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


001:        /* Copyright 2004 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.alm.channels;
007:
008:        import java.util.Iterator;
009:        import java.util.Map;
010:        import java.util.Collection;
011:        import java.util.HashMap;
012:
013:        import org.jasig.portal.IPrivileged;
014:        import org.jasig.portal.PortalControlStructures;
015:        import org.jasig.portal.PortalException;
016:        import org.jasig.portal.ThemeStylesheetUserPreferences;
017:        import org.jasig.portal.channels.BaseChannel;
018:        import org.jasig.portal.layout.IUserLayoutManager;
019:        import org.jasig.portal.layout.TransientUserLayoutManagerWrapper;
020:        import org.jasig.portal.layout.alm.ALFolder;
021:        import org.jasig.portal.layout.alm.ALFragment;
022:        import org.jasig.portal.layout.alm.ALNode;
023:        import org.jasig.portal.layout.alm.IAggregatedUserLayoutManager;
024:        import org.jasig.portal.layout.alm.ILayoutFragment;
025:        import org.jasig.portal.utils.XSLT;
026:        import org.w3c.dom.Document;
027:        import org.w3c.dom.Node;
028:        import org.w3c.dom.Element;
029:
030:        /**
031:         * An abstract class containing the basic business-logic and components for
032:         * CFragmentManager and CContentSubscriber.
033:         * 
034:         * Prior to uPortal 2.5, this channel existed in the org.jasig.portal.layout.channels
035:         * package.  It was moved to its present package to reflect that it is a part of
036:         * Aggregated Layouts.
037:         * 
038:         * @author Michael Ivanov, mvi@immagic.com
039:         * @version $Revision: 36811 $
040:         * @since uPortal 2.5
041:         */
042:        public abstract class FragmentManager extends BaseChannel implements 
043:                IPrivileged {
044:
045:            protected IAggregatedUserLayoutManager alm;
046:            protected ThemeStylesheetUserPreferences themePrefs;
047:            protected Map fragments;
048:
049:            protected String getFragmentRootId(String fragmentId)
050:                    throws PortalException {
051:                if (fragments != null && !fragments.isEmpty()) {
052:                    ALFragment fragment = (ALFragment) fragments
053:                            .get(fragmentId);
054:                    ALFolder rootFolder = (ALFolder) fragment.getNode(fragment
055:                            .getRootId());
056:                    return rootFolder.getFirstChildNodeId();
057:                }
058:                return null;
059:            }
060:
061:            /**
062:             * Passes portal control structure to the channel.
063:             * @see PortalControlStructures
064:             */
065:            public void setPortalControlStructures(PortalControlStructures pcs)
066:                    throws PortalException {
067:                themePrefs = pcs.getUserPreferencesManager()
068:                        .getUserPreferences()
069:                        .getThemeStylesheetUserPreferences();
070:                IUserLayoutManager ulm = pcs.getUserPreferencesManager()
071:                        .getUserLayoutManager();
072:                if (ulm instanceof  TransientUserLayoutManagerWrapper)
073:                    ulm = ((TransientUserLayoutManagerWrapper) ulm)
074:                            .getOriginalLayoutManager();
075:                if (ulm instanceof  IAggregatedUserLayoutManager)
076:                    alm = (IAggregatedUserLayoutManager) ulm;
077:            }
078:
079:            protected void getFragmentList(Document document)
080:                    throws PortalException {
081:                getFragmentList(document, document);
082:            }
083:
084:            protected void getFragmentList(Document document, Node node)
085:                    throws PortalException {
086:                Element fragmentsNode = document.createElement("fragments");
087:                node.appendChild(fragmentsNode);
088:                Element category = document.createElement("category");
089:                category.setAttribute("name", "Fragments");
090:                category.setAttribute("view", "expanded");
091:                category.setAttribute("ID", "fragcat.1");
092:                fragmentsNode.appendChild(category);
093:                boolean updateList = false;
094:                if (fragments != null) {
095:                    for (Iterator ids = fragments.keySet().iterator(); ids
096:                            .hasNext();) {
097:                        String fragmentId = (String) ids.next();
098:                        ALFragment fragment = (ALFragment) fragments
099:                                .get(fragmentId);
100:                        String fragmentRootId = getFragmentRootId(fragmentId);
101:                        // if the fragment root ID is NULL then the fragment must be deleted
102:                        // since it does not have any content
103:                        if (fragmentRootId == null) {
104:                            alm.deleteFragment(fragmentId);
105:                            if (!updateList)
106:                                updateList = true;
107:                            continue;
108:                        }
109:                        Element fragmentNode = document
110:                                .createElement("fragment");
111:                        fragmentNode.setAttribute("ID", fragmentId);
112:                        category.appendChild(fragmentNode);
113:                        Element rootId = document.createElement("rootNodeID");
114:                        rootId.appendChild(document
115:                                .createTextNode(fragmentRootId));
116:                        rootId.setAttribute("immutable", fragment.getNode(
117:                                fragmentRootId).getNodeDescription()
118:                                .isImmutable() ? "Y" : "N");
119:                        fragmentNode.appendChild(rootId);
120:                        Element type = document.createElement("type");
121:                        type.appendChild(document.createTextNode(fragment
122:                                .isPushedFragment() ? "pushed" : "pulled"));
123:                        fragmentNode.appendChild(type);
124:                        Element fname = document.createElement("fname");
125:                        fname.appendChild(document.createTextNode(fragment
126:                                .getFunctionalName()));
127:                        fragmentNode.appendChild(fname);
128:                        Element name = document.createElement("name");
129:                        name
130:                                .appendChild(document
131:                                        .createTextNode(fragmentRootId != null ? ((ALNode) fragment
132:                                                .getNode(fragmentRootId))
133:                                                .getNodeDescription().getName()
134:                                                : fragment.getFunctionalName()));
135:                        fragmentNode.appendChild(name);
136:                        Element desc = document.createElement("description");
137:                        desc.appendChild(document.createTextNode(fragment
138:                                .getDescription()));
139:                        fragmentNode.appendChild(desc);
140:                    }
141:
142:                    // If there were any fragments withno rootID and these fragments were deleted - need to update the fragment list
143:                    if (updateList)
144:                        refreshFragmentMap();
145:                }
146:
147:            }
148:
149:            protected void refreshFragmentMap() throws PortalException {
150:                Collection fragmentIds = getFragments();
151:                fragments = new HashMap();
152:                for (Iterator ids = fragmentIds.iterator(); ids.hasNext();) {
153:                    String fragmentId = (String) ids.next();
154:                    ILayoutFragment layoutFragment = alm
155:                            .getFragment(fragmentId);
156:                    if (layoutFragment == null
157:                            || !(layoutFragment instanceof  ALFragment))
158:                        throw new PortalException("The fragment must be "
159:                                + ALFragment.class.getName() + " type!");
160:                    fragments.put(fragmentId, layoutFragment);
161:                }
162:            }
163:
164:            protected abstract Collection getFragments() throws PortalException;
165:
166:            protected static final class ErrorMessage {
167:
168:                // Instance Members.
169:                private final String title;
170:                private final String description;
171:
172:                /*
173:                 * Public API.
174:                 */
175:
176:                public ErrorMessage(String title, String description) {
177:
178:                    // Assertions.
179:                    if (title == null) {
180:                        String msg = "Argument 'title' cannot be null.";
181:                        throw new IllegalArgumentException(msg);
182:                    }
183:                    if (description == null) {
184:                        String msg = "Argument 'description' cannot be null.";
185:                        throw new IllegalArgumentException(msg);
186:                    }
187:
188:                    // Instance Members.
189:                    this .title = title;
190:                    this .description = description;
191:
192:                }
193:
194:                public String getTitle() {
195:                    return title;
196:                }
197:
198:                public String getDescription() {
199:                    return description;
200:                }
201:
202:                public Element toElement(Document doc) {
203:
204:                    // Assertions.
205:                    if (doc == null) {
206:                        String msg = "Argument 'doc' cannot be null.";
207:                        throw new IllegalArgumentException(msg);
208:                    }
209:
210:                    // Title.
211:                    Element t = doc.createElement("title");
212:                    t.appendChild(doc.createTextNode(title));
213:
214:                    // Description.
215:                    Element d = doc.createElement("body");
216:                    d.appendChild(doc.createTextNode(description));
217:
218:                    Element rslt = doc.createElement("error-message");
219:                    rslt.appendChild(t);
220:                    rslt.appendChild(d);
221:
222:                    return rslt;
223:                }
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.