1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.engine.servlet; |
18 |
|
|
19 |
|
import java.io.BufferedReader; |
20 |
|
import java.io.IOException; |
21 |
|
import java.io.UnsupportedEncodingException; |
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.Collections; |
25 |
|
import java.util.Enumeration; |
26 |
|
import java.util.HashMap; |
27 |
|
import java.util.HashSet; |
28 |
|
import java.util.Iterator; |
29 |
|
import java.util.Locale; |
30 |
|
import java.util.Map; |
31 |
|
|
32 |
|
import javax.portlet.PortletRequest; |
33 |
|
import javax.servlet.ServletInputStream; |
34 |
|
import javax.servlet.ServletRequest; |
35 |
|
import javax.servlet.http.HttpServletRequest; |
36 |
|
import javax.servlet.http.HttpServletRequestWrapper; |
37 |
|
|
38 |
|
import org.apache.commons.logging.Log; |
39 |
|
import org.apache.commons.logging.LogFactory; |
40 |
|
import org.apache.jetspeed.Jetspeed; |
41 |
|
import org.apache.jetspeed.PortalReservedParameters; |
42 |
|
import org.apache.jetspeed.aggregator.CurrentWorkerContext; |
43 |
|
import org.apache.jetspeed.container.PortletDispatcherIncludeAware; |
44 |
|
import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapper; |
45 |
|
import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapperFactory; |
46 |
|
import org.apache.jetspeed.container.state.NavigationalState; |
47 |
|
import org.apache.jetspeed.container.url.PortalURL; |
48 |
|
import org.apache.jetspeed.om.common.GenericMetadata; |
49 |
|
import org.apache.jetspeed.om.common.LocalizedField; |
50 |
|
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
51 |
|
import org.apache.jetspeed.request.JetspeedRequestContext; |
52 |
|
import org.apache.jetspeed.request.RequestContext; |
53 |
|
import org.apache.pluto.om.entity.PortletEntity; |
54 |
|
import org.apache.pluto.om.portlet.PortletApplicationDefinition; |
55 |
|
import org.apache.pluto.om.window.PortletWindow; |
56 |
|
import org.apache.pluto.util.Enumerator; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
public class ServletRequestImpl extends HttpServletRequestWrapper implements PortletDispatcherIncludeAware |
66 |
|
{ |
67 |
|
public static final String ACCEPT_LANGUAGE = "Accept-Language"; |
68 |
|
|
69 |
0 |
private static final Log log = LogFactory.getLog(ServletRequestImpl.class); |
70 |
|
|
71 |
0 |
PortletWindow portletWindow = null; |
72 |
0 |
private JetspeedNamespaceMapper nameSpaceMapper = null; |
73 |
0 |
private ServletRequest currentRequest = null; |
74 |
|
|
75 |
|
private Map portletParameters; |
76 |
|
|
77 |
|
private boolean included; |
78 |
|
|
79 |
|
private static Boolean mergePortalParametersWithPortletParameters; |
80 |
|
private static Boolean mergePortalParametersBeforePortletParameters; |
81 |
|
|
82 |
|
private boolean portletMergePortalParametersWithPortletParameters; |
83 |
|
private boolean portletMergePortalParametersBeforePortletParameters; |
84 |
|
|
85 |
|
private Map portalParameters; |
86 |
|
|
87 |
|
private String currentIncludeQueryString; |
88 |
|
private String currentForwardQueryString; |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
private Map cachedAttributes; |
93 |
|
|
94 |
|
public ServletRequestImpl( HttpServletRequest servletRequest, PortletWindow window ) |
95 |
|
{ |
96 |
0 |
super(servletRequest); |
97 |
0 |
nameSpaceMapper = ((JetspeedNamespaceMapperFactory) Jetspeed.getComponentManager().getComponent( |
98 |
|
org.apache.pluto.util.NamespaceMapper.class)).getJetspeedNamespaceMapper(); |
99 |
0 |
this.portletWindow = window; |
100 |
|
|
101 |
|
|
102 |
0 |
String encoding = (String) servletRequest.getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE); |
103 |
0 |
boolean decode = servletRequest.getAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE) == null |
104 |
|
&& encoding != null; |
105 |
0 |
if (decode) |
106 |
|
{ |
107 |
0 |
servletRequest.setAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE, |
108 |
|
new Boolean(true)); |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
0 |
portalParameters = new HashMap(); |
113 |
0 |
for (Enumeration parameters = servletRequest.getParameterNames(); parameters.hasMoreElements();) |
114 |
|
{ |
115 |
0 |
String paramName = (String) parameters.nextElement(); |
116 |
0 |
String[] paramValues = servletRequest.getParameterValues(paramName); |
117 |
|
|
118 |
0 |
if (decode) |
119 |
|
{ |
120 |
0 |
for (int i = 0; i < paramValues.length; i++) |
121 |
|
{ |
122 |
|
try |
123 |
|
{ |
124 |
0 |
paramValues[i] = new String(paramValues[i].getBytes("ISO-8859-1"), encoding); |
125 |
|
} |
126 |
0 |
catch (UnsupportedEncodingException e) |
127 |
|
{ |
128 |
|
; |
129 |
0 |
} |
130 |
|
} |
131 |
|
} |
132 |
0 |
portalParameters.put(paramName, paramValues); |
133 |
0 |
} |
134 |
|
|
135 |
0 |
if (mergePortalParametersWithPortletParameters == null ) |
136 |
|
{ |
137 |
0 |
mergePortalParametersWithPortletParameters = |
138 |
|
new Boolean(Jetspeed.getContext().getConfiguration().getBoolean("merge.portal.parameters.with.portlet.parameters", false)); |
139 |
|
} |
140 |
|
|
141 |
0 |
if (mergePortalParametersBeforePortletParameters == null) |
142 |
|
{ |
143 |
0 |
mergePortalParametersBeforePortletParameters = |
144 |
|
new Boolean(Jetspeed.getContext().getConfiguration().getBoolean("merge.portal.parameters.before.portlet.parameters", false)); |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
0 |
PortletDefinitionComposite portletDef = (PortletDefinitionComposite)portletWindow.getPortletEntity().getPortletDefinition(); |
149 |
0 |
if(portletDef != null) |
150 |
|
{ |
151 |
0 |
GenericMetadata metaData = portletDef.getMetadata(); |
152 |
|
|
153 |
0 |
portletMergePortalParametersWithPortletParameters = |
154 |
|
getMetaDataBooleanValue( |
155 |
|
metaData, |
156 |
|
PortalReservedParameters.PORTLET_EXTENDED_DESCRIPTOR_MERGE_PORTAL_PARAMETERS_WITH_PORTLET_PARAMETERS, |
157 |
|
mergePortalParametersWithPortletParameters.booleanValue()); |
158 |
0 |
portletMergePortalParametersBeforePortletParameters = |
159 |
|
getMetaDataBooleanValue( |
160 |
|
metaData, |
161 |
|
PortalReservedParameters.PORTLET_EXTENDED_DESCRIPTOR_MERGE_PORTAL_PARAMETERS_BEFORE_PORTLET_PARAMETERS, |
162 |
|
mergePortalParametersBeforePortletParameters.booleanValue()); |
163 |
|
|
164 |
0 |
} |
165 |
|
else |
166 |
|
{ |
167 |
|
|
168 |
0 |
portletMergePortalParametersWithPortletParameters = mergePortalParametersWithPortletParameters.booleanValue(); |
169 |
0 |
portletMergePortalParametersBeforePortletParameters = mergePortalParametersBeforePortletParameters.booleanValue(); |
170 |
|
} |
171 |
0 |
} |
172 |
|
|
173 |
|
private boolean getMetaDataBooleanValue(GenericMetadata metaData, String fieldName, class="keyword">boolean defaultValue ) |
174 |
|
{ |
175 |
0 |
String value = null; |
176 |
0 |
if ( metaData != null ) |
177 |
|
{ |
178 |
0 |
Collection fields = metaData.getFields(fieldName); |
179 |
0 |
if ( fields != null && !fields.isEmpty() ) |
180 |
|
{ |
181 |
0 |
value = ((LocalizedField)fields.iterator().next()).getValue(); |
182 |
|
} |
183 |
|
} |
184 |
0 |
if ( value != null ) |
185 |
|
{ |
186 |
0 |
return Boolean.valueOf(value).booleanValue(); |
187 |
|
} |
188 |
0 |
return defaultValue; |
189 |
|
} |
190 |
|
|
191 |
|
protected HttpServletRequest _getHttpServletRequest() |
192 |
|
{ |
193 |
0 |
return (HttpServletRequest) super.getRequest(); |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
public String getParameter( String name ) |
199 |
|
{ |
200 |
0 |
Object value = this.getParameterMap().get(name); |
201 |
0 |
if (value == null) |
202 |
|
{ |
203 |
0 |
return (null); |
204 |
|
} |
205 |
0 |
else if (value instanceof String[]) |
206 |
|
{ |
207 |
0 |
return (((String[]) value)[0]); |
208 |
|
} |
209 |
0 |
else if (value instanceof String) |
210 |
|
{ |
211 |
0 |
return ((String) value); |
212 |
|
} |
213 |
|
else |
214 |
|
{ |
215 |
0 |
return (value.toString()); |
216 |
|
} |
217 |
|
} |
218 |
|
|
219 |
|
private boolean isEqual(String one, String two) |
220 |
|
{ |
221 |
0 |
return (one == null && two == class="keyword">null) || (one != class="keyword">null && two != class="keyword">null && one.equals(two)); |
222 |
|
} |
223 |
|
|
224 |
|
private boolean checkQueryStringChanged() |
225 |
|
{ |
226 |
0 |
boolean changed = false; |
227 |
0 |
ServletRequest request = getRequest(); |
228 |
0 |
String includeQueryString = (String)request.getAttribute("javax.servlet.include.query_string"); |
229 |
0 |
String forwardQueryString = (String)request.getAttribute("javax.servlet.forward.query_string"); |
230 |
|
|
231 |
0 |
if (!isEqual(currentIncludeQueryString,includeQueryString)) |
232 |
|
{ |
233 |
0 |
currentIncludeQueryString = includeQueryString; |
234 |
0 |
changed = true; |
235 |
|
} |
236 |
0 |
if (!isEqual(currentForwardQueryString,forwardQueryString)) |
237 |
|
{ |
238 |
0 |
currentForwardQueryString = forwardQueryString; |
239 |
0 |
changed = true; |
240 |
|
} |
241 |
0 |
return changed; |
242 |
|
} |
243 |
|
|
244 |
|
public Map getParameterMap() |
245 |
|
{ |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
0 |
boolean queryStringChanged = checkQueryStringChanged(); |
251 |
|
|
252 |
0 |
if (queryStringChanged || currentRequest == null || currentRequest != getRequest() ) |
253 |
|
{ |
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
0 |
currentRequest = getRequest(); |
262 |
|
|
263 |
0 |
boolean postAllowed = false; |
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
0 |
HashMap queryParameters = new HashMap(); |
269 |
0 |
for ( Iterator iter = getRequest().getParameterMap().entrySet().iterator(); iter.hasNext(); ) |
270 |
|
{ |
271 |
0 |
Map.Entry entry = (Map.Entry)iter.next(); |
272 |
0 |
String[] values = (String[])entry.getValue(); |
273 |
0 |
String[] original = (String[])portalParameters.get(entry.getKey()); |
274 |
0 |
String[] diff = null; |
275 |
0 |
if ( original == null ) |
276 |
|
{ |
277 |
|
|
278 |
0 |
diff = new String[values.length]; |
279 |
0 |
System.arraycopy(values,0,diff,0,values.length); |
280 |
|
} |
281 |
0 |
else if ( values.length > original.length ) |
282 |
|
{ |
283 |
|
|
284 |
0 |
diff = new String[values.length - original.length]; |
285 |
0 |
System.arraycopy(values,0,diff,0,values.length-original.length); |
286 |
|
} |
287 |
0 |
if ( dclass="keyword">iff != null ) |
288 |
|
{ |
289 |
0 |
queryParameters.put(entry.getKey(), diff); |
290 |
|
} |
291 |
0 |
} |
292 |
|
|
293 |
|
|
294 |
0 |
HashMap navParameters = new HashMap(); |
295 |
0 |
JetspeedRequestContext context = (JetspeedRequestContext) getAttribute("org.apache.jetspeed.request.RequestContext"); |
296 |
0 |
if (context != null) |
297 |
|
{ |
298 |
0 |
NavigationalState ns = context.getPortalURL().getNavigationalState(); |
299 |
0 |
postAllowed = ns.getPortletWindowOfAction() != null || ns.getPortletWindowOfResource() != class="keyword">null; |
300 |
0 |
Iterator iter = ns.getParameterNames(portletWindow); |
301 |
0 |
while (iter.hasNext()) |
302 |
|
{ |
303 |
0 |
String name = (String) iter.next(); |
304 |
0 |
String[] values = ns.getParameterValues(portletWindow, name); |
305 |
0 |
navParameters.put(name, values); |
306 |
0 |
} |
307 |
|
} |
308 |
|
|
309 |
|
|
310 |
0 |
HashSet keys = new HashSet(); |
311 |
0 |
keys.addAll(portalParameters.keySet()); |
312 |
0 |
keys.addAll(queryParameters.keySet()); |
313 |
0 |
keys.addAll(navParameters.keySet()); |
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
0 |
portletParameters = new HashMap(); |
326 |
0 |
for ( Iterator iter = keys.iterator(); iter.hasNext(); ) |
327 |
|
{ |
328 |
0 |
String key = (String)iter.next(); |
329 |
0 |
String[] first = (String[])queryParameters.get(key); |
330 |
0 |
String[] next = null, last = class="keyword">null, result = class="keyword">null; |
331 |
|
|
332 |
0 |
if ( portletMergePortalParametersWithPortletParameters == false && !postAllowed ) |
333 |
|
{ |
334 |
0 |
next = (String[])navParameters.get(key); |
335 |
|
} |
336 |
0 |
else if ( portletMergePortalParametersBeforePortletParameters ) |
337 |
|
{ |
338 |
0 |
next = (String[])portalParameters.get(key); |
339 |
0 |
last = (String[])navParameters.get(key); |
340 |
|
} |
341 |
|
else |
342 |
|
{ |
343 |
0 |
next = (String[])navParameters.get(key); |
344 |
0 |
last = (String[])portalParameters.get(key); |
345 |
|
} |
346 |
0 |
if ( first == null ) |
347 |
|
{ |
348 |
0 |
if ( next == null ) |
349 |
|
{ |
350 |
0 |
first = last; |
351 |
0 |
last = null; |
352 |
|
} |
353 |
|
else |
354 |
|
{ |
355 |
0 |
first = next; |
356 |
0 |
next = last; |
357 |
0 |
last = null; |
358 |
|
} |
359 |
|
} |
360 |
0 |
else if ( next == null ) |
361 |
|
{ |
362 |
0 |
next = last; |
363 |
0 |
last = null; |
364 |
|
} |
365 |
|
|
366 |
0 |
if ( last == null ) |
367 |
|
{ |
368 |
0 |
if ( next == null && first != class="keyword">null ) |
369 |
|
{ |
370 |
0 |
result = new String[first.length]; |
371 |
0 |
System.arraycopy(first,0,result,0,first.length); |
372 |
|
} |
373 |
0 |
else if (next != null ) |
374 |
|
{ |
375 |
0 |
result = new String[first.length + next.length]; |
376 |
0 |
System.arraycopy(first,0,result,0,first.length); |
377 |
0 |
System.arraycopy(next,0,result,first.length,next.length); |
378 |
|
} |
379 |
|
} |
380 |
|
else |
381 |
|
{ |
382 |
0 |
result = new String[first.length + next.length + last.length]; |
383 |
0 |
System.arraycopy(first,0,result,0,first.length); |
384 |
0 |
System.arraycopy(next,0,result,first.length,next.length); |
385 |
0 |
System.arraycopy(last,0,result,first.length+next.length,last.length); |
386 |
|
|
387 |
|
} |
388 |
0 |
if ( result != null ) |
389 |
|
{ |
390 |
0 |
portletParameters.put(key, result); |
391 |
|
} |
392 |
0 |
} |
393 |
|
} |
394 |
0 |
return Collections.unmodifiableMap(portletParameters); |
395 |
|
|
396 |
|
} |
397 |
|
|
398 |
|
public Enumeration getParameterNames() |
399 |
|
{ |
400 |
0 |
return Collections.enumeration(this.getParameterMap().keySet()); |
401 |
|
} |
402 |
|
|
403 |
|
public String[] getParameterValues( String name ) |
404 |
|
{ |
405 |
0 |
return (String[]) this.getParameterMap().get(name); |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
public Enumeration getAttributeNames() |
412 |
|
{ |
413 |
0 |
Enumeration attrNames = super.getAttributeNames(); |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
0 |
if (CurrentWorkerContext.getParallelRenderingMode()) |
418 |
|
{ |
419 |
|
|
420 |
|
|
421 |
0 |
if (cachedAttributes == null) |
422 |
|
{ |
423 |
0 |
HashMap adjustedAttrMap = new HashMap(); |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
0 |
while (attrNames.hasMoreElements()) |
428 |
|
{ |
429 |
0 |
String key = (String) attrNames.nextElement(); |
430 |
0 |
adjustedAttrMap.put(key, super.getAttribute(key)); |
431 |
0 |
} |
432 |
|
|
433 |
|
|
434 |
|
|
435 |
0 |
Enumeration cwAttrNames = CurrentWorkerContext.getAttributeNames(); |
436 |
|
|
437 |
0 |
while (cwAttrNames.hasMoreElements()) |
438 |
|
{ |
439 |
0 |
String key = (String) cwAttrNames.nextElement(); |
440 |
0 |
adjustedAttrMap.put(key, CurrentWorkerContext.getAttribute(key)); |
441 |
0 |
} |
442 |
|
|
443 |
0 |
cachedAttributes = Collections.unmodifiableMap(adjustedAttrMap); |
444 |
|
} |
445 |
|
|
446 |
0 |
attrNames = Collections.enumeration(cachedAttributes.keySet()); |
447 |
|
} |
448 |
|
|
449 |
0 |
return attrNames; |
450 |
|
} |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
public Object getAttribute( String name ) |
456 |
|
{ |
457 |
0 |
Object value = null; |
458 |
|
|
459 |
|
|
460 |
|
|
461 |
0 |
if (CurrentWorkerContext.getParallelRenderingMode()) |
462 |
|
{ |
463 |
0 |
value = CurrentWorkerContext.getAttribute(name); |
464 |
|
|
465 |
|
|
466 |
|
|
467 |
0 |
if (null == value) |
468 |
|
{ |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
0 |
value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(), name)); |
473 |
|
} |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
0 |
if (null == value) |
478 |
|
{ |
479 |
0 |
value = getAttributeInternal(name); |
480 |
|
} |
481 |
|
|
482 |
0 |
return value; |
483 |
|
} |
484 |
|
|
485 |
|
private Object getAttributeInternal( String name ) |
486 |
|
{ |
487 |
0 |
Object value = super.getAttribute(name); |
488 |
0 |
if (name.equals(PortletRequest.USER_INFO)) |
489 |
|
{ |
490 |
0 |
JetspeedRequestContext context = (JetspeedRequestContext) getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE); |
491 |
0 |
if (null != context) |
492 |
|
{ |
493 |
0 |
String entityID = "--NULL--"; |
494 |
0 |
PortletEntity entity = portletWindow.getPortletEntity(); |
495 |
0 |
if (entity != null) |
496 |
|
{ |
497 |
0 |
entityID = entity.getId().toString(); |
498 |
|
} |
499 |
0 |
PortletApplicationDefinition portletAppDef = entity.getPortletDefinition() |
500 |
|
.getPortletApplicationDefinition(); |
501 |
|
|
502 |
0 |
if (null != portletAppDef) |
503 |
|
{ |
504 |
0 |
value = context.getUserInfoMap(portletAppDef.getId()); |
505 |
0 |
if (log.isDebugEnabled() && (null != value)) |
506 |
0 |
log.debug(PortletRequest.USER_INFO + " map size: " + ((Map) value).size()); |
507 |
|
} |
508 |
|
else |
509 |
|
{ |
510 |
0 |
log.error("Entity is null:" + entityID); |
511 |
|
} |
512 |
|
|
513 |
|
} |
514 |
0 |
} |
515 |
|
else |
516 |
|
{ |
517 |
0 |
if (null == value) |
518 |
|
{ |
519 |
0 |
PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request"); |
520 |
0 |
if (pr != null) |
521 |
|
{ |
522 |
0 |
value = super.getAttribute(nameSpaceMapper.encode(portletWindow.getId(), |
523 |
|
name)); |
524 |
|
} |
525 |
|
} |
526 |
|
} |
527 |
0 |
return value; |
528 |
|
} |
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
public Locale getLocale() |
534 |
|
{ |
535 |
|
|
536 |
0 |
RequestContext requestContext = (RequestContext) _getHttpServletRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE); |
537 |
0 |
Locale preferedLocale = requestContext.getLocale(); |
538 |
0 |
if (preferedLocale != null) |
539 |
|
{ |
540 |
0 |
return preferedLocale; |
541 |
|
} |
542 |
|
|
543 |
0 |
return super.getLocale(); |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
public Enumeration getLocales() |
550 |
|
{ |
551 |
0 |
RequestContext requestContext = (RequestContext) _getHttpServletRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE); |
552 |
0 |
Locale preferedLocale = requestContext.getLocale(); |
553 |
0 |
if (preferedLocale != null) |
554 |
|
{ |
555 |
0 |
return getLocaleEnum(preferedLocale); |
556 |
|
} |
557 |
|
|
558 |
0 |
return super.getLocales(); |
559 |
|
} |
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
protected Enumeration getLocaleEnum( Locale preferedLocale ) |
570 |
|
{ |
571 |
0 |
ArrayList locales = new ArrayList(); |
572 |
0 |
locales.add(preferedLocale); |
573 |
0 |
Enumeration localeEnums = super.getLocales(); |
574 |
0 |
while (localeEnums.hasMoreElements()) |
575 |
|
{ |
576 |
0 |
locales.add(localeEnums.nextElement()); |
577 |
|
} |
578 |
0 |
return new Enumerator(locales); |
579 |
|
} |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
public String getHeader( String name ) |
585 |
|
{ |
586 |
0 |
if(name.equals(ACCEPT_LANGUAGE)) |
587 |
|
{ |
588 |
0 |
return getLocale().getLanguage(); |
589 |
|
} |
590 |
|
else |
591 |
|
{ |
592 |
0 |
return super.getHeader(name); |
593 |
|
} |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
|
599 |
|
public Enumeration getHeaders( String name ) |
600 |
|
{ |
601 |
0 |
if(name.equals(ACCEPT_LANGUAGE)) |
602 |
|
{ |
603 |
0 |
return getLocaleEnum(getLocale()); |
604 |
|
} |
605 |
|
else |
606 |
|
{ |
607 |
0 |
return super.getHeaders(name); |
608 |
|
} |
609 |
|
|
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
public void setAttribute( String name, Object value ) |
623 |
|
{ |
624 |
0 |
if (name == null) |
625 |
|
{ |
626 |
0 |
throw new IllegalArgumentException("Attribute name == null"); |
627 |
|
} |
628 |
|
|
629 |
|
|
630 |
|
|
631 |
0 |
if (CurrentWorkerContext.getParallelRenderingMode()) |
632 |
|
{ |
633 |
|
|
634 |
0 |
cachedAttributes = null; |
635 |
|
|
636 |
0 |
if (null == value) |
637 |
|
{ |
638 |
0 |
CurrentWorkerContext.removeAttribute(name); |
639 |
|
} |
640 |
|
else |
641 |
|
{ |
642 |
0 |
CurrentWorkerContext.setAttribute(name, value); |
643 |
|
} |
644 |
|
|
645 |
0 |
if (name.startsWith("org.apache.jetspeed")) |
646 |
|
{ |
647 |
0 |
setAttributeInternal(name, value); |
648 |
|
} |
649 |
|
} |
650 |
|
else |
651 |
|
{ |
652 |
|
|
653 |
0 |
setAttributeInternal(name, value); |
654 |
|
} |
655 |
0 |
} |
656 |
|
|
657 |
|
private void setAttributeInternal( String name, Object value ) |
658 |
|
{ |
659 |
|
|
660 |
|
|
661 |
0 |
if (name.startsWith("org.apache.jetspeed")) |
662 |
|
{ |
663 |
0 |
if (value == null) |
664 |
|
{ |
665 |
0 |
this.removeAttribute(name); |
666 |
|
} |
667 |
|
else |
668 |
|
{ |
669 |
0 |
String encodedKey = nameSpaceMapper.encode(portletWindow.getId(), name); |
670 |
0 |
this._getHttpServletRequest().setAttribute( |
671 |
|
encodedKey, value); |
672 |
|
} |
673 |
|
} |
674 |
0 |
super.setAttribute(name, value); |
675 |
0 |
} |
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
public void removeAttribute( String name ) |
686 |
|
{ |
687 |
0 |
if (name == null) |
688 |
|
{ |
689 |
0 |
throw new IllegalArgumentException("Attribute name == null"); |
690 |
|
} |
691 |
|
|
692 |
|
|
693 |
|
|
694 |
0 |
if (CurrentWorkerContext.getParallelRenderingMode()) |
695 |
|
{ |
696 |
|
|
697 |
0 |
cachedAttributes = null; |
698 |
|
|
699 |
0 |
CurrentWorkerContext.removeAttribute(name); |
700 |
|
|
701 |
0 |
if (name.startsWith("org.apache.jetspeed")) { |
702 |
0 |
super.removeAttribute(name); |
703 |
|
} |
704 |
|
} |
705 |
|
else |
706 |
|
{ |
707 |
|
|
708 |
0 |
super.removeAttribute(name); |
709 |
|
} |
710 |
0 |
} |
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
|
|
720 |
|
public Enumeration getHeaderNames() |
721 |
|
{ |
722 |
0 |
return super.getHeaderNames(); |
723 |
|
} |
724 |
|
|
725 |
|
|
726 |
|
|
727 |
|
|
728 |
|
public void setPortletDispatcherIncluded(boolean included) |
729 |
|
{ |
730 |
0 |
this.included = included; |
731 |
0 |
} |
732 |
|
|
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
public String getProtocol() |
737 |
|
{ |
738 |
0 |
return (included ? null : super.getProtocol() ); |
739 |
|
} |
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
public String getRemoteAddr() |
745 |
|
{ |
746 |
0 |
return (included ? null : super.getRemoteAddr() ); |
747 |
|
} |
748 |
|
|
749 |
|
|
750 |
|
|
751 |
|
|
752 |
|
public String getRemoteHost() |
753 |
|
{ |
754 |
0 |
return (included ? null : super.getRemoteHost() ); |
755 |
|
} |
756 |
|
|
757 |
|
|
758 |
|
|
759 |
|
|
760 |
|
public StringBuffer getRequestURL() |
761 |
|
{ |
762 |
0 |
return (included ? null : super.getRequestURL()); |
763 |
|
} |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
public String getPathInfo() |
769 |
|
{ |
770 |
0 |
return (included ? (String)super.getAttribute("javax.servlet.include.path_info") : super.getPathInfo()); |
771 |
|
} |
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
|
776 |
|
public String getPathTranslated() |
777 |
|
{ |
778 |
0 |
return (included ? null : super.getPathTranslated()); |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
public String getQueryString() |
785 |
|
{ |
786 |
0 |
return (included ? (String)super.getAttribute("javax.servlet.include.query_string") : super.getQueryString()); |
787 |
|
} |
788 |
|
|
789 |
|
|
790 |
|
|
791 |
|
|
792 |
|
public String getRequestURI() |
793 |
|
{ |
794 |
0 |
return (included ? (String)super.getAttribute("javax.servlet.include.request_uri") : super.getRequestURI()); |
795 |
|
} |
796 |
|
|
797 |
|
|
798 |
|
|
799 |
|
|
800 |
|
public String getServletPath() |
801 |
|
{ |
802 |
0 |
return (included ? (String)super.getAttribute("javax.servlet.include.servlet_path") : super.getServletPath()); |
803 |
|
} |
804 |
|
|
805 |
|
|
806 |
|
|
807 |
|
|
808 |
|
public String getContextPath() |
809 |
|
{ |
810 |
0 |
return (included ? (String)super.getAttribute("javax.servlet.include.context_path") : super.getContextPath()); |
811 |
|
} |
812 |
|
|
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
public int getContentLength() |
817 |
|
{ |
818 |
0 |
return (included ? 0 : super.getContentLength()); |
819 |
|
} |
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
public String getRealPath(String arg0) |
825 |
|
{ |
826 |
0 |
return (included ? null : super.getRealPath(arg0)); |
827 |
|
} |
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
public BufferedReader getReader() throws IOException |
833 |
|
{ |
834 |
0 |
return (included ? null : super.getReader()); |
835 |
|
} |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
public String getCharacterEncoding() |
841 |
|
{ |
842 |
0 |
return (included ? null : super.getCharacterEncoding()); |
843 |
|
} |
844 |
|
|
845 |
|
|
846 |
|
|
847 |
|
|
848 |
|
public String getContentType() |
849 |
|
{ |
850 |
0 |
return (included ? null : super.getContentType()); |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
|
856 |
|
public ServletInputStream getInputStream() throws IOException |
857 |
|
{ |
858 |
0 |
return (included ? null : super.getInputStream()); |
859 |
|
} |
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException |
865 |
|
{ |
866 |
0 |
if ( !included ) |
867 |
|
{ |
868 |
0 |
super.setCharacterEncoding(arg0); |
869 |
|
} |
870 |
0 |
} |
871 |
|
} |