Source Code Cross Referenced for GetMenusAction.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.Locale;
020:        import java.util.Map;
021:        import java.util.HashMap;
022:        import java.util.Set;
023:        import java.util.Iterator;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.apache.jetspeed.JetspeedActions;
028:        import org.apache.jetspeed.ajax.AjaxAction;
029:        import org.apache.jetspeed.ajax.AjaxBuilder;
030:        import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
031:        import org.apache.jetspeed.page.document.NodeNotFoundException;
032:        import org.apache.jetspeed.portalsite.Menu;
033:        import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
034:        import org.apache.jetspeed.profiler.impl.ProfilerValveImpl;
035:        import org.apache.jetspeed.request.RequestContext;
036:
037:        /**
038:         * Get menus action retrieves all menu names defined for the addressed page.
039:         *
040:         * AJAX Parameters: 
041:         *    none
042:         *    
043:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
044:         * @version $Id: $
045:         */
046:        public class GetMenusAction extends BasePortletAction implements 
047:                AjaxAction, AjaxBuilder, Constants {
048:            protected static final Log log = LogFactory
049:                    .getLog(GetMenusAction.class);
050:
051:            public GetMenusAction(String template, String errorTemplate,
052:                    PortletActionSecurityBehavior securityBehavior) {
053:                super (template, errorTemplate, securityBehavior);
054:            }
055:
056:            public boolean run(RequestContext requestContext, Map resultMap) {
057:                boolean success = true;
058:                String status = "success";
059:                try {
060:                    // generate action result
061:                    resultMap.put(ACTION, "getmenus");
062:
063:                    // check permission to use ajax api
064:                    if (!checkAccess(requestContext, JetspeedActions.VIEW)) {
065:                        success = false;
066:                        resultMap.put(REASON,
067:                                "Insufficient access to get menus");
068:                        return success;
069:                    }
070:
071:                    // get request context
072:                    PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext) requestContext
073:                            .getAttribute(ProfilerValveImpl.PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);
074:                    if (siteRequestContext == null) {
075:                        success = false;
076:                        resultMap
077:                                .put(REASON,
078:                                        "Missing portal site request context from ProfilerValve");
079:                        return success;
080:                    }
081:
082:                    // get menu names
083:                    Set standardMenuNames = siteRequestContext
084:                            .getStandardMenuNames();
085:                    Set customMenuNames = null;
086:                    try {
087:                        customMenuNames = siteRequestContext
088:                                .getCustomMenuNames();
089:                    } catch (NodeNotFoundException nnfe) {
090:                    }
091:
092:                    // return menu names action results
093:                    resultMap.put(STANDARD_MENUS, standardMenuNames);
094:                    resultMap.put(CUSTOM_MENUS, customMenuNames);
095:
096:                    // get action parameter
097:                    String includeMenuDefinitions = getActionParameter(
098:                            requestContext, INCLUDE_MENU_DEFS);
099:                    if (includeMenuDefinitions != null
100:                            && includeMenuDefinitions.toLowerCase().equals(
101:                                    "true")) {
102:                        // get request locale
103:                        Locale locale = requestContext.getLocale();
104:
105:                        HashMap menuDefinitionsMap = new HashMap();
106:
107:                        StringBuffer failReason = new StringBuffer();
108:                        Iterator menuNamesIter = standardMenuNames.iterator();
109:                        while (menuNamesIter.hasNext()) {
110:                            String menuName = (String) menuNamesIter.next();
111:                            Menu menuDefinition = getMenuDefinition(menuName,
112:                                    siteRequestContext, failReason);
113:                            if (menuDefinition != null)
114:                                menuDefinitionsMap
115:                                        .put(menuName, menuDefinition);
116:                        }
117:                        menuNamesIter = customMenuNames.iterator();
118:                        while (menuNamesIter.hasNext()) {
119:                            String menuName = (String) menuNamesIter.next();
120:                            Menu menuDefinition = getMenuDefinition(menuName,
121:                                    siteRequestContext, failReason);
122:                            if (menuDefinition != null)
123:                                menuDefinitionsMap
124:                                        .put(menuName, menuDefinition);
125:                        }
126:
127:                        if (failReason.length() > 0) {
128:                            success = false;
129:                            resultMap.put(REASON, failReason.toString());
130:                            return success;
131:                        }
132:                        resultMap.put(INCLUDE_MENU_DEFS, new Boolean(true));
133:                        resultMap.put(MENU_DEFINITIONS, menuDefinitionsMap);
134:                        resultMap.put(MENU_CONTEXT, siteRequestContext);
135:                        resultMap.put(MENU_LOCALE, locale);
136:                    } else {
137:                        resultMap.put(INCLUDE_MENU_DEFS, new Boolean(false));
138:                    }
139:                    resultMap.put(STATUS, status);
140:                } catch (Exception e) {
141:                    log.error("Exception while getting page menus info", e);
142:                    success = false;
143:                }
144:
145:                return success;
146:            }
147:
148:            private Menu getMenuDefinition(String menuName,
149:                    PortalSiteRequestContext siteRequestContext,
150:                    StringBuffer failReason) {
151:                // get menu definition
152:                Menu menuDefinition = null;
153:                try {
154:                    menuDefinition = siteRequestContext.getMenu(menuName);
155:                } catch (NodeNotFoundException nnfe) {
156:                }
157:                if (menuDefinition == null && failReason != null) {
158:                    if (failReason.length() == 0)
159:                        failReason.append("Unable to lookup specified menus: ")
160:                                .append(menuName);
161:                    else
162:                        failReason.append(", ").append(menuName);
163:                }
164:                return menuDefinition;
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.