/** Creates a new user. */
CmsUser createUser(String username, Map<String, Object> properties, Map<String, Object> credentials);
+ /** Created a new group. */
+ CmsGroup createGroup(String dn);
+
/** Creates a group. */
CmsGroup getOrCreateGroup(HierarchyUnit groups, String commonName);
/** Add a member to this group. */
void addMember(CmsGroup group, Role role);
+ /** Remove a member from this group. */
+ void removeMember(CmsGroup group, Role role);
+
void edit(Runnable action);
/* MISCELLANEOUS */
}
}
+ @Override
+ public CmsGroup createGroup(String dn) {
+ try {
+ userTransaction.begin();
+ CmsGroup group = (CmsGroup) userAdmin.createRole(dn, Role.GROUP);
+ userTransaction.commit();
+ return group;
+ } catch (Exception e) {
+ try {
+ userTransaction.rollback();
+ } catch (Exception e1) {
+ log.error("Could not roll back", e1);
+ }
+ if (e instanceof RuntimeException)
+ throw (RuntimeException) e;
+ else
+ throw new RuntimeException("Cannot create group " + dn, e);
+ }
+ }
+
@Override
public CmsGroup getOrCreateGroup(HierarchyUnit groups, String commonName) {
try {
if (log.isTraceEnabled())
log.trace("Cannot rollback transaction", e2);
}
- throw new RuntimeException("Cannot add object classes " + role + " to group " + group, e1);
+ throw new RuntimeException("Cannot add member " + role + " to group " + group, e1);
+ }
+ }
+
+ @Override
+ public void removeMember(CmsGroup group, Role role) {
+ try {
+ userTransaction.begin();
+ group.removeMember(role);
+ userTransaction.commit();
+ } catch (Exception e1) {
+ try {
+ if (!userTransaction.isNoTransactionStatus())
+ userTransaction.rollback();
+ } catch (Exception e2) {
+ if (log.isTraceEnabled())
+ log.trace("Cannot rollback transaction", e2);
+ }
+ throw new RuntimeException("Cannot remove member " + role + " from group " + group, e1);
}
}