Source Code Cross Referenced for RenderPageCommand.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » model » portal » command » render » 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 » jboss portal 2.6.4 » org.jboss.portal.core.model.portal.command.render 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.model.portal.command.render;
023:
024:        import org.jboss.portal.common.invocation.InvocationException;
025:        import org.jboss.portal.core.controller.ControllerContext;
026:        import org.jboss.portal.core.controller.ControllerException;
027:        import org.jboss.portal.core.controller.ControllerResponse;
028:        import org.jboss.portal.core.controller.NoSuchResourceException;
029:        import org.jboss.portal.core.controller.SecurityException;
030:        import org.jboss.portal.core.controller.command.info.CommandInfo;
031:        import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
032:        import org.jboss.portal.core.model.portal.Page;
033:        import org.jboss.portal.core.model.portal.PortalObject;
034:        import org.jboss.portal.core.model.portal.PortalObjectId;
035:        import org.jboss.portal.core.model.portal.PortalObjectPermission;
036:        import org.jboss.portal.core.model.portal.Window;
037:        import org.jboss.portal.core.model.portal.command.PageCommand;
038:        import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
039:        import org.jboss.portal.core.model.portal.content.WindowRendition;
040:        import org.jboss.portal.core.theme.PageRendition;
041:        import org.jboss.portal.core.theme.WindowContextFactory;
042:        import org.jboss.portal.identity.User;
043:        import org.jboss.portal.identity.UserProfileModule;
044:        import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
045:        import org.jboss.portal.theme.LayoutService;
046:        import org.jboss.portal.theme.PageService;
047:        import org.jboss.portal.theme.PortalLayout;
048:        import org.jboss.portal.theme.PortalTheme;
049:        import org.jboss.portal.theme.ThemeConstants;
050:        import org.jboss.portal.theme.ThemeService;
051:        import org.jboss.portal.theme.page.PageResult;
052:
053:        import javax.naming.InitialContext;
054:        import javax.naming.NamingException;
055:        import java.util.ArrayList;
056:        import java.util.Collection;
057:        import java.util.HashMap;
058:        import java.util.Iterator;
059:
060:        /**
061:         * Render a full page.
062:         *
063:         * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
064:         * @version $Revision: 8786 $
065:         */
066:        public final class RenderPageCommand extends PageCommand {
067:
068:            /** . */
069:            private static final CommandInfo info = new ViewCommandInfo();
070:
071:            /** The windows to render. */
072:            private Collection windows;
073:
074:            /** . */
075:            private boolean personalizable;
076:
077:            public RenderPageCommand(PortalObjectId pageId) {
078:                super (pageId);
079:            }
080:
081:            /**
082:             * Get the command info (runtime info about the command)
083:             *
084:             * @return info about the command
085:             */
086:            public CommandInfo getInfo() {
087:                return info;
088:            }
089:
090:            /**
091:             * Returns the modifiable list of windows.
092:             *
093:             * @return the windows on the page
094:             */
095:            public Collection getWindows() {
096:                return windows;
097:            }
098:
099:            public void acquireResources() throws NoSuchResourceException {
100:                super .acquireResources();
101:
102:                // All windows on the page
103:                windows = new ArrayList(getPage().getChildren(
104:                        PortalObject.WINDOW_MASK));
105:            }
106:
107:            protected Page initPage() {
108:                return (Page) getTarget();
109:            }
110:
111:            public void enforceSecurity(PortalAuthorizationManager pam)
112:                    throws SecurityException {
113:                //
114:                super .enforceSecurity(pam);
115:
116:                // Check if the user can personalize the page
117:                PortalObjectPermission perm = new PortalObjectPermission(page
118:                        .getId(), PortalObjectPermission.PERSONALIZE_MASK);
119:                personalizable = pam.checkPermission(perm);
120:            }
121:
122:            /**
123:             * execute the command
124:             *
125:             * @throws InvocationException
126:             */
127:            public ControllerResponse execute() throws ControllerException,
128:                    InvocationException {
129:                try {
130:                    //
131:                    PageService pageService = context.getController()
132:                            .getPageService();
133:                    ThemeService themeService = pageService.getThemeService();
134:                    LayoutService layoutService = pageService
135:                            .getLayoutService();
136:                    //
137:
138:                    PortalLayout layout = getLayout(layoutService, page);
139:
140:                    // The theme for the page
141:                    PortalTheme theme = null;
142:
143:                    // Determine theme
144:                    if (personalizable) {
145:                        ControllerContext controllerCtx = (ControllerContext) getContext();
146:                        User user = controllerCtx.getUser();
147:                        if (user != null) {
148:                            UserProfileModule userProfileModule = null;
149:
150:                            //MARK: identity code change
151:                            try {
152:                                userProfileModule = (UserProfileModule) new InitialContext()
153:                                        .lookup("java:portal/UserProfileModule");
154:                            } catch (NamingException ignore) {
155:                                // Name is not bound anymore, it could happen during a shutdown, we don't do anything
156:                            }
157:
158:                            //
159:                            String themeId = (String) userProfileModule
160:                                    .getProperty(user, User.INFO_USER_THEME);
161:
162:                            if (themeId != null) {
163:                                theme = themeService.getThemeById(themeId);
164:                            }
165:                        }
166:                    }
167:                    if (theme == null) {
168:                        // If nothing get it from the object properties
169:                        String themeId = page
170:                                .getProperty(ThemeConstants.PORTAL_PROP_THEME);
171:                        theme = themeService.getThemeById(themeId);
172:                    }
173:
174:                    // Call the portlet container to create the markup fragment(s) for each portlet that needs to render itself
175:                    PageResult pageResult = new PageResult(getPage().getName(),
176:                            new HashMap(getPage().getProperties()));
177:
178:                    // The window context factory
179:                    WindowContextFactory wcFactory = new WindowContextFactory(
180:                            context);
181:
182:                    // Render the windows
183:                    for (Iterator i = windows.iterator(); i.hasNext();) {
184:                        PortalObject o = (PortalObject) i.next();
185:                        if (o instanceof  Window) {
186:                            Window window = (Window) o;
187:                            RenderWindowCommand renderCmd = new RenderWindowCommand(
188:                                    window.getId());
189:
190:                            //
191:                            WindowRendition rendition = null;
192:
193:                            //
194:                            if (renderCmd != null) {
195:                                rendition = renderCmd.render(context);
196:                            }
197:
198:                            // We ignore null result objects
199:                            if (rendition != null) {
200:                                // Get the controller response 
201:                                ControllerResponse response = rendition
202:                                        .getControllerResponse();
203:
204:                                // Null means we skip the window
205:                                if (response != null) {
206:                                    if (response instanceof  MarkupResponse) {
207:                                        // If this is a markup response we aggregate it
208:                                        pageResult.addWindowContext(wcFactory
209:                                                .createWindowContext(window,
210:                                                        rendition));
211:                                    } else if (response != null) {
212:                                        // Otherwise we return it
213:                                        return response;
214:                                    }
215:                                }
216:                            }
217:                        }
218:                    }
219:
220:                    //
221:                    return new PageRendition(layout, theme, pageResult,
222:                            pageService);
223:                } catch (Exception e) {
224:                    rethrow(e);
225:                }
226:
227:                //
228:                return null;
229:            }
230:
231:            /**
232:             * Get the portal layout to use for the provided page. <p>The name of the layout to use can be defined as a property
233:             * in the portal, or the individual page. The page property overwrites the portal property. If no property was set, a
234:             * default layout with the name "nodesk" is assumed.</p>
235:             *
236:             * @param layoutService the layout service that allows access to the layout
237:             * @param page          the page that hosts the markup container to render (the page, region, window,...)
238:             * @return a <code>PortalLayout</code> for the defined layout name
239:             */
240:            public static PortalLayout getLayout(LayoutService layoutService,
241:                    Page page) {
242:                String layoutIdString = page
243:                        .getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
244:                return layoutService.getLayoutById(layoutIdString);
245:            }
246:        }
w__w__w__.__jav___a_2__s___.c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.