Source Code Cross Referenced for GetPageAction.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » layout » impl » 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 » jetspeed 2.1.3 » org.apache.jetspeed.layout.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.layout.impl;
018:
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import java.io.UnsupportedEncodingException;
025:        import java.security.MessageDigest;
026:        import java.security.NoSuchAlgorithmException;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.apache.jetspeed.JetspeedActions;
031:        import org.apache.jetspeed.PortalReservedParameters;
032:        import org.apache.jetspeed.ajax.AjaxAction;
033:        import org.apache.jetspeed.ajax.AjaxBuilder;
034:        import org.apache.jetspeed.components.portletregistry.PortletRegistry;
035:        import org.apache.jetspeed.decoration.DecorationValve;
036:        import org.apache.jetspeed.decoration.PageActionAccess;
037:        import org.apache.jetspeed.decoration.Theme;
038:        import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
039:        import org.apache.jetspeed.om.page.Fragment;
040:        import org.apache.jetspeed.om.page.Page;
041:        import org.apache.jetspeed.page.PageManager;
042:        import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
043:        import org.apache.jetspeed.profiler.impl.ProfilerValveImpl;
044:        import org.apache.jetspeed.request.RequestContext;
045:        import org.apache.pluto.om.common.Parameter;
046:        import org.apache.pluto.om.common.ParameterSet;
047:        import org.apache.pluto.om.portlet.PortletDefinition;
048:
049:        /**
050:         * Get Page retrieves a page from the Page Manager store and PSML format
051:         *
052:         * AJAX Parameters: 
053:         *    page = the path and name of the page ("/_user/ronaldino/goals.psml")
054:         *    
055:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
056:         * @version $Id: $
057:         */
058:        public class GetPageAction extends BaseGetResourceAction implements 
059:                AjaxAction, AjaxBuilder, Constants {
060:            protected Log log = LogFactory.getLog(GetPageAction.class);
061:
062:            private PortletRegistry registry;
063:            private DecorationValve decorationValve;
064:
065:            public GetPageAction(String template, String errorTemplate,
066:                    PageManager pageManager,
067:                    PortletActionSecurityBehavior securityBehavior,
068:                    PortletRegistry registry, DecorationValve decorationValve) {
069:                super (template, errorTemplate, pageManager, securityBehavior);
070:                this .registry = registry;
071:                this .decorationValve = decorationValve;
072:            }
073:
074:            public boolean run(RequestContext requestContext, Map resultMap) {
075:                boolean success = true;
076:                String status = "success";
077:                try {
078:                    resultMap.put(ACTION, "getpage");
079:                    if (false == checkAccess(requestContext,
080:                            JetspeedActions.VIEW)) {
081:                        resultMap.put(REASON,
082:                                "Insufficient access to view page");
083:                        success = false;
084:                        return success;
085:                    }
086:
087:                    // Run the Decoration valve to get actions
088:                    decorationValve.invoke(requestContext, null);
089:
090:                    Page page = requestContext.getPage();
091:                    String pageName = getActionParameter(requestContext, PAGE);
092:                    if (pageName != null) {
093:                        page = retrievePage(requestContext, pageName);
094:                    }
095:                    resultMap.put(STATUS, status);
096:                    resultMap.put(PAGE, page);
097:
098:                    Theme theme = (Theme) requestContext
099:                            .getAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE);
100:                    String pageDecoratorName = null;
101:                    if (theme != null) {
102:                        pageDecoratorName = theme.getPageLayoutDecoration()
103:                                .getName();
104:                    } else {
105:                        pageDecoratorName = page.getDefaultDecorator(LAYOUT);
106:                    }
107:                    if (pageDecoratorName != null)
108:                        resultMap.put(DEFAULT_LAYOUT, pageDecoratorName);
109:
110:                    PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext) requestContext
111:                            .getAttribute(ProfilerValveImpl.PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);
112:                    if (siteRequestContext == null) {
113:                        success = false;
114:                        resultMap
115:                                .put(REASON,
116:                                        "Missing portal site request context from ProfilerValve");
117:                        return success;
118:                    }
119:
120:                    String profiledPath = siteRequestContext.getPage()
121:                            .getPath();
122:                    resultMap.put(PROFILED_PATH, profiledPath);
123:                    putSecurityInformation(resultMap, page);
124:
125:                    PageActionAccess pageActionAccess = (PageActionAccess) requestContext
126:                            .getAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE);
127:                    Boolean userIsAnonymous = Boolean.TRUE;
128:                    if (pageActionAccess != null)
129:                        userIsAnonymous = new Boolean(pageActionAccess
130:                                .isAnonymous());
131:                    resultMap
132:                            .put(USER_IS_ANONYMOUS, userIsAnonymous.toString());
133:
134:                    Boolean isPageQualifiedForCreateNewPageOnEdit = Boolean.FALSE;
135:                    if (!userIsAnonymous.booleanValue())
136:                        isPageQualifiedForCreateNewPageOnEdit = new Boolean(
137:                                isPageQualifiedForCreateNewPageOnEdit(requestContext));
138:                    resultMap.put(PAGE_QUALIFIED_CREATE_ON_EDIT,
139:                            isPageQualifiedForCreateNewPageOnEdit.toString());
140:
141:                    String fragments = getActionParameter(requestContext,
142:                            FRAGMENTS);
143:                    if (fragments == null) {
144:                        resultMap.put(FRAGMENTS, "true");
145:                    } else {
146:                        if (fragments.equalsIgnoreCase("true")) {
147:                            resultMap.put(FRAGMENTS, "true");
148:                        } else {
149:                            resultMap.put(FRAGMENTS, "false");
150:                            return success;
151:                        }
152:                    }
153:
154:                    Map fragSizes = new HashMap();
155:                    Map portletIcons = new HashMap();
156:
157:                    String singleLayoutId = getActionParameter(requestContext,
158:                            LAYOUTID);
159:                    if (singleLayoutId != null) { // build page representation with single layout
160:                        Fragment currentLayoutFragment = page
161:                                .getFragmentById(singleLayoutId);
162:                        if (currentLayoutFragment == null) {
163:                            throw new Exception("layout id not found: "
164:                                    + singleLayoutId);
165:                        }
166:                        Fragment currentPortletFragment = null;
167:
168:                        String singlePortletId = getActionParameter(
169:                                requestContext, PORTLETENTITY);
170:                        if (singlePortletId != null) {
171:                            Iterator layoutChildIter = currentLayoutFragment
172:                                    .getFragments().iterator();
173:                            while (layoutChildIter.hasNext()) {
174:                                Fragment childFrag = (Fragment) layoutChildIter
175:                                        .next();
176:                                if (childFrag != null) {
177:                                    if (singlePortletId.equals(childFrag
178:                                            .getId())) {
179:                                        currentPortletFragment = childFrag;
180:                                        break;
181:                                    }
182:                                }
183:                            }
184:                            if (currentPortletFragment == null) {
185:                                throw new Exception("portlet id "
186:                                        + singlePortletId
187:                                        + " not found in layout "
188:                                        + singleLayoutId);
189:                            }
190:                            resultMap.put("portletsingleId",
191:                                    currentPortletFragment.getId());
192:                        }
193:
194:                        retrieveFragmentSpecialProperties(requestContext,
195:                                currentLayoutFragment, fragSizes, portletIcons);
196:                        resultMap.put("layoutsingle", currentLayoutFragment);
197:                    } else {
198:                        retrieveFragmentSpecialProperties(requestContext, page
199:                                .getRootFragment(), fragSizes, portletIcons);
200:                    }
201:                    resultMap.put(SIZES, fragSizes);
202:                    resultMap.put("portletIcons", portletIcons);
203:                } catch (Exception e) {
204:                    // Log the exception
205:                    log.error("exception while getting page", e);
206:
207:                    // Return a failure indicator
208:                    success = false;
209:                }
210:
211:                return success;
212:            }
213:
214:            protected Page retrievePage(RequestContext requestContext,
215:                    String pageName) throws Exception {
216:                if (pageName == null) {
217:                    pageName = "/";
218:                }
219:                Page page = pageManager.getPage(pageName);
220:                return page;
221:            }
222:
223:            protected void retrieveFragmentSpecialProperties(
224:                    RequestContext requestContext, Fragment frag,
225:                    Map fragSizes, Map portletIcons) {
226:                if (frag == null) {
227:                    return;
228:                }
229:
230:                if ("layout".equals(frag.getType())) { // get layout fragment sizes
231:                    if (fragSizes != null)
232:                        PortletPlacementContextImpl.getColumnCountAndSizes(
233:                                frag, registry, fragSizes);
234:
235:                    List childFragments = frag.getFragments();
236:                    if (childFragments != null) {
237:                        Iterator childFragIter = childFragments.iterator();
238:                        while (childFragIter.hasNext()) {
239:                            Fragment childFrag = (Fragment) childFragIter
240:                                    .next();
241:                            retrieveFragmentSpecialProperties(requestContext,
242:                                    childFrag, fragSizes, portletIcons);
243:                        }
244:                    }
245:                } else if (portletIcons != null
246:                        && "portlet".equals(frag.getType())) { // get portlet icon and locale specific portlet display name
247:                    String portletName = frag.getName();
248:                    if (portletName != null && portletName.length() > 0) {
249:                        PortletDefinition portletDef = registry
250:                                .getPortletDefinitionByUniqueName(portletName);
251:
252:                        if (portletDef != null && portletIcons != null) {
253:                            ParameterSet paramSet = portletDef
254:                                    .getInitParameterSet();
255:                            Parameter iconParam = paramSet.get("portlet-icon");
256:                            String iconParamVal = (iconParam == null) ? null
257:                                    : iconParam.getValue();
258:                            if (iconParamVal != null
259:                                    && iconParamVal.length() > 0) {
260:                                portletIcons.put(frag.getId(), iconParamVal);
261:                            }
262:                        } else if (portletDef == null) {
263:                            log
264:                                    .error("GetPageAction could not obtain PortletDefinition for portlet "
265:                                            + portletName);
266:                        }
267:                    }
268:                }
269:            }
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.