logger.info("Attempting to create group " + groupName);
Group group = new GroupAider(groupName);
final DBBroker broker = context.getBroker();
final Subject currentUser = broker.getSubject();
try {
final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
// add the current user as a group manager
group.addManager(currentUser);
if (args.length == 2) {
// add the additional group managers, this also makes sure they
// all exist first!
for (final SequenceIterator i = args[1].iterate(); i.hasNext();) {
final String groupManager = i.nextItem().getStringValue();
final Account groupManagerAccount = sm.getAccount(groupManager);
if (groupManagerAccount == null) {
logger.error("Could not find the user: " + groupManager);
// throw exception is better -shabanovd
return BooleanValue.FALSE;
}
group.addManager(groupManagerAccount);
}
}
// create the group
group = sm.addGroup(group);
//TEMP - ESCALATE TO DBA :-(
//START TEMP - we also need to make every manager a member of the group otherwise
//they do not show up as group members automatically - this is a design problem because group
//membership is managed on the user and not the group, this needs to be fixed!
//see XMLDBAddUserToGroup and XMLDBRemoveUserFromGroup also
final Subject currentSubject = context.getBroker().getSubject();
try {
//escalate
context.getBroker().setSubject(sm.getSystemSubject());
//perform action