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