Source Code Cross Referenced for DoneWithSelection.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » channels » groupsmanager » commands » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.channels.groupsmanager.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.channels.groupsmanager.commands;
007:
008:        import java.util.Iterator;
009:        import java.util.Vector;
010:
011:        import org.jasig.portal.ChannelStaticData;
012:        import org.jasig.portal.channels.groupsmanager.CGroupsManagerSessionData;
013:        import org.jasig.portal.channels.groupsmanager.GroupsManagerXML;
014:        import org.jasig.portal.channels.groupsmanager.Utility;
015:        import org.jasig.portal.groups.IGroupMember;
016:        import org.jasig.portal.groups.ILockableEntityGroup;
017:        import org.w3c.dom.Document;
018:        import org.w3c.dom.Element;
019:        import org.w3c.dom.NodeList;
020:
021:        /** A select cycle could be started in Servant mode or it could be started by
022:         *  the AddMembers command. The AddMembers command sets the id of the parent
023:         *  group (ie. the group to which child  members will be added). Control is then
024:         *  passed to a selection view where the child group members will be selected
025:         *  for addition. When the selection has been completed by the user, the
026:         *  DoneWithSelection command will be invoked where the selected members are
027:         *  added to a collection of IAuthorizationPrincipal. If a parent group had
028:         *  been set the children groupmembers are actually added to the parent group.
029:         *  If in Servant mode, the collection is simply returned to the master channel.
030:         *  Alternatively, the CancelSelection command have been invoked by the user to
031:         *  cancel the selection process and reset the mode and view control parameters.
032:         * @author Don Fracapane
033:         * @version $Revision: 34756 $
034:         */
035:        public class DoneWithSelection extends GroupsManagerCommand {
036:
037:            /** Creates new AddMember */
038:            public DoneWithSelection() {
039:            }
040:
041:            /**
042:             * This is the public method
043:             * @param sessionData
044:             * @throws Exception
045:             */
046:            public void execute(CGroupsManagerSessionData sessionData)
047:                    throws Exception {
048:                ChannelStaticData staticData = sessionData.staticData;
049:                //ChannelRuntimeData runtimeData= sessionData.runtimeData;
050:
051:                Utility.logMessage("DEBUG",
052:                        "DoneWithSelection::execute(): Start");
053:                String parentId = null;
054:                boolean hasParentId = hasParentId(staticData);
055:                Utility.logMessage("DEBUG",
056:                        "DoneWithSelection::execute(): Parent ID is set: "
057:                                + hasParentId);
058:                IGroupMember[] princResults = null;
059:                Document model = getXmlDoc(sessionData);
060:                Element rootElem = model.getDocumentElement();
061:                NodeList nGroupList = rootElem
062:                        .getElementsByTagName(GROUP_TAGNAME);
063:                NodeList nEntityList = rootElem
064:                        .getElementsByTagName(ENTITY_TAGNAME);
065:                Vector gmCollection = new Vector();
066:                Element parentElem = null;
067:                Utility.logMessage("DEBUG",
068:                        "DoneWithSelection::execute(): Starting group process");
069:                addGroupMemberToCollection(gmCollection, nGroupList);
070:                Utility
071:                        .logMessage("DEBUG",
072:                                "DoneWithSelection::execute(): Starting entity process");
073:                addGroupMemberToCollection(gmCollection, nEntityList);
074:                // check if selections were made
075:                if (gmCollection.size() < 1) {
076:                    sessionData.feedback = sessionData.feedback
077:                            + "\n No groups or people were selected! ";
078:                    return;
079:                }
080:
081:                /** Presence of parentID means the process is not in servant mode. That is,
082:                 * the master channel is the Groups Manager channel and AddMembers had
083:                 * been selected
084:                 */
085:                if (hasParentId) {
086:                    parentId = getParentId(staticData);
087:                    Utility.logMessage("DEBUG",
088:                            "DoneWithSelection::execute(): Parent ID is set to: "
089:                                    + parentId);
090:                    parentElem = GroupsManagerXML.getElementByTagNameAndId(
091:                            model, GROUP_TAGNAME, parentId);
092:                    if (parentElem == null) {
093:                        Utility
094:                                .logMessage("ERROR",
095:                                        "DoneWithSelection::execute: Error parent element not found");
096:                        return;
097:                    }
098:                    addChildrenToGroup(gmCollection, sessionData, parentElem,
099:                            model);
100:                    clearSelected(sessionData);
101:                    sessionData.mode = sessionData.returnToMode;
102:                    ;
103:                    sessionData.highlightedGroupID = parentId;
104:                    sessionData.rootViewGroupID = null;
105:                    // Parent was locked so no other thread or process could have changed it, but
106:                    // child members could have changed.
107:                    GroupsManagerXML.refreshAllNodesRecursivelyIfRequired(
108:                            sessionData.getUnrestrictedData(), parentElem);
109:                    sessionData.staticData.remove("groupParentId");
110:                } else {
111:                    princResults = (IGroupMember[]) gmCollection
112:                            .toArray(new IGroupMember[0]);
113:                    if (princResults.length > 0) {
114:                        staticData.put("princResults", princResults);
115:                        staticData.setParameter("groupManagerFinished", "true");
116:                    }
117:                }
118:            }
119:
120:            /**
121:             * This method processes the xml document looking for selected groupmembers.
122:             * It then creates an instance of IGroupMember for each selected
123:             * member and passes the collection back.
124:             * @param gmCollection
125:             * @param nList
126:             * @throws Exception
127:             */
128:            private void addGroupMemberToCollection(Vector gmCollection,
129:                    NodeList nList) throws Exception {
130:                boolean addit;
131:                for (int i = 0; i < nList.getLength(); i++) {
132:                    Element elem = (org.w3c.dom.Element) nList.item(i);
133:                    if (Utility.areEqual(elem.getAttribute("selected"), "true")) {
134:                        addit = true;
135:                        Iterator gmItr = gmCollection.iterator();
136:                        while (gmItr.hasNext()) {
137:                            IGroupMember ggmm = (IGroupMember) gmItr.next();
138:                            if ((ggmm.getKey().equals(elem.getAttribute("key")))
139:                                    && (ggmm.getType().equals(elem
140:                                            .getAttribute("type")))) {
141:                                addit = false;
142:                                break;
143:                            }
144:                        }
145:                        if (addit) {
146:                            IGroupMember gm = Utility
147:                                    .retrieveGroupMemberForKeyAndType(elem
148:                                            .getAttribute("key"), elem
149:                                            .getAttribute("type"));
150:                            gmCollection.add(gm);
151:                            Utility.logMessage("DEBUG",
152:                                    "DoneWithSelection::addGroupMemberToCollection(): "
153:                                            + "- adding group member"
154:                                            + elem.getAttribute("key"));
155:                        }
156:                    }
157:                }
158:            }
159:
160:            /**
161:             * This section adds the selected members to an IEntityGroup.
162:             * @param gmCollection
163:             * @param sessionData
164:             * @param parentElem
165:             * @param model
166:             * @throws Exception
167:             */
168:            private void addChildrenToGroup(Vector gmCollection,
169:                    CGroupsManagerSessionData sessionData, Element parentElem,
170:                    Document model) throws Exception {
171:                //ChannelRuntimeData runtimeData = sessionData.runtimeData;
172:                Element parent;
173:                ILockableEntityGroup parentGroup = null;
174:                IGroupMember childGm = null;
175:                Element childElem;
176:                parentGroup = sessionData.lockedGroup;
177:                Iterator gmItr = gmCollection.iterator();
178:                while (gmItr.hasNext()) {
179:                    childGm = (IGroupMember) gmItr.next();
180:                    Utility.logMessage("DEBUG",
181:                            "DoneWithSelection::execute: About to add child");
182:                    // add to parent group
183:                    parentGroup.addMember(childGm);
184:                    // remove property elements for child gm and clear the Entity Properties cache.
185:                    GroupsManagerXML.removePropertyElements(model, childGm,
186:                            true);
187:                    // update parent group
188:                    parentGroup.updateMembersAndRenewLock();
189:                    // get parent element(s) and add element for child group member
190:                    Iterator parentNodes = GroupsManagerXML
191:                            .getNodesByTagNameAndKey(model, GROUP_TAGNAME,
192:                                    parentElem.getAttribute("key"));
193:                    while (parentNodes.hasNext()) {
194:                        parent = (Element) parentNodes.next();
195:
196:                        childElem = GroupsManagerXML.getGroupMemberXml(childGm,
197:                                false, null, sessionData.getUnrestrictedData());
198:                        parent.appendChild(childElem);
199:                        parent.setAttribute("hasMembers", "true");
200:                    }
201:                }
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.