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.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10: import org.jasig.portal.ChannelStaticData;
11: import org.jasig.portal.channels.groupsmanager.CGroupsManagerSessionData;
12: import org.jasig.portal.channels.groupsmanager.GroupsManagerXML;
13: import org.jasig.portal.channels.groupsmanager.Utility;
14: import org.jasig.portal.concurrency.LockingException;
15: import org.w3c.dom.Document;
16: import org.w3c.dom.Element;
17:
18: /** A select cycle could be started in Servant mode or it could be started by
19: * the AddMembers command. The AddMembers command sets the id of the parent
20: * group (ie. the group to which child members will be added). Control is then
21: * passed to a selection view where the child group members will be selected
22: * for addition. When the selection has been completed by the user, the
23: * 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: 36809 $
29: */
30: public class CancelSelection extends GroupsManagerCommand {
31:
32: private static final Log log = LogFactory
33: .getLog(GroupsManagerCommand.class);
34:
35: public CancelSelection() {
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:
47: Document model = getXmlDoc(sessionData);
48: /** @todo move to GroupManagerCommand.cleanUp */
49: Utility
50: .logMessage("DEBUG",
51: "CancelSelection::execute(): Start");
52: clearSelected(sessionData);
53: String parentId = getParentId(staticData);
54: if (parentId != null) {
55: // go back to stored mode
56: sessionData.mode = sessionData.returnToMode;
57: sessionData.highlightedGroupID = parentId;
58: sessionData.rootViewGroupID = null;
59: // Parent is locked so no other thread or process could have changed it, but
60: // child members could have changed.
61: Element parentElem = GroupsManagerXML.getElementById(model,
62: parentId);
63: GroupsManagerXML.refreshAllNodesRecursivelyIfRequired(
64: sessionData.getUnrestrictedData(), parentElem);
65: sessionData.staticData.remove("groupParentId");
66: } else {
67: // @todo refactor into separate servant finish command
68: if (sessionData.lockedGroup != null) {
69: try {
70: sessionData.lockedGroup.getLock().release();
71: } catch (LockingException e) {
72: log.error(e, e);
73: }
74: }
75: staticData.setParameter("groupManagerFinished", "true");
76: }
77: }
78: }
|