01: /* Copyright 2001 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.channels.groupsmanager.commands;
07:
08: import org.jasig.portal.ChannelRuntimeData;
09: import org.jasig.portal.ChannelStaticData;
10: import org.jasig.portal.channels.groupsmanager.CGroupsManagerSessionData;
11: import org.jasig.portal.channels.groupsmanager.GroupsManagerXML;
12: import org.jasig.portal.channels.groupsmanager.Utility;
13: import org.jasig.portal.groups.IGroupMember;
14: import org.jasig.portal.services.GroupService;
15: import org.w3c.dom.Document;
16: import org.w3c.dom.Element;
17:
18: /**
19: * AddMembers is a command which sets the id of the parent group.
20: * The parent group is the group to which child members will be added.
21: * Control is then passed to a selection view where the child group members will
22: * be selected for addition. When the selection has been completed by the user,
23: * the DoneWithSelection command will be invoked where the selected children
24: * group members are actually processed. Alternatively, the CancelSelection
25: * command is invoked to cancel the selection process and reset the mode and
26: * view control parameters.
27: * @author Don Fracapane
28: * @version $Revision: 34756 $
29: */
30: public class AddMembers extends GroupsManagerCommand {
31:
32: /**
33: * put your documentation comment here
34: */
35: public AddMembers() {
36: }
37:
38: /**
39: * This is the public method
40: * @param sessionData
41: * @throws Exception
42: */
43: public void execute(CGroupsManagerSessionData sessionData)
44: throws Exception {
45: ChannelStaticData staticData = sessionData.staticData;
46: ChannelRuntimeData runtimeData = sessionData.runtimeData;
47: Document model = getXmlDoc(sessionData);
48: Utility.logMessage("DEBUG", "AddMembers::execute(): Start");
49: String parentAddElemId = getCommandArg(runtimeData);
50:
51: IGroupMember pg = GroupsManagerXML
52: .retrieveGroupMemberForElementId(model, parentAddElemId);
53: sessionData.rootViewGroupID = Utility.translateKeytoID(
54: GroupService.getRootGroup(pg.getLeafType()).getKey(),
55: sessionData.getUnrestrictedData());
56: // Parent was locked so no other thread or process could have changed it, but
57: // child members could have changed.
58: Element parentElem = GroupsManagerXML.getElementById(model,
59: parentAddElemId);
60: GroupsManagerXML.refreshAllNodesRecursivelyIfRequired(
61: sessionData.getUnrestrictedData(), parentElem);
62: sessionData.returnToMode = sessionData.mode;
63: sessionData.mode = SELECT_MODE;
64: sessionData.highlightedGroupID = sessionData.rootViewGroupID;
65: Utility.logMessage("DEBUG",
66: "AddMembers::execute(): Uid of parent element = "
67: + parentAddElemId);
68: staticData.setParameter("groupParentId", parentAddElemId);
69: }
70: }
|