Source Code Cross Referenced for BaseUserAction.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.Iterator;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import org.apache.commons.logging.Log;
024:        import org.apache.commons.logging.LogFactory;
025:        import org.apache.jetspeed.ajax.AJAXException;
026:        import org.apache.jetspeed.ajax.AjaxAction;
027:        import org.apache.jetspeed.ajax.AjaxBuilder;
028:        import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
029:        import org.apache.jetspeed.om.page.Fragment;
030:        import org.apache.jetspeed.om.page.Page;
031:        import org.apache.jetspeed.page.PageManager;
032:        import org.apache.jetspeed.request.RequestContext;
033:        import org.apache.jetspeed.security.UserManager;
034:
035:        /**
036:         * Abstract portlet placement action
037:         *
038:         * @author <a>David Gurney</a>
039:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
040:         * @author <a href="mailto:mikko.wuokko@evtek.fi">Mikko Wuokko</a>
041:         * @version $Id: $
042:         */
043:        public abstract class BaseUserAction implements  AjaxAction,
044:                AjaxBuilder, Constants {
045:            protected Log log = LogFactory.getLog(BaseUserAction.class);
046:            protected String template = null;
047:            protected UserManager userManager = null;
048:            protected String errorTemplate = null;
049:            protected RolesSecurityBehavior securityBehavior;
050:
051:            public BaseUserAction(String template, String errorTemplate,
052:                    RolesSecurityBehavior securityBehavior) {
053:                this .template = template;
054:                this .errorTemplate = errorTemplate;
055:                this .securityBehavior = securityBehavior;
056:            }
057:
058:            public BaseUserAction(String template, String errorTemplate,
059:                    UserManager userManager) {
060:                this .template = template;
061:                this .errorTemplate = errorTemplate;
062:                this .userManager = userManager;
063:                this .securityBehavior = null;
064:            }
065:
066:            public BaseUserAction(String template, String errorTemplate,
067:                    UserManager userManager,
068:                    RolesSecurityBehavior securityBehavior) {
069:                this (template, errorTemplate, securityBehavior);
070:                this .userManager = userManager;
071:            }
072:
073:            public boolean buildContext(RequestContext requestContext,
074:                    Map responseContext) {
075:                return true;
076:            }
077:
078:            public boolean buildErrorContext(RequestContext requestContext,
079:                    Map responseContext) {
080:                responseContext.put(STATUS, "failure");
081:
082:                // Check for the case where we don't know basic information
083:                if (responseContext.get(ACTION) == null) {
084:                    responseContext.put(ACTION, "unknown");
085:                }
086:
087:                if (responseContext.get(PORTLETID) == null) {
088:                    responseContext.put(PORTLETID, "unknown");
089:                }
090:
091:                return true;
092:            }
093:
094:            public String getErrorTemplate() {
095:                return errorTemplate;
096:            }
097:
098:            public String getTemplate() {
099:                return template;
100:            }
101:
102:            public boolean checkAccess(RequestContext context, String action) {
103:                boolean access = true;
104:                if (null != securityBehavior) {
105:                    access = securityBehavior.checkAccess(context, action);
106:                }
107:                return access;
108:            }
109:
110:            public boolean createNewPageOnEdit(RequestContext context) {
111:                if (securityBehavior == null)
112:                    return false;
113:
114:                return securityBehavior.createNewPageOnEdit(context);
115:            }
116:
117:            // TODO: support nested fragments
118:            public Fragment getFragmentIdFromLocation(int row, int column,
119:                    Page page) {
120:                Fragment root = page.getRootFragment();
121:                Iterator fragments = root.getFragments().iterator();
122:                while (fragments.hasNext()) {
123:                    Fragment fragment = (Fragment) fragments.next();
124:                    if (fragment.getLayoutColumn() == column
125:                            && fragment.getLayoutRow() == row) {
126:                        return fragment;
127:                    }
128:                }
129:                return null;
130:            }
131:
132:            public boolean runBatch(RequestContext requestContext, Map resultMap)
133:                    throws AJAXException {
134:                return run(requestContext, resultMap);
135:            }
136:
137:            public String getActionParameter(RequestContext requestContext,
138:                    String name) {
139:                String parameter = requestContext.getRequestParameter(name);
140:                if (parameter == null) {
141:                    Object o = requestContext.getAttribute(name);
142:                    if (o != null) {
143:                        if (o instanceof  String)
144:                            return (String) o;
145:                    }
146:                }
147:                return parameter;
148:            }
149:
150:            public Fragment getParentFragmentById(String id, Fragment root) {
151:                if (id == null) {
152:                    return null;
153:                }
154:                return searchForParentFragmentById(id, root);
155:            }
156:
157:            protected Fragment searchForParentFragmentById(String id,
158:                    Fragment parent) {
159:                // find fragment by id, tracking fragment parent
160:                Fragment matchedParent = null;
161:                if (parent != null) {
162:                    // process the children
163:                    List children = parent.getFragments();
164:                    for (int i = 0, cSize = children.size(); i < cSize; i++) {
165:                        Fragment childFrag = (Fragment) children.get(i);
166:                        if (childFrag != null) {
167:                            if (id.equals(childFrag.getId())) {
168:                                matchedParent = parent;
169:                                break;
170:                            } else {
171:                                matchedParent = searchForParentFragmentById(id,
172:                                        childFrag);
173:                                if (matchedParent != null) {
174:                                    break;
175:                                }
176:                            }
177:                        }
178:                    }
179:                }
180:                return matchedParent;
181:            }
182:
183:            /**
184:             * Helper method to determine if a parameter is true. Prevents
185:             * accidental NullPointerExceptions when comparing or or using
186:             * the parameter value.
187:             * @param parameter The value to be determined as boolean true or false.
188:             * @return boolean true or false according to the @param value.
189:             */
190:            public boolean isTrue(String parameter) {
191:                boolean isTrue = false;
192:                if (parameter != null) {
193:                    if (parameter.equalsIgnoreCase("true")) {
194:                        isTrue = true;
195:                    }
196:                }
197:                return isTrue;
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.