Document model = getXmlDoc(sessionData);
String parentID = getCommandArg(runtimeData);
String newGrpName = runtimeData.getParameter("grpNewName");
Utility.logMessage("DEBUG", "CreateGroup::execute(): New grp: " + newGrpName +
" will be added to parent element = " + parentID);
ILockableEntityGroup parentGroup = null;
Class parentEntityType;
Element parentElem = GroupsManagerXML.getElementByTagNameAndId(model, GROUP_TAGNAME, parentID);
String parentKey = parentElem.getAttribute("key");
String retMsg;
Iterator parentNodes;
if (parentElem == null) {
retMsg = "Unable to find Parent element!";
sessionData.feedback = retMsg;
Utility.logMessage("ERROR", "CreateGroup::execute(): " + retMsg);
return;
}
Utility.logMessage("DEBUG", "CreateGroup::execute(): Parent element was found!");
//parentGroup = GroupsManagerXML.retrieveGroup(parentKey);
parentGroup = sessionData.lockedGroup;
if (parentGroup == null) {
retMsg = "Unable to retrieve Parent Entity Group!";
sessionData.feedback = retMsg;
return;
}
parentEntityType = parentGroup.getLeafType();
//parentEntityType = (Class) GroupsManagerXML.getEntityTypes().get("Person");
Utility.logMessage("DEBUG", "CreateGroup::execute(): About to create new group: "
+ newGrpName + " Type: " + parentEntityType.getName());
String userID = sessionData.user.getEntityIdentifier().getKey();
Utility.logMessage("DEBUG", "CreateGroup::execute(): userID = " + userID);
IEntityGroup childEntGrp = GroupService.newGroup(parentEntityType);
childEntGrp.setName(newGrpName);
childEntGrp.setCreatorID(userID);
childEntGrp.update();
Utility.logMessage("DEBUG", "CreateGroup::execute(): About to add new group: "
+ newGrpName);
parentGroup.addMember((IGroupMember)childEntGrp);
parentGroup.updateMembersAndRenewLock();
parentNodes = GroupsManagerXML.getNodesByTagNameAndKey(model, GROUP_TAGNAME, parentKey);
// add new group to all parent group xml nodes
while (parentNodes.hasNext()) {
Element parentNode = (Element)parentNodes.next();
GroupsManagerXML.getGroupMemberXml((IGroupMember)parentGroup, true, parentNode,