Source Code Cross Referenced for DesktopPortletContainerImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » container » 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.container 
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.container;
018:
019:        import java.io.IOException;
020:        import java.util.Map;
021:
022:        import javax.portlet.PortletMode;
023:        import javax.portlet.WindowState;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import org.apache.pluto.PortletContainer;
028:        import org.apache.pluto.PortletContainerImpl;
029:        import org.apache.pluto.core.InternalActionResponse;
030:        import org.apache.pluto.om.window.PortletWindow;
031:        import org.apache.pluto.services.information.DynamicInformationProvider;
032:        import org.apache.pluto.services.information.InformationProviderAccess;
033:        import org.apache.pluto.services.information.PortletURLProvider;
034:
035:        import org.apache.jetspeed.desktop.JetspeedDesktop;
036:
037:        /**
038:         * Desktop Portlet Container implementation. This implementation 
039:         * redirects only if the query paramater encoder=desktop is NOT specified.
040:         * When the encoder=desktop parameter is specified, the 'redirect' URL 
041:         * is returned in the response body for use by desktop javascript code.
042:         * 
043:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
044:         * @version $Id: $
045:         */
046:        public class DesktopPortletContainerImpl extends PortletContainerImpl
047:                implements  PortletContainer {
048:            private String desktopPipelinePath = null;
049:            private String desktopActionPipelinePath = null;
050:            private String desktopRenderPipelinePath = null;
051:
052:            public DesktopPortletContainerImpl(String desktopPipelinePath,
053:                    String desktopActionPipelinePath,
054:                    String desktopRenderPipelinePath) {
055:                if (desktopPipelinePath == null
056:                        || desktopPipelinePath.length() == 0)
057:                    desktopPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_PIPELINE_PATH;
058:                if (desktopPipelinePath.charAt(0) != '/')
059:                    desktopPipelinePath = "/" + desktopPipelinePath;
060:                if (desktopPipelinePath
061:                        .charAt(desktopPipelinePath.length() - 1) != '/')
062:                    desktopPipelinePath = desktopPipelinePath + "/";
063:
064:                if (desktopActionPipelinePath == null
065:                        || desktopActionPipelinePath.length() == 0)
066:                    desktopActionPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_ACTION_PIPELINE_PATH;
067:                if (desktopActionPipelinePath.charAt(0) != '/')
068:                    desktopActionPipelinePath = "/" + desktopActionPipelinePath;
069:                if (desktopActionPipelinePath.charAt(desktopActionPipelinePath
070:                        .length() - 1) != '/')
071:                    desktopActionPipelinePath = desktopActionPipelinePath + "/";
072:
073:                if (desktopRenderPipelinePath == null
074:                        || desktopRenderPipelinePath.length() == 0)
075:                    desktopRenderPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_RENDER_PIPELINE_PATH;
076:                if (desktopRenderPipelinePath.charAt(0) != '/')
077:                    desktopRenderPipelinePath = "/" + desktopRenderPipelinePath;
078:                if (desktopRenderPipelinePath.charAt(desktopRenderPipelinePath
079:                        .length() - 1) != '/')
080:                    desktopRenderPipelinePath = desktopRenderPipelinePath + "/";
081:
082:                this .desktopPipelinePath = desktopPipelinePath;
083:                this .desktopActionPipelinePath = desktopActionPipelinePath;
084:                this .desktopRenderPipelinePath = desktopRenderPipelinePath;
085:            }
086:
087:            /**
088:             * This redirect does not redirect, instead returns the redirect URL in the response
089:             */
090:            protected void redirect(String location,
091:                    PortletWindow portletWindow,
092:                    HttpServletRequest servletRequest,
093:                    HttpServletResponse servletResponse,
094:                    InternalActionResponse _actionResponse) throws IOException {
095:                String encoding = servletRequest
096:                        .getParameter(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER);
097:                boolean requestHasDesktopEncoding = false;
098:                boolean requestIsDesktopAjax = false;
099:                if (encoding != null
100:                        && encoding
101:                                .equals(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE)) { // used in cases where action request cannot be made via ajax (e.g. form has <input type=file/> element)
102:                    requestHasDesktopEncoding = true;
103:                    requestIsDesktopAjax = true;
104:                    String ajaxOverride = servletRequest
105:                            .getParameter(JetspeedDesktop.DESKTOP_AJAX_REQUEST_PARAMETER);
106:                    if (ajaxOverride != null && ajaxOverride.equals("false")) {
107:                        requestIsDesktopAjax = false;
108:                    }
109:                }
110:
111:                if (location == null && _actionResponse != null) {
112:                    DynamicInformationProvider provider = InformationProviderAccess
113:                            .getDynamicProvider(servletRequest);
114:
115:                    // TODO: don't send changes in case of exception -> PORTLET:SPEC:17
116:
117:                    PortletMode portletMode = provider
118:                            .getPortletMode(portletWindow);
119:                    WindowState windowState = provider
120:                            .getWindowState(portletWindow);
121:
122:                    // get the changings of this portlet entity that might be set during
123:                    // action handling
124:                    // change portlet mode
125:                    if (_actionResponse.getChangedPortletMode() != null) {
126:                        portletMode = _actionResponse.getChangedPortletMode();
127:                        InformationProviderAccess.getDynamicProvider(
128:                                servletRequest).getPortletActionProvider(
129:                                portletWindow).changePortletMode(portletMode);
130:                    }
131:                    // change window state
132:                    if (_actionResponse.getChangedWindowState() != null) {
133:                        windowState = _actionResponse.getChangedWindowState();
134:                        InformationProviderAccess.getDynamicProvider(
135:                                servletRequest).getPortletActionProvider(
136:                                portletWindow).changePortletWindowState(
137:                                windowState);
138:                    }
139:                    // get render parameters
140:                    Map renderParameter = _actionResponse.getRenderParameters();
141:
142:                    PortletURLProvider redirectURL = provider
143:                            .getPortletURLProvider(portletWindow);
144:
145:                    if (provider.getPortletMode(portletWindow) != null) {
146:                        redirectURL.setPortletMode(portletMode);
147:                    }
148:                    if (provider.getWindowState(portletWindow) != null) {
149:                        redirectURL.setWindowState(windowState);
150:                    }
151:                    if (servletRequest.isSecure()) {
152:                        redirectURL.setSecure(); // TBD
153:                    }
154:
155:                    if (requestHasDesktopEncoding && !requestIsDesktopAjax) { // add parameter to tell DesktopEncodingPortalURL that it should not add extra desktop parameters (e.g. entity and portlet)
156:                        renderParameter
157:                                .put(
158:                                        JetspeedDesktop.DESKTOP_REQUEST_NOT_AJAX_PARAMETER,
159:                                        Boolean.TRUE);
160:                    }
161:
162:                    redirectURL.clearParameters();
163:                    redirectURL.setParameters(renderParameter);
164:
165:                    location = servletResponse.encodeRedirectURL(redirectURL
166:                            .toString());
167:                }
168:
169:                javax.servlet.http.HttpServletResponse redirectResponse = servletResponse;
170:                while (redirectResponse instanceof  javax.servlet.http.HttpServletResponseWrapper) {
171:                    redirectResponse = (javax.servlet.http.HttpServletResponse) ((javax.servlet.http.HttpServletResponseWrapper) redirectResponse)
172:                            .getResponse();
173:                }
174:
175:                if (requestIsDesktopAjax) { // no real redirect will occur; instead, return the redirect URL in the response body
176:                    location = location.replaceAll(
177:                            this .desktopActionPipelinePath,
178:                            this .desktopRenderPipelinePath);
179:                    redirectResponse.getWriter().print(location);
180:                } else { // do real redirect
181:                    location = location.replaceAll(
182:                            this .desktopActionPipelinePath,
183:                            this .desktopPipelinePath);
184:                    location = location.replaceAll(
185:                            this .desktopRenderPipelinePath,
186:                            this .desktopPipelinePath);
187:                    redirectResponse.sendRedirect(location);
188:                }
189:                // System.out.println("+++ >>>> location is " + location);
190:
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.