1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.mockobjects.request;
18
19 import java.security.Principal;
20 import java.util.HashMap;
21 import java.util.Locale;
22 import java.util.Map;
23
24 import javax.security.auth.Subject;
25 import javax.servlet.ServletConfig;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import org.apache.jetspeed.aggregator.ContentDispatcher;
30 import org.apache.jetspeed.capabilities.CapabilityMap;
31 import org.apache.jetspeed.container.state.NavigationalState;
32 import org.apache.jetspeed.container.url.PortalURL;
33 import org.apache.jetspeed.mockobjects.MockHttpServletRequest;
34 import org.apache.jetspeed.om.page.ContentPage;
35 import org.apache.jetspeed.pipeline.Pipeline;
36 import org.apache.jetspeed.profiler.Profiler;
37 import org.apache.jetspeed.request.RequestContext;
38 import org.apache.pluto.om.common.Language;
39 import org.apache.pluto.om.common.ObjectID;
40 import org.apache.pluto.om.portlet.PortletDefinition;
41 import org.apache.pluto.om.window.PortletWindow;
42
43
44
45 /***
46 * MockRequestContext
47 *
48 * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
49 * @version $Id: MockRequestContext.java,v 1.1.2.1 2004/04/20 19:40:40 weaver
50 * Exp $
51 */
52 public class MockRequestContext implements RequestContext
53 {
54 private Map requestParameters = new HashMap();
55 private Map requestAttributes = new HashMap();
56 private Map sessionAttributes = new HashMap();
57 private String path;
58 private Map locators;
59 private Subject subject;
60 private Locale locale;
61 private String mediaType;
62 private String mimeType;
63 private ContentPage page;
64 private HttpServletRequest request;
65 private HttpServletResponse response;
66 private Object session;
67 private Pipeline pipeline;
68 private Map objects;
69
70
71
72
73 public Map getUserInfoMap( ObjectID oid )
74 {
75
76 return null;
77 }
78 public MockRequestContext(HttpServletRequest request, HttpServletResponse response)
79 {
80 this.request = request;
81 this.response = response;
82 }
83
84
85
86
87
88
89 public PortletWindow getActionWindow()
90 {
91
92 return null;
93 }
94
95
96 public MockRequestContext()
97 {
98
99 this.request = new MockHttpServletRequest();
100
101
102 }
103
104 public MockRequestContext( String path )
105 {
106
107 this.path = path;
108 }
109
110
111
112
113
114
115 public CapabilityMap getCapabilityMap()
116 {
117
118 return null;
119 }
120
121
122
123
124
125
126 public String getCharacterEncoding()
127 {
128
129 return null;
130 }
131
132
133
134
135
136
137 public ServletConfig getConfig()
138 {
139
140 return null;
141 }
142
143
144
145
146
147
148 public ContentDispatcher getContentDispatcher()
149 {
150
151 return null;
152 }
153
154
155
156
157
158
159 public Locale getLocale()
160 {
161 return this.locale;
162 }
163
164
165
166
167
168
169 public String getMediaType()
170 {
171 return this.mediaType;
172 }
173
174
175
176
177
178
179 public String getMimeType()
180 {
181
182 return this.mimeType;
183 }
184
185
186
187
188
189
190 public NavigationalState getNavigationalState()
191 {
192
193 return null;
194 }
195
196
197
198
199
200
201 public ContentPage getPage()
202 {
203
204 return this.page;
205 }
206
207
208
209
210
211
212 public PortalURL getPortalURL()
213 {
214
215 return null;
216 }
217
218 public void setPortalURL(PortalURL url)
219 {
220 }
221
222
223
224
225
226
227 public Map getProfileLocators()
228 {
229 return locators;
230 }
231
232
233
234
235
236
237 public HttpServletRequest getRequest()
238 {
239
240 return this.request;
241 }
242
243
244
245
246
247
248 public HttpServletRequest getRequestForWindow( PortletWindow window )
249 {
250
251 return null;
252 }
253
254
255
256
257
258
259 public HttpServletResponse getResponse()
260 {
261
262 return null;
263 }
264
265
266
267
268
269
270 public HttpServletResponse getResponseForWindow( PortletWindow window )
271 {
272
273 return null;
274 }
275
276
277
278
279
280
281 public Subject getSubject()
282 {
283 return subject;
284 }
285
286 public Principal getUserPrincipal()
287 {
288 return request.getUserPrincipal();
289 }
290
291
292
293
294
295
296 public void setActionWindow( PortletWindow window )
297 {
298
299
300 }
301
302
303
304
305
306
307 public void setCapabilityMap( CapabilityMap map )
308 {
309
310
311 }
312
313
314
315
316
317
318 public void setCharacterEncoding( String enc )
319 {
320
321
322 }
323
324
325
326
327
328
329 public void setContentDispatcher( ContentDispatcher dispatcher )
330 {
331
332
333 }
334
335
336
337
338
339
340 public void setLocale( Locale locale )
341 {
342 this.locale = locale;
343
344 }
345
346
347
348
349
350
351 public void setMediaType( String mediaType )
352 {
353 this.mediaType = mediaType;
354
355 }
356
357
358
359
360
361
362 public void setMimeType( String mimeType )
363 {
364 this.mimeType = mimeType;
365
366 }
367
368
369
370
371
372
373 public void setPage( ContentPage page )
374 {
375 this.page = page;
376
377 }
378
379
380
381
382
383
384 public void setProfileLocators( Map locators )
385 {
386 this.locators = locators;
387
388 }
389
390
391
392
393
394
395 public void setSubject( Subject subject )
396 {
397 this.subject = subject;
398
399 }
400
401
402
403
404
405
406
407 public String getRequestParameter( String key )
408 {
409 return (String) requestParameters.get(key);
410 }
411
412
413
414
415
416
417 public Map getParameterMap()
418 {
419 return requestParameters;
420 }
421
422
423
424
425
426
427
428 public void setSessionAttribute( String key, Object value )
429 {
430 this.sessionAttributes.put(key, value);
431 }
432
433
434
435
436
437
438 public Object getSessionAttribute( String key )
439 {
440 return this.sessionAttributes.get(key);
441 }
442
443
444
445
446
447
448
449 public void setAttribute( String key, Object value )
450 {
451 requestAttributes.put(key, value);
452 }
453
454
455
456
457
458
459 public Object getAttribute( String key )
460 {
461 return requestAttributes.get(key);
462 }
463
464
465
466
467
468
469 public String getPath()
470 {
471 return path;
472 }
473
474 /***
475 * <p>
476 * getPreferedLanguage
477 * </p>
478 *
479 * @see org.apache.jetspeed.request.RequestContext#getPreferedLanguage(org.apache.pluto.om.portlet.PortletDefinition)
480 * @param portlet
481 * @return
482 */
483 public Language getPreferedLanguage( PortletDefinition portlet )
484 {
485
486 return null;
487 }
488 /***
489 * <p>
490 * setPath
491 * </p>
492 *
493 * @see org.apache.jetspeed.request.RequestContext#setPath(java.lang.String)
494 * @param path
495 */
496 public void setPath( String path )
497 {
498 this.path = path;
499 }
500
501
502
503
504
505 public Throwable popActionFailure(PortletWindow window)
506 {
507
508 return null;
509 }
510
511
512
513 public void setActionFailure(PortletWindow window, Throwable actionFailure)
514 {
515
516
517 }
518
519 /***
520 * Get the current executing pipeline
521 *
522 * @return Pipeline
523 */
524 public Pipeline getPipeline()
525 {
526 return pipeline;
527 }
528
529
530 /***
531 * Set the current pipeline
532 * @param pipeline
533 */
534 public void setPipeline(Pipeline pipeline)
535 {
536 this.pipeline = pipeline;
537 }
538
539 /***
540 * @param request The request to set.
541 */
542 public void setRequest(HttpServletRequest request)
543 {
544 this.request = request;
545 }
546
547 /***
548 * @param response The request to set.
549 */
550 public void setResponse(HttpServletResponse response)
551 {
552 this.response = response;
553 }
554
555 public ContentPage locatePage(Profiler profiler, String nonProfiledPath)
556 {
557 return null;
558 }
559
560 public Map getObjects()
561 {
562 return objects;
563 }
564
565 public void setObjects(Map objects)
566 {
567 this.objects = objects;
568 }
569 }