Source Code Cross Referenced for DeleteGroup.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:
010:        import org.jasig.portal.ChannelRuntimeData;
011:        import org.jasig.portal.channels.groupsmanager.CGroupsManagerSessionData;
012:        import org.jasig.portal.channels.groupsmanager.GroupsManagerXML;
013:        import org.jasig.portal.channels.groupsmanager.Utility;
014:        import org.jasig.portal.groups.IEntityGroup;
015:        import org.w3c.dom.Document;
016:        import org.w3c.dom.Element;
017:        import org.w3c.dom.Node;
018:        import org.w3c.dom.NodeList;
019:
020:        /**
021:         * This command deletes an IEntityGroup and removes all of it's associations.
022:         * It then gathers all of the xml
023:         * nodes for the parent group and removes the child node of the removed member.
024:         * @author Don Fracapane
025:         * @version $Revision: 34756 $
026:         */
027:        public class DeleteGroup extends GroupsManagerCommand {
028:
029:            public DeleteGroup() {
030:            }
031:
032:            /**
033:             * This is the public method
034:             * @param sessionData
035:             * @throws Exception
036:             */
037:            public void execute(CGroupsManagerSessionData sessionData)
038:                    throws Exception {
039:                //ChannelStaticData staticData = sessionData.staticData;
040:                ChannelRuntimeData runtimeData = sessionData.runtimeData;
041:
042:                Utility.logMessage("DEBUG", "DeleteGroup::execute(): Start");
043:                Document model = getXmlDoc(sessionData);
044:                String delId = getCommandArg(runtimeData);
045:                Element delElem = GroupsManagerXML.getElementByTagNameAndId(
046:                        model, GROUP_TAGNAME, delId);
047:                Element pn = ((Element) delElem.getParentNode());
048:                if (pn != null) {
049:                    sessionData.highlightedGroupID = pn.getAttribute("id");
050:                }
051:                String delKey = delElem.getAttribute("key");
052:                String elemName = delElem.getAttribute("name");
053:                String retMsg;
054:                Node parentNode;
055:                Node deletedNode;
056:                Utility.logMessage("DEBUG", "DeleteGroup::execute(): Group: "
057:                        + elemName + "will be deleted");
058:                if (Utility.areEqual(delElem.getAttribute("searchResults"),
059:                        "true")) {
060:                    // if it is search results, just delete the node and skip the rest
061:                    delElem.getParentNode().removeChild(delElem);
062:                } else {
063:                    IEntityGroup delGroup = sessionData.lockedGroup;
064:                    if (delGroup == null) {
065:                        retMsg = "Unable to retrieve Group!";
066:                        sessionData.feedback = retMsg;
067:                        return;
068:                    }
069:                    Utility.logMessage("DEBUG",
070:                            "DeleteGroup::execute(): About to delete group: "
071:                                    + elemName);
072:                    // remove permissions associated with group
073:                    deletePermissions(delGroup);
074:                    // delete the group
075:                    delGroup.delete();
076:                    Utility.logMessage("DEBUG",
077:                            "DeleteGroup::execute(): About to delete xml nodes for group: "
078:                                    + elemName);
079:                    // remove all xml nodes for this group
080:                    Iterator deletedNodes = GroupsManagerXML
081:                            .getNodesByTagNameAndKey(model, GROUP_TAGNAME,
082:                                    delKey);
083:                    IEntityGroup parentEntGrp = null;
084:                    String hasMbrs = "duh";
085:                    while (deletedNodes.hasNext()) {
086:                        deletedNode = (Node) deletedNodes.next();
087:                        parentNode = deletedNode.getParentNode();
088:                        String nodeKey = ((Element) parentNode)
089:                                .getAttribute("key");
090:                        if (parentEntGrp == null
091:                                || !parentEntGrp.getKey().equals(nodeKey)) {
092:                            if (!Utility.areEqual(nodeKey, "")) {
093:                                parentEntGrp = GroupsManagerXML
094:                                        .retrieveGroup(nodeKey);
095:                                hasMbrs = String.valueOf(parentEntGrp
096:                                        .hasMembers());
097:                                parentNode.removeChild(deletedNode);
098:                            } else {
099:                                //Search elements have a null "key"
100:                                parentNode.removeChild(deletedNode);
101:                                NodeList nl = parentNode.getChildNodes();
102:                                if (nl.getLength() > 0) {
103:                                    hasMbrs = "true";
104:                                } else {
105:                                    hasMbrs = "false";
106:                                }
107:                            }
108:                        }
109:                        ((Element) parentNode).setAttribute("hasMembers",
110:                                hasMbrs);
111:                    }
112:
113:                    /** Remove the permission elements in the xmlDoc */
114:                    Node principalNode = model.getDocumentElement()
115:                            .getElementsByTagName("principal").item(0);
116:                    NodeList permElems = model
117:                            .getElementsByTagName("permission");
118:                    /** If we delete from the bottom up, the NodeList elements shift down
119:                     *  everytime we delete an element. Since the elements that we are looking
120:                     *  for are sequential and because we increment the counter at the end of
121:                     *  the loop, the element that we should process next slips down into the
122:                     *  slot that we just processed. We therefore end up deleting every other
123:                     *  element. The solution is to delete from the top down.
124:                     */
125:                    for (int i = permElems.getLength() - 1; i > -1; i--) {
126:                        Element permElem = (Element) permElems.item(i);
127:                        if (permElem.getAttribute("target").equals(delKey)) {
128:                            principalNode.removeChild(permElem);
129:                        }
130:                    }
131:                    sessionData.mode = BROWSE_MODE;
132:                }
133:                Utility.logMessage("DEBUG", "DeleteGroup::execute(): Finished");
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.