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 java.util.Iterator;
09:
10: import org.jasig.portal.ChannelRuntimeData;
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.w3c.dom.Document;
15: import org.w3c.dom.Element;
16:
17: /**
18: * SelectMembers sets the "selected" attribute for each elements that was
19: * selected by the user.
20: * @author Don Fracapane
21: * @version $Revision: 35497 $
22: */
23: public class SelectMembers extends GroupsManagerCommand {
24:
25: public SelectMembers() {
26: }
27:
28: /**
29: * This is the public method
30: * @param sessionData
31: * @throws Exception
32: */
33: public void execute(CGroupsManagerSessionData sessionData)
34: throws Exception {
35: ChannelRuntimeData runtimeData = sessionData.runtimeData;
36:
37: Utility.logMessage("DEBUG", "SelectMembers::execute(): Start");
38: Document model = getXmlDoc(sessionData);
39: String theCommand = getCommand(runtimeData);
40: Utility.logMessage("DEBUG",
41: "SelectMembers::execute(): action = " + theCommand);
42: Iterator itr = runtimeData.keySet().iterator();
43: Element theElement;
44: while (itr.hasNext()) {
45: String key = (String) itr.next();
46: String this Perm = null;
47: String tagname = theCommand + "//";
48: if (key.indexOf(tagname) > -1) {
49: this Perm = key.substring(key.lastIndexOf("/") + 1);
50: if (Utility.notEmpty(this Perm)) {
51: //Utility.logMessage("DEBUG","SelectMembers::renderXML(): Iterating over input");
52: String princeKey = this Perm.substring(0, this Perm
53: .lastIndexOf("|"));
54: String princeType = this Perm.substring(this Perm
55: .lastIndexOf("|") + 1);
56: //String principal = princeType + "." + princeKey;
57: theElement = GroupsManagerXML
58: .getElementByTagNameAndId(model,
59: princeType, princeKey);
60: // test first
61: if (theElement != null) {
62: GroupsManagerXML.refreshAllNodesIfRequired(
63: sessionData.getUnrestrictedData(),
64: theElement);
65: theElement.setAttribute("selected", String
66: .valueOf(theCommand.equals("Select")));
67: Utility.logMessage("DEBUG",
68: "SelectMembers::execute(): "
69: + theCommand + "ed element "
70: + princeType + " " + princeKey);
71: }
72: }
73: }
74: }
75: }
76: }
|