1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.container; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
import java.util.Map; |
21 |
|
|
22 |
|
import javax.portlet.PortletMode; |
23 |
|
import javax.portlet.WindowState; |
24 |
|
import javax.servlet.http.HttpServletRequest; |
25 |
|
import javax.servlet.http.HttpServletResponse; |
26 |
|
|
27 |
|
import org.apache.pluto.PortletContainer; |
28 |
|
import org.apache.pluto.PortletContainerImpl; |
29 |
|
import org.apache.pluto.core.InternalActionResponse; |
30 |
|
import org.apache.pluto.om.window.PortletWindow; |
31 |
|
import org.apache.pluto.services.information.DynamicInformationProvider; |
32 |
|
import org.apache.pluto.services.information.InformationProviderAccess; |
33 |
|
import org.apache.pluto.services.information.PortletURLProvider; |
34 |
|
|
35 |
|
import org.apache.jetspeed.desktop.JetspeedDesktop; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
public class DesktopPortletContainerImpl extends PortletContainerImpl implements PortletContainer |
47 |
|
{ |
48 |
0 |
private String desktopPipelinePath = null; |
49 |
0 |
private String desktopActionPipelinePath = null; |
50 |
0 |
private String desktopRenderPipelinePath = null; |
51 |
|
|
52 |
|
public DesktopPortletContainerImpl( String desktopPipelinePath, String desktopActionPipelinePath, String desktopRenderPipelinePath ) |
53 |
0 |
{ |
54 |
0 |
if ( desktopPipelinePath == null || desktopPipelinePath.length() == 0 ) |
55 |
0 |
desktopPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_PIPELINE_PATH; |
56 |
0 |
if ( desktopPipelinePath.charAt( 0 ) != '/' ) |
57 |
0 |
desktopPipelinePath = "/" + desktopPipelinePath; |
58 |
0 |
if ( desktopPipelinePath.charAt( desktopPipelinePath.length() -1 ) != '/' ) |
59 |
0 |
desktopPipelinePath = desktopPipelinePath + "/"; |
60 |
|
|
61 |
0 |
if ( desktopActionPipelinePath == null || desktopActionPipelinePath.length() == 0 ) |
62 |
0 |
desktopActionPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_ACTION_PIPELINE_PATH; |
63 |
0 |
if ( desktopActionPipelinePath.charAt( 0 ) != '/' ) |
64 |
0 |
desktopActionPipelinePath = "/" + desktopActionPipelinePath; |
65 |
0 |
if ( desktopActionPipelinePath.charAt( desktopActionPipelinePath.length() -1 ) != '/' ) |
66 |
0 |
desktopActionPipelinePath = desktopActionPipelinePath + "/"; |
67 |
|
|
68 |
0 |
if ( desktopRenderPipelinePath == null || desktopRenderPipelinePath.length() == 0 ) |
69 |
0 |
desktopRenderPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_RENDER_PIPELINE_PATH; |
70 |
0 |
if ( desktopRenderPipelinePath.charAt( 0 ) != '/' ) |
71 |
0 |
desktopRenderPipelinePath = "/" + desktopRenderPipelinePath; |
72 |
0 |
if ( desktopRenderPipelinePath.charAt( desktopRenderPipelinePath.length() -1 ) != '/' ) |
73 |
0 |
desktopRenderPipelinePath = desktopRenderPipelinePath + "/"; |
74 |
|
|
75 |
0 |
this.desktopPipelinePath = desktopPipelinePath; |
76 |
0 |
this.desktopActionPipelinePath = desktopActionPipelinePath; |
77 |
0 |
this.desktopRenderPipelinePath = desktopRenderPipelinePath; |
78 |
0 |
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
protected void redirect(String location, PortletWindow portletWindow, |
84 |
|
HttpServletRequest servletRequest, |
85 |
|
HttpServletResponse servletResponse, |
86 |
|
InternalActionResponse _actionResponse) throws IOException |
87 |
|
{ |
88 |
0 |
if (location == null && _actionResponse != class="keyword">null) |
89 |
|
{ |
90 |
0 |
DynamicInformationProvider provider = InformationProviderAccess |
91 |
|
.getDynamicProvider(servletRequest); |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
0 |
PortletMode portletMode = provider.getPortletMode(portletWindow); |
96 |
0 |
WindowState windowState = provider.getWindowState(portletWindow); |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
0 |
if (_actionResponse.getChangedPortletMode() != null) |
102 |
|
{ |
103 |
0 |
portletMode = _actionResponse.getChangedPortletMode(); |
104 |
0 |
InformationProviderAccess.getDynamicProvider(servletRequest) |
105 |
|
.getPortletActionProvider(portletWindow) |
106 |
|
.changePortletMode(portletMode); |
107 |
|
} |
108 |
|
|
109 |
0 |
if (_actionResponse.getChangedWindowState() != null) |
110 |
|
{ |
111 |
0 |
windowState = _actionResponse.getChangedWindowState(); |
112 |
0 |
InformationProviderAccess.getDynamicProvider(servletRequest) |
113 |
|
.getPortletActionProvider(portletWindow) |
114 |
|
.changePortletWindowState(windowState); |
115 |
|
} |
116 |
|
|
117 |
0 |
Map renderParameter = _actionResponse.getRenderParameters(); |
118 |
|
|
119 |
0 |
PortletURLProvider redirectURL = provider |
120 |
|
.getPortletURLProvider(portletWindow); |
121 |
|
|
122 |
0 |
if (provider.getPortletMode(portletWindow) != null) |
123 |
|
{ |
124 |
0 |
redirectURL.setPortletMode(portletMode); |
125 |
|
} |
126 |
0 |
if (provider.getWindowState(portletWindow) != null) |
127 |
|
{ |
128 |
0 |
redirectURL.setWindowState(windowState); |
129 |
|
} |
130 |
0 |
if (servletRequest.isSecure()) |
131 |
|
{ |
132 |
0 |
redirectURL.setSecure(); |
133 |
|
} |
134 |
0 |
redirectURL.clearParameters(); |
135 |
0 |
redirectURL.setParameters(renderParameter); |
136 |
|
|
137 |
0 |
location = servletResponse |
138 |
|
.encodeRedirectURL(redirectURL.toString()); |
139 |
|
} |
140 |
|
|
141 |
0 |
javax.servlet.http.HttpServletResponse redirectResponse = servletResponse; |
142 |
0 |
while (redirectResponse instanceof javax.servlet.http.HttpServletResponseWrapper) |
143 |
|
{ |
144 |
0 |
redirectResponse = (javax.servlet.http.HttpServletResponse) ((javax.servlet.http.HttpServletResponseWrapper) redirectResponse) |
145 |
|
.getResponse(); |
146 |
|
} |
147 |
|
|
148 |
0 |
String encoding = servletRequest.getParameter( JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER ); |
149 |
0 |
if ( encoding != null && encoding.equals( JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE ) ) |
150 |
|
{ |
151 |
0 |
location = location.replaceAll( this.desktopActionPipelinePath, class="keyword">this.desktopRenderPipelinePath ); |
152 |
0 |
redirectResponse.getWriter().print( location ); |
153 |
|
} |
154 |
|
else |
155 |
|
{ |
156 |
0 |
location = location.replaceAll( this.desktopActionPipelinePath, class="keyword">this.desktopPipelinePath ); |
157 |
0 |
location = location.replaceAll( this.desktopRenderPipelinePath, class="keyword">this.desktopPipelinePath); |
158 |
0 |
redirectResponse.sendRedirect(location); |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
0 |
} |
163 |
|
|
164 |
|
} |