Source Code Cross Referenced for HandlerUtils.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » layout » dlm » 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.layout.dlm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2005 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.layout.dlm;
007:
008:        import org.jasig.portal.PortalException;
009:        import org.jasig.portal.layout.IUserLayoutStore;
010:        import org.jasig.portal.layout.UserLayoutStoreFactory;
011:        import org.jasig.portal.security.IPerson;
012:        import org.w3c.dom.Document;
013:        import org.w3c.dom.Element;
014:
015:        /** 
016:         * Utility functions for applying user changes to the user's plf prior
017:         * to persisting.
018:         * 
019:         * @version $Revision: 36294 $Date$
020:         * @since uPortal 2.5
021:         */
022:        public class HandlerUtils {
023:            public static final String RCS_ID = "@(#) $Header$";
024:
025:            /**
026:               This method returns the PLF version of the passed in compViewNode. If
027:               create is false and a node with the same id is not found in the PLF then
028:               null is returned. If the create is true then an attempt is made to
029:               create the node along with any necessary ancestor nodes needed to
030:               represent the path along the tree.
031:             */
032:            public static Element getPLFNode(Element compViewNode,
033:                    IPerson person, boolean create, boolean includeChildNodes)
034:                    throws PortalException {
035:                Document plf = (Document) person.getAttribute(Constants.PLF);
036:                String ID = compViewNode.getAttribute(Constants.ATT_ID);
037:                Element plfNode = plf.getElementById(ID);
038:
039:                if (plfNode != null)
040:                    return plfNode;
041:
042:                // make sure that the root isn't what we are trying to get. Root is not
043:                // registered with document under an id.
044:
045:                if (compViewNode.getNodeName().equals("layout"))
046:                    return plf.getDocumentElement();
047:
048:                // if not found then create if indicated.
049:                if (create == true)
050:                    return createPlfNodeAndPath(compViewNode,
051:                            includeChildNodes, person);
052:                return null;
053:            }
054:
055:            /**
056:               Creates a copy of the passed in ILF node in the PLF if not already
057:               there as well as creating any ancestor nodes along the path from this
058:               node up to the layout root if they are not there.
059:             */
060:            public static Element createPlfNodeAndPath(Element compViewNode,
061:                    boolean includeChildNodes, IPerson person)
062:                    throws PortalException {
063:                // first attempt to get parent
064:                Element compViewParent = (Element) compViewNode.getParentNode();
065:                Element plfParent = getPLFNode(compViewParent, person, true,
066:                        false);
067:                Document plf = (Document) person.getAttribute(Constants.PLF);
068:
069:                // if ilf copy being created we can append to parent and use the
070:                // position set to place it.
071:
072:                if (compViewNode.getAttribute(Constants.ATT_ID).startsWith(
073:                        Constants.FRAGMENT_ID_USER_PREFIX))
074:                    return createILFCopy(compViewNode, compViewParent,
075:                            includeChildNodes, plf, plfParent, person);
076:                return createOrMovePLFOwnedNode(compViewNode, compViewParent,
077:                        true, // create if not found
078:                        includeChildNodes, plf, plfParent, person);
079:            }
080:
081:            /**
082:               Creates a copy of an ilf node in the plf and sets up necessary storage
083:               attributes.
084:             */
085:            private static Element createILFCopy(Element compViewNode,
086:                    Element compViewParent, boolean includeChildNodes,
087:                    Document plf, Element plfParent, IPerson person)
088:                    throws PortalException {
089:                Element plfNode = (Element) plf.importNode(compViewNode,
090:                        includeChildNodes);
091:                // make sure that we don't include ILF restriction params in the PLF if
092:                // this ILF node contained any.
093:                plfNode.removeAttributeNS(Constants.NS_URI,
094:                        Constants.LCL_ADD_CHILD_ALLOWED);
095:                plfNode.removeAttributeNS(Constants.NS_URI,
096:                        Constants.LCL_DELETE_ALLOWED);
097:                plfNode.removeAttributeNS(Constants.NS_URI,
098:                        Constants.LCL_EDIT_ALLOWED);
099:                plfNode.removeAttributeNS(Constants.NS_URI,
100:                        Constants.LCL_MOVE_ALLOWED);
101:
102:                String ID = plfNode.getAttribute(Constants.ATT_ID);
103:                plfNode.setIdAttribute(Constants.ATT_ID, true);
104:
105:                IUserLayoutStore uls = null;
106:                uls = UserLayoutStoreFactory.getUserLayoutStoreImpl();
107:
108:                if (plfNode.getAttribute(Constants.ATT_PLF_ID).equals("")) {
109:                    String plfID = null;
110:
111:                    try {
112:                        if (!plfNode.getAttribute(Constants.ATT_CHANNEL_ID)
113:                                .equals("")) // dealing with a channel
114:                            plfID = uls.generateNewChannelSubscribeId(person);
115:                        else
116:                            plfID = uls.generateNewFolderId(person);
117:                    } catch (Exception e) {
118:                        throw new PortalException(
119:                                "Exception encountered while "
120:                                        + "generating new user layout node "
121:                                        + "Id for userId=" + person.getID(), e);
122:                    }
123:
124:                    plfNode.setAttributeNS(Constants.NS_URI,
125:                            Constants.ATT_PLF_ID, plfID);
126:                    plfNode.setAttributeNS(Constants.NS_URI,
127:                            Constants.ATT_ORIGIN, ID);
128:                }
129:
130:                plfParent.appendChild(plfNode);
131:                PositionManager.updatePositionSet(compViewParent, plfParent,
132:                        person);
133:                return plfNode;
134:            }
135:
136:            /**
137:               Creates or moves the plf copy of a node in the composite view and
138:               inserting it before its next highest sibling so that if dlm is not used
139:               then the model ends up exactly like the original non-dlm persistance
140:               version. The position set is also updated and if no ilf copy nodes are
141:               found in the sibling list the set is cleared if it exists.
142:             */
143:            static Element createOrMovePLFOwnedNode(Element compViewNode,
144:                    Element compViewParent, boolean createIfNotFound,
145:                    boolean createChildNodes, Document plf, Element plfParent,
146:                    IPerson person) throws PortalException {
147:                Element child = (Element) compViewParent.getFirstChild();
148:                Element nextOwnedSibling = null;
149:                boolean insertionPointFound = false;
150:
151:                while (child != null) {
152:                    if (insertionPointFound
153:                            && nextOwnedSibling == null
154:                            && !child.getAttribute(Constants.ATT_ID)
155:                                    .startsWith(
156:                                            Constants.FRAGMENT_ID_USER_PREFIX))
157:                        nextOwnedSibling = child;
158:
159:                    if (child == compViewNode)
160:                        insertionPointFound = true;
161:                    child = (Element) child.getNextSibling();
162:                }
163:
164:                if (insertionPointFound == false)
165:                    return null;
166:
167:                String nextSibID = null;
168:                Element nextPlfSib = null;
169:
170:                if (nextOwnedSibling != null) {
171:                    nextSibID = nextOwnedSibling.getAttribute(Constants.ATT_ID);
172:                    nextPlfSib = plf.getElementById(nextSibID);
173:                }
174:
175:                String plfNodeID = compViewNode.getAttribute(Constants.ATT_ID);
176:                Element plfNode = plf.getElementById(plfNodeID);
177:
178:                if (plfNode == null) {
179:                    if (createIfNotFound == true) {
180:                        plfNode = (Element) plf.importNode(compViewNode,
181:                                createChildNodes);
182:                        plfNode.setIdAttribute(Constants.ATT_ID, true);
183:                    } else
184:                        return null;
185:                }
186:
187:                if (nextPlfSib == null)
188:                    plfParent.appendChild(plfNode);
189:                else
190:                    plfParent.insertBefore(plfNode, nextPlfSib);
191:
192:                PositionManager.updatePositionSet(compViewParent, plfParent,
193:                        person);
194:                return (Element) plfNode;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.