1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.container.url.impl; |
18 |
|
|
19 |
|
import java.io.UnsupportedEncodingException; |
20 |
|
import java.util.Map; |
21 |
|
import java.util.StringTokenizer; |
22 |
|
|
23 |
|
import javax.portlet.PortletMode; |
24 |
|
import javax.portlet.WindowState; |
25 |
|
import javax.servlet.http.HttpServletRequest; |
26 |
|
|
27 |
|
import org.apache.jetspeed.PortalContext; |
28 |
|
import org.apache.jetspeed.container.state.NavigationalState; |
29 |
|
import org.apache.jetspeed.container.url.BasePortalURL; |
30 |
|
import org.apache.jetspeed.desktop.JetspeedDesktop; |
31 |
|
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; |
32 |
|
import org.apache.pluto.om.window.PortletWindow; |
33 |
|
import org.apache.pluto.om.entity.PortletEntity; |
34 |
|
import org.apache.pluto.om.portlet.PortletDefinition; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
public class DesktopEncodingPortalURL extends AbstractPortalURL |
47 |
|
{ |
48 |
0 |
private String baseActionPath = null; |
49 |
0 |
private String baseRenderPath = null; |
50 |
|
|
51 |
0 |
private String desktopActionPipelinePath = null; |
52 |
0 |
private String desktopRenderPipelinePath = null; |
53 |
|
|
54 |
|
|
55 |
|
public DesktopEncodingPortalURL(NavigationalState navState, PortalContext portalContext, String desktopRenderPipelinePath, String desktopActionPipelinePath) |
56 |
|
{ |
57 |
0 |
super(navState, portalContext); |
58 |
0 |
initializePipelinePaths( desktopRenderPipelinePath, desktopActionPipelinePath ); |
59 |
0 |
} |
60 |
|
|
61 |
|
public DesktopEncodingPortalURL(NavigationalState navState, PortalContext portalContext, String desktopRenderPipelinePath, String desktopActionPipelinePath, BasePortalURL base) |
62 |
|
{ |
63 |
0 |
super(navState, portalContext, base); |
64 |
0 |
initializePipelinePaths( desktopRenderPipelinePath, desktopActionPipelinePath ); |
65 |
0 |
} |
66 |
|
|
67 |
|
public DesktopEncodingPortalURL(String characterEncoding, NavigationalState navState, PortalContext portalContext) |
68 |
|
{ |
69 |
0 |
super(characterEncoding, navState, portalContext); |
70 |
0 |
initializePipelinePaths( null, class="keyword">null ); |
71 |
0 |
} |
72 |
|
|
73 |
|
public DesktopEncodingPortalURL(HttpServletRequest request, String characterEncoding, NavigationalState navState, PortalContext portalContext) |
74 |
|
{ |
75 |
0 |
super(request, characterEncoding, navState, portalContext); |
76 |
0 |
initializePipelinePaths( null, class="keyword">null ); |
77 |
0 |
} |
78 |
|
|
79 |
|
private void initializePipelinePaths( String desktopRenderPipelinePath, String desktopActionPipelinePath ) |
80 |
|
{ |
81 |
0 |
if ( desktopActionPipelinePath == null || desktopActionPipelinePath.length() == 0 ) |
82 |
0 |
desktopActionPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_ACTION_PIPELINE_PATH; |
83 |
0 |
if ( desktopActionPipelinePath.charAt( 0 ) != '/' ) |
84 |
0 |
desktopActionPipelinePath = "/" + desktopActionPipelinePath; |
85 |
0 |
if ( desktopActionPipelinePath.length() > 1 && desktopActionPipelinePath.charAt( desktopActionPipelinePath.length() -1 ) == '/' ) |
86 |
0 |
desktopActionPipelinePath = desktopActionPipelinePath.substring( 0, desktopActionPipelinePath.length() -1 ); |
87 |
|
|
88 |
0 |
if ( desktopRenderPipelinePath == null || desktopRenderPipelinePath.length() == 0 ) |
89 |
0 |
desktopRenderPipelinePath = JetspeedDesktop.DEFAULT_DESKTOP_RENDER_PIPELINE_PATH; |
90 |
0 |
if ( desktopRenderPipelinePath.charAt( 0 ) != '/' ) |
91 |
0 |
desktopRenderPipelinePath = "/" + desktopRenderPipelinePath; |
92 |
0 |
if ( desktopRenderPipelinePath.length() > 1 && desktopRenderPipelinePath.charAt( desktopRenderPipelinePath.length() -1 ) == '/' ) |
93 |
0 |
desktopRenderPipelinePath = desktopRenderPipelinePath.substring( 0, desktopRenderPipelinePath.length() -1 ); |
94 |
|
|
95 |
0 |
this.desktopRenderPipelinePath = desktopRenderPipelinePath; |
96 |
0 |
this.desktopActionPipelinePath = desktopActionPipelinePath; |
97 |
0 |
} |
98 |
|
|
99 |
|
protected void decodeBasePath(HttpServletRequest request) |
100 |
|
{ |
101 |
0 |
super.decodeBasePath(request); |
102 |
0 |
if ( this.baseActionPath == null ) |
103 |
|
{ |
104 |
0 |
this.baseActionPath = contextPath + class="keyword">this.desktopActionPipelinePath; |
105 |
0 |
this.baseRenderPath = contextPath + class="keyword">this.desktopRenderPipelinePath; |
106 |
|
} |
107 |
0 |
} |
108 |
|
|
109 |
|
protected void decodePathAndNavigationalState(HttpServletRequest request) |
110 |
|
{ |
111 |
0 |
String path = null; |
112 |
0 |
String encodedNavState = null; |
113 |
|
|
114 |
0 |
String pathInfo = request.getPathInfo(); |
115 |
0 |
if (pathInfo != null) |
116 |
|
{ |
117 |
0 |
StringTokenizer tokenizer = new StringTokenizer(request.getPathInfo(),"/"); |
118 |
0 |
StringBuffer buffer = new StringBuffer(); |
119 |
|
String token; |
120 |
0 |
boolean foundNavState = false; |
121 |
0 |
String navStatePrefix = getNavigationalStateParameterName() +":"; |
122 |
0 |
while (tokenizer.hasMoreTokens()) |
123 |
|
{ |
124 |
0 |
token = tokenizer.nextToken(); |
125 |
0 |
if (!foundNavState && token.startsWith(navStatePrefix)) |
126 |
|
{ |
127 |
0 |
foundNavState = true; |
128 |
0 |
if ( token.length() > navStatePrefix.length() ) |
129 |
|
{ |
130 |
0 |
encodedNavState = token.substring(navStatePrefix.length()); |
131 |
|
} |
132 |
|
} |
133 |
|
else |
134 |
|
{ |
135 |
0 |
buffer.append("/"); |
136 |
0 |
buffer.append(token); |
137 |
|
} |
138 |
|
} |
139 |
0 |
if ( buffer.length() > 0 ) |
140 |
|
{ |
141 |
0 |
path = buffer.toString(); |
142 |
|
} |
143 |
|
else |
144 |
|
{ |
145 |
0 |
path = "/"; |
146 |
|
} |
147 |
|
} |
148 |
0 |
setPath(path); |
149 |
0 |
setEncodedNavigationalState(encodedNavState); |
150 |
0 |
} |
151 |
|
|
152 |
|
protected String createPortletURL(String encodedNavState, boolean secure) |
153 |
|
{ |
154 |
0 |
return createPortletURL(encodedNavState, secure, null, false); |
155 |
|
} |
156 |
|
|
157 |
|
protected String createPortletURL(String encodedNavState, boolean secure, PortletWindow window, class="keyword">boolean action) |
158 |
|
{ |
159 |
0 |
StringBuffer buffer = new StringBuffer(""); |
160 |
0 |
buffer.append(getBaseURL(secure)); |
161 |
0 |
if (action) |
162 |
|
{ |
163 |
0 |
buffer.append(this.baseActionPath); |
164 |
|
} |
165 |
|
else |
166 |
|
{ |
167 |
0 |
buffer.append(this.baseRenderPath); |
168 |
|
} |
169 |
0 |
if ( encodedNavState != null ) |
170 |
|
{ |
171 |
0 |
buffer.append("/"); |
172 |
0 |
buffer.append(getNavigationalStateParameterName()); |
173 |
0 |
buffer.append(":"); |
174 |
0 |
buffer.append(encodedNavState); |
175 |
|
} |
176 |
0 |
if ( getPath() != null ) |
177 |
|
{ |
178 |
0 |
buffer.append(getPath()); |
179 |
|
} |
180 |
0 |
PortletEntity pe = window.getPortletEntity(); |
181 |
0 |
buffer.append( "?entity=" ).append( pe.getId() ); |
182 |
|
|
183 |
0 |
PortletDefinition portlet = pe.getPortletDefinition(); |
184 |
0 |
MutablePortletApplication app = (MutablePortletApplication)portlet.getPortletApplicationDefinition(); |
185 |
0 |
String uniqueName = app.getName() + "::" + portlet.getName(); |
186 |
0 |
buffer.append( "&portlet=" ).append( uniqueName ); |
187 |
|
|
188 |
0 |
return buffer.toString(); |
189 |
|
} |
190 |
|
|
191 |
|
public String createPortletURL(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action, class="keyword">boolean secure) |
192 |
|
{ |
193 |
|
try |
194 |
|
{ |
195 |
0 |
return createPortletURL(this.getNavigationalState().encode(window,parameters,mode,state,action), secure, window, action); |
196 |
|
} |
197 |
0 |
catch (UnsupportedEncodingException e) |
198 |
|
{ |
199 |
|
|
200 |
0 |
e.printStackTrace(); |
201 |
|
|
202 |
0 |
return null; |
203 |
|
} |
204 |
|
} |
205 |
|
} |