001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.mockobjects.request;
018:
019: import java.security.Principal;
020: import java.util.HashMap;
021: import java.util.Locale;
022: import java.util.Map;
023:
024: import javax.security.auth.Subject;
025: import javax.servlet.ServletConfig;
026: import javax.servlet.http.HttpServletRequest;
027: import javax.servlet.http.HttpServletResponse;
028:
029: import org.apache.jetspeed.aggregator.ContentDispatcher;
030: import org.apache.jetspeed.capabilities.CapabilityMap;
031: import org.apache.jetspeed.container.state.NavigationalState;
032: import org.apache.jetspeed.container.url.PortalURL;
033: import org.apache.jetspeed.mockobjects.MockHttpServletRequest;
034: import org.apache.jetspeed.om.page.ContentPage;
035: import org.apache.jetspeed.pipeline.Pipeline;
036: import org.apache.jetspeed.profiler.Profiler;
037: import org.apache.jetspeed.request.RequestContext;
038: import org.apache.pluto.om.common.Language;
039: import org.apache.pluto.om.common.ObjectID;
040: import org.apache.pluto.om.portlet.PortletDefinition;
041: import org.apache.pluto.om.window.PortletWindow;
042:
043: /**
044: * MockRequestContext
045: *
046: * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
047: * @version $Id: MockRequestContext.java,v 1.1.2.1 2004/04/20 19:40:40 weaver
048: * Exp $
049: */
050: public class MockRequestContext implements RequestContext {
051: private Map requestParameters = new HashMap();
052: private Map requestAttributes = new HashMap();
053: private Map sessionAttributes = new HashMap();
054: private String path;
055: private Map locators;
056: private Subject subject;
057: private Locale locale;
058: private String mediaType;
059: private String mimeType;
060: private ContentPage page;
061: private HttpServletRequest request;
062: private HttpServletResponse response;
063: private Object session;
064: private Pipeline pipeline;
065: private Map objects;
066:
067: /* (non-Javadoc)
068: * @see org.apache.jetspeed.request.RequestContext#getUserInfoMap(org.apache.pluto.om.common.ObjectID)
069: */
070: public Map getUserInfoMap(ObjectID oid) {
071: // TODO Auto-generated method stub
072: return null;
073: }
074:
075: public MockRequestContext(HttpServletRequest request,
076: HttpServletResponse response) {
077: this .request = request;
078: this .response = response;
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see org.apache.jetspeed.request.RequestContext#getActionWindow()
085: */
086: public PortletWindow getActionWindow() {
087: // TODO Auto-generated method stub
088: return null;
089: }
090:
091: public MockRequestContext() {
092: // WebMockObjectFactory mockFactory = new WebMockObjectFactory();
093: this .request = new MockHttpServletRequest();
094: // this.response = mockFactory.getMockResponse();
095: // this.session = mockFactory.getSession();
096: }
097:
098: public MockRequestContext(String path) {
099: // super(null, null, null, null);
100: this .path = path;
101: }
102:
103: /*
104: * (non-Javadoc)
105: *
106: * @see org.apache.jetspeed.request.RequestContext#getCapabilityMap()
107: */
108: public CapabilityMap getCapabilityMap() {
109: // TODO Auto-generated method stub
110: return null;
111: }
112:
113: /*
114: * (non-Javadoc)
115: *
116: * @see org.apache.jetspeed.request.RequestContext#getCharacterEncoding()
117: */
118: public String getCharacterEncoding() {
119: // TODO Auto-generated method stub
120: return null;
121: }
122:
123: /*
124: * (non-Javadoc)
125: *
126: * @see org.apache.jetspeed.request.RequestContext#getConfig()
127: */
128: public ServletConfig getConfig() {
129: // TODO Auto-generated method stub
130: return null;
131: }
132:
133: /*
134: * (non-Javadoc)
135: *
136: * @see org.apache.jetspeed.request.RequestContext#getContentDispatcher()
137: */
138: public ContentDispatcher getContentDispatcher() {
139: // TODO Auto-generated method stub
140: return null;
141: }
142:
143: /*
144: * (non-Javadoc)
145: *
146: * @see org.apache.jetspeed.request.RequestContext#getLocale()
147: */
148: public Locale getLocale() {
149: return this .locale;
150: }
151:
152: /*
153: * (non-Javadoc)
154: *
155: * @see org.apache.jetspeed.request.RequestContext#getMediaType()
156: */
157: public String getMediaType() {
158: return this .mediaType;
159: }
160:
161: /*
162: * (non-Javadoc)
163: *
164: * @see org.apache.jetspeed.request.RequestContext#getMimeType()
165: */
166: public String getMimeType() {
167:
168: return this .mimeType;
169: }
170:
171: /*
172: * (non-Javadoc)
173: *
174: * @see org.apache.jetspeed.request.RequestContext#getNavigationalState()
175: */
176: public NavigationalState getNavigationalState() {
177: // TODO Auto-generated method stub
178: return null;
179: }
180:
181: /*
182: * (non-Javadoc)
183: *
184: * @see org.apache.jetspeed.request.RequestContext#getPage()
185: */
186: public ContentPage getPage() {
187: // TODO Auto-generated method stub
188: return this .page;
189: }
190:
191: /*
192: * (non-Javadoc)
193: *
194: * @see org.apache.jetspeed.request.RequestContext#getPortalURL()
195: */
196: public PortalURL getPortalURL() {
197: // TODO Auto-generated method stub
198: return null;
199: }
200:
201: public void setPortalURL(PortalURL url) {
202: }
203:
204: /*
205: * (non-Javadoc)
206: *
207: * @see org.apache.jetspeed.request.RequestContext#getProfileLocators()
208: */
209: public Map getProfileLocators() {
210: return locators;
211: }
212:
213: /*
214: * (non-Javadoc)
215: *
216: * @see org.apache.jetspeed.request.RequestContext#getRequest()
217: */
218: public HttpServletRequest getRequest() {
219: // TODO Auto-generated method stub
220: return this .request;
221: }
222:
223: /*
224: * (non-Javadoc)
225: *
226: * @see org.apache.jetspeed.request.RequestContext#getRequestForWindow(org.apache.pluto.om.window.PortletWindow)
227: */
228: public HttpServletRequest getRequestForWindow(PortletWindow window) {
229: // TODO Auto-generated method stub
230: return null;
231: }
232:
233: /*
234: * (non-Javadoc)
235: *
236: * @see org.apache.jetspeed.request.RequestContext#getResponse()
237: */
238: public HttpServletResponse getResponse() {
239: // TODO Auto-generated method stub
240: return null;
241: }
242:
243: /*
244: * (non-Javadoc)
245: *
246: * @see org.apache.jetspeed.request.RequestContext#getResponseForWindow(org.apache.pluto.om.window.PortletWindow)
247: */
248: public HttpServletResponse getResponseForWindow(PortletWindow window) {
249: // TODO Auto-generated method stub
250: return null;
251: }
252:
253: /*
254: * (non-Javadoc)
255: *
256: * @see org.apache.jetspeed.request.RequestContext#getSubject()
257: */
258: public Subject getSubject() {
259: return subject;
260: }
261:
262: public Principal getUserPrincipal() {
263: return request.getUserPrincipal();
264: }
265:
266: /*
267: * (non-Javadoc)
268: *
269: * @see org.apache.jetspeed.request.RequestContext#setActionWindow(org.apache.pluto.om.window.PortletWindow)
270: */
271: public void setActionWindow(PortletWindow window) {
272: // TODO Auto-generated method stub
273:
274: }
275:
276: /*
277: * (non-Javadoc)
278: *
279: * @see org.apache.jetspeed.request.RequestContext#setCapabilityMap(org.apache.jetspeed.capability.CapabilityMap)
280: */
281: public void setCapabilityMap(CapabilityMap map) {
282: // TODO Auto-generated method stub
283:
284: }
285:
286: /*
287: * (non-Javadoc)
288: *
289: * @see org.apache.jetspeed.request.RequestContext#setCharacterEncoding(java.lang.String)
290: */
291: public void setCharacterEncoding(String enc) {
292: // TODO Auto-generated method stub
293:
294: }
295:
296: /*
297: * (non-Javadoc)
298: *
299: * @see org.apache.jetspeed.request.RequestContext#setContentDispatcher(org.apache.jetspeed.aggregator.ContentDispatcher)
300: */
301: public void setContentDispatcher(ContentDispatcher dispatcher) {
302: // TODO Auto-generated method stub
303:
304: }
305:
306: /*
307: * (non-Javadoc)
308: *
309: * @see org.apache.jetspeed.request.RequestContext#setLocale(java.util.Locale)
310: */
311: public void setLocale(Locale locale) {
312: this .locale = locale;
313:
314: }
315:
316: /*
317: * (non-Javadoc)
318: *
319: * @see org.apache.jetspeed.request.RequestContext#setMediaType(java.lang.String)
320: */
321: public void setMediaType(String mediaType) {
322: this .mediaType = mediaType;
323:
324: }
325:
326: /*
327: * (non-Javadoc)
328: *
329: * @see org.apache.jetspeed.request.RequestContext#setMimeType(java.lang.String)
330: */
331: public void setMimeType(String mimeType) {
332: this .mimeType = mimeType;
333:
334: }
335:
336: /*
337: * (non-Javadoc)
338: *
339: * @see org.apache.jetspeed.request.RequestContext#setPage(org.apache.jetspeed.om.page.Page)
340: */
341: public void setPage(ContentPage page) {
342: this .page = page;
343:
344: }
345:
346: /*
347: * (non-Javadoc)
348: *
349: * @see org.apache.jetspeed.request.RequestContext#setProfileLocators(java.util.Map)
350: */
351: public void setProfileLocators(Map locators) {
352: this .locators = locators;
353:
354: }
355:
356: /*
357: * (non-Javadoc)
358: *
359: * @see org.apache.jetspeed.request.RequestContext#setSubject(javax.security.auth.Subject)
360: */
361: public void setSubject(Subject subject) {
362: this .subject = subject;
363:
364: }
365:
366: /*
367: * (non-Javadoc)
368: *
369: * @see org.apache.jetspeed.request.RequestContext#getRequestParameter(java.lang.String)
370: */
371: public String getRequestParameter(String key) {
372: return (String) requestParameters.get(key);
373: }
374:
375: /*
376: * (non-Javadoc)
377: *
378: * @see org.apache.jetspeed.request.RequestContext#getParameterMap()
379: */
380: public Map getParameterMap() {
381: return requestParameters;
382: }
383:
384: /*
385: * (non-Javadoc)
386: *
387: * @see org.apache.jetspeed.request.RequestContext#setSessionAttribute(java.lang.String,
388: * java.lang.Object)
389: */
390: public void setSessionAttribute(String key, Object value) {
391: this .sessionAttributes.put(key, value);
392: }
393:
394: /*
395: * (non-Javadoc)
396: *
397: * @see org.apache.jetspeed.request.RequestContext#getSessionAttribute(java.lang.String)
398: */
399: public Object getSessionAttribute(String key) {
400: return this .sessionAttributes.get(key);
401: }
402:
403: /*
404: * (non-Javadoc)
405: *
406: * @see org.apache.jetspeed.request.RequestContext#setAttribute(java.lang.String,
407: * java.lang.Object)
408: */
409: public void setAttribute(String key, Object value) {
410: requestAttributes.put(key, value);
411: }
412:
413: /*
414: * (non-Javadoc)
415: *
416: * @see org.apache.jetspeed.request.RequestContext#getAttribute(java.lang.String)
417: */
418: public Object getAttribute(String key) {
419: return requestAttributes.get(key);
420: }
421:
422: /*
423: * (non-Javadoc)
424: *
425: * @see org.apache.jetspeed.request.RequestContext#getPath()
426: */
427: public String getPath() {
428: return path;
429: }
430:
431: /**
432: * <p>
433: * getPreferedLanguage
434: * </p>
435: *
436: * @see org.apache.jetspeed.request.RequestContext#getPreferedLanguage(org.apache.pluto.om.portlet.PortletDefinition)
437: * @param portlet
438: * @return
439: */
440: public Language getPreferedLanguage(PortletDefinition portlet) {
441: // TODO Auto-generated method stub
442: return null;
443: }
444:
445: /**
446: * <p>
447: * setPath
448: * </p>
449: *
450: * @see org.apache.jetspeed.request.RequestContext#setPath(java.lang.String)
451: * @param path
452: */
453: public void setPath(String path) {
454: this .path = path;
455: }
456:
457: /* (non-Javadoc)
458: * @see org.apache.jetspeed.request.RequestContext#popActionFailure(org.apache.pluto.om.window.PortletWindow)
459: */
460: public Throwable popActionFailure(PortletWindow window) {
461: // TODO Auto-generated method stub
462: return null;
463: }
464:
465: /* (non-Javadoc)
466: * @see org.apache.jetspeed.request.RequestContext#setActionFailure(org.apache.pluto.om.window.PortletWindow, java.lang.Throwable)
467: */
468: public void setActionFailure(PortletWindow window,
469: Throwable actionFailure) {
470: // TODO Auto-generated method stub
471:
472: }
473:
474: /**
475: * Get the current executing pipeline
476: *
477: * @return Pipeline
478: */
479: public Pipeline getPipeline() {
480: return pipeline;
481: }
482:
483: /**
484: * Set the current pipeline
485: * @param pipeline
486: */
487: public void setPipeline(Pipeline pipeline) {
488: this .pipeline = pipeline;
489: }
490:
491: /**
492: * @param request The request to set.
493: */
494: public void setRequest(HttpServletRequest request) {
495: this .request = request;
496: }
497:
498: /**
499: * @param response The request to set.
500: */
501: public void setResponse(HttpServletResponse response) {
502: this .response = response;
503: }
504:
505: public ContentPage locatePage(Profiler profiler,
506: String nonProfiledPath) {
507: return null;
508: }
509:
510: public Map getObjects() {
511: return objects;
512: }
513:
514: public void setObjects(Map objects) {
515: this.objects = objects;
516: }
517: }
|