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.request;
018:
019: import java.security.Principal;
020: import java.util.Locale;
021: import java.util.Map;
022:
023: import javax.security.auth.Subject;
024: import javax.servlet.ServletConfig;
025: import javax.servlet.http.HttpServletRequest;
026: import javax.servlet.http.HttpServletResponse;
027:
028: import org.apache.jetspeed.PortalReservedParameters;
029: import org.apache.jetspeed.aggregator.ContentDispatcher;
030: import org.apache.jetspeed.capabilities.CapabilityMap;
031: import org.apache.jetspeed.container.url.PortalURL;
032: import org.apache.jetspeed.om.page.ContentPage;
033: import org.apache.jetspeed.pipeline.Pipeline;
034: import org.apache.jetspeed.profiler.Profiler;
035: import org.apache.pluto.om.common.Language;
036: import org.apache.pluto.om.common.ObjectID;
037: import org.apache.pluto.om.portlet.PortletDefinition;
038: import org.apache.pluto.om.window.PortletWindow;
039:
040: /**
041: * Portal Request Context is associated with each request
042: *
043: * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
044: * @version $Id: RequestContext.java,v 1.14 2005/04/29 14:00:48 weaver Exp $
045: */
046: public interface RequestContext {
047: public final static String REQUEST_PORTALENV = PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE;
048:
049: /**
050: * Gets the HTTP Servlet Request. This is the Servlet
051: * containers raw request object. This request should
052: * be wrapped using <code>getPortletRequestForWindow()</code> before
053: * being processed by the portlet container.
054: *
055: * @return HttpServletRequest
056: */
057: public HttpServletRequest getRequest();
058:
059: /**
060: * Sets the HTTP Servlet Request. This is the Servlet
061: * containers raw request object. This request should
062: * be wrapped using <code>getPortletRequestForWindow()</code> before
063: * being processed by the portlet container.
064: *
065: * @return HttpServletRequest
066: */
067: public void setRequest(HttpServletRequest request);
068:
069: /**
070: * Gets the HTTP Servlet Response. This is the Servlet
071: * containers raw response object. This response should
072: * be wrapped using <code>getPortletResponseForWindow()</code> before
073: * being processed by the portlet container.
074: * @return HttpServletResponse
075: */
076: public HttpServletResponse getResponse();
077:
078: /**
079: * Sets the HTTP Servlet Response. This is the Servlet
080: * containers raw response object. This response should
081: * be wrapped using <code>getPortletResponseForWindow()</code> before
082: * being processed by the portlet container.
083: * @return HttpServletResponse
084: */
085: public void setResponse(HttpServletResponse response);
086:
087: /**
088: * Gets the HTTP Servlet Config
089: *
090: * @return ServletConfig
091: */
092: public ServletConfig getConfig();
093:
094: /**
095: * Gets the profile locators for this request
096: *
097: * @return Profile locators by locator name
098: */
099: public Map getProfileLocators();
100:
101: /**
102: * Sets the target page profile locators for this request
103: *
104: * @param locators The target profile locators by locator name
105: */
106: public void setProfileLocators(Map locators);
107:
108: /**
109: * Gets the target page for this request
110: *
111: * @return Page
112: */
113: public ContentPage getPage();
114:
115: /**
116: * Sets the target page for this request
117: *
118: * @param page The target page
119: */
120: public void setPage(ContentPage page);
121:
122: /**
123: * Gets the content dispatcher for this request
124: *
125: * @return ContentDispatcher
126: */
127: public ContentDispatcher getContentDispatcher();
128:
129: /**
130: * Sets the content dispatcher for this request
131: *
132: * @param dispatcher The ContentDispatcher to use for this request
133: */
134: public void setContentDispatcher(ContentDispatcher dispatcher);
135:
136: /**
137: * Set the capabilityMap. Used by the CapabilityValve
138: *
139: * @param capabilityMap
140: */
141: public void setCapabilityMap(CapabilityMap map);
142:
143: /**
144: * Get the Capability Map
145: *
146: */
147: public CapabilityMap getCapabilityMap();
148:
149: /**
150: * Set the Mimetype. Set by the CapabilityValve
151: *
152: * @param mimeType
153: */
154: public void setMimeType(String mimeType);
155:
156: /**
157: * Get the mimeType for the request
158: *
159: */
160: public String getMimeType();
161:
162: /**
163: * Set the mediaType. Set by the CapabilityValve
164: *
165: * @param mediaType
166: */
167: public void setMediaType(String mediaType);
168:
169: /**
170: * get the Media Type
171: *
172: */
173: public String getMediaType();
174:
175: /**
176: * Gets the Portal URL for the current request.
177: *
178: * @return The Portal URL object for the current request. This method will never
179: * return a <code>null</code> value.
180: * @throws IllegalStateException if <code>portalUrl</code>
181: * if has not been set.
182: */
183: public PortalURL getPortalURL();
184:
185: /**
186: * Sets the Portal URL for the current request.
187: *
188: * @throws IllegalStateException if <code>portalUrl</code>
189: * has been set already.
190: * @throws IllegalArgumentException if a null value is passed in.
191: */
192: public void setPortalURL(PortalURL portalUrl);
193:
194: /**
195: * Get the target Action Window
196: *
197: * @return PortletWindow The target portlet action window
198: */
199: public PortletWindow getActionWindow();
200:
201: /**
202: * Sets the target Portlet Window
203: *
204: * @param window
205: */
206: public void setActionWindow(PortletWindow window);
207:
208: /**
209: * get the character encoding
210: *
211: *
212: */
213: public String getCharacterEncoding();
214:
215: /**
216: * set character encoding
217: *
218: * @param enc
219: */
220: public void setCharacterEncoding(String enc);
221:
222: /**
223: *
224: * <p>
225: * getRequestForWindow
226: * </p>
227: *
228: * Takes a PortletWindow and generates a HttpServletRequest that
229: * accurately represents that PortletWindow's request parameters
230: *
231: *
232: * @param window PortletWindow that we are build a request for
233: * @return HttpServletRequest that wraps the existing servlet
234: * container's request that can interpret encoded portlet information
235: * for this PortletWindow
236: *
237: */
238: HttpServletRequest getRequestForWindow(PortletWindow window);
239:
240: /**
241: *
242: * <p>
243: * getResponseForWindow
244: * </p>
245: *
246: * Takes a PortletWindow and generates a HttpServletResponse that
247: * accurately represents that PortletWindow's request parameters.
248: *
249: *
250: * @param window PortletWindow that we are build a response for
251: * @return HttpServletRequest that wraps the existing servlet
252: * container's request that can interpret encoded portlet information
253: * for this PortletWindow
254: *
255: *
256: */
257: HttpServletResponse getResponseForWindow(PortletWindow window);
258:
259: /**
260: * Gets the subject associated with the authorized entity.
261: * This subject can be used to provide credentials and principals.
262: *
263: * @return The JAAS subject on this request.
264: */
265: Subject getSubject();
266:
267: /**
268: * Sets the subject associated with the authorized entity.
269: * This subject can be used to provide credentials and principals.
270: *
271: * @param subject The JAAS subject on this request.
272: */
273: void setSubject(Subject subject);
274:
275: /**
276: * Gets the locale associated with this request.
277: *
278: * @return The locale associated with this request.
279: */
280: Locale getLocale();
281:
282: /**
283: * Sets the locale associated with this request.
284: *
285: * @param The locale associated with this request.
286: */
287: void setLocale(Locale locale);
288:
289: /**
290: * Use this method to get a request parameter on the generalized request,
291: * decoupling request parameter manipulation from servlet API.
292: * This parameter could be on the Http Servlet request,
293: * in that case it simply passes through to the servlet request.
294: *
295: * @param key The parameter unique key
296: * @return The object associated with the uniqu
297: */
298: String getRequestParameter(String key);
299:
300: /**
301: * Use this method to get a map of request parameters on the generalized request,
302: * decoupling request parameter manipulation from servlet API.
303: * The parameters returned could be on the Http Servlet request,
304: * in that case it simply passes through to the servlet request.
305: *
306: * @return
307: */
308: Map getParameterMap();
309:
310: /**
311: * Gets an attribute from the session.
312: * This method is decoupled from the servlet api request to
313: * facilitate abstractions for testing and other programs not
314: * connected to a servlet application.
315: *
316: * @param key The key of the attribute
317: * @return The value of the attribute
318: */
319: Object getSessionAttribute(String key);
320:
321: /**
322: * Sets an attribute into the session.
323: * This method is decoupled from the servlet api request to
324: * facilitate abstractions for testing and other programs not
325: * connected to a servlet application.
326: *
327: * @param key The key of the session attribute
328: * @param value The value of the session attribute
329: */
330: void setSessionAttribute(String key, Object value);
331:
332: /**
333: * Get a request attribute associated with this single request.
334: *
335: * @param key The key of the request attribute
336: * @return The value of the request attribute
337: */
338: Object getAttribute(String key);
339:
340: /**
341: * Sets an attribute into the request.
342: * This method is decoupled from the servlet api request to
343: * facilitate abstractions for testing and other programs not
344: * connected to a servlet application.
345: *
346: * @param key The key of the request attribute
347: * @param value The value of the request attribute
348: */
349: void setAttribute(String key, Object value);
350:
351: /**
352: * <p>
353: * Returns any extra path information associated with the URL the
354: * client sent when it made this request. The extra path information
355: * follows the servlet path but precedes the query string.
356: * This method returns null if there was no extra path information.
357: * </p>
358: * <p>
359: * This method should function identically to <code>HttpServletRequest.getPathInfo()</code>
360: * except for that it removes ALL portal/portlet navigational state information from the
361: * path info string.
362: * </p>
363: *
364: * @return the path
365: */
366: String getPath();
367:
368: /**
369: *
370: * <p>
371: * setPath
372: * </p>
373: * Allows the manual overriding of path Jetspeed 2 will look to resolves pages and folders.
374: *
375: * @param path
376: */
377: void setPath(String path);
378:
379: /**
380: * Returns the user info map of user attributes for a given portlet application.</p>
381: * @param oid The portlet application object id.
382: * @return The PortletRequest.USER_INFO map.
383: */
384: Map getUserInfoMap(ObjectID oid);
385:
386: /**
387: *
388: * <p>
389: * getPreferedLanguage
390: * </p>
391: * Returns the Language object for the <code>portlet</code> which most
392: * closely matches the prefences of the currently requesting client.
393: *
394: * @param portlet
395: * @return <code>Language</code> that matches, as closely as possible, that of
396: * the requesting client.
397: */
398: Language getPreferedLanguage(PortletDefinition portlet);
399:
400: /**
401: *
402: * @return
403: */
404: Throwable popActionFailure(PortletWindow window);
405:
406: /**
407: * @param actionFailed The actionFailed to set.
408: */
409: void setActionFailure(PortletWindow window, Throwable actionFailure);
410:
411: /**
412: * Get the current executing pipeline
413: *
414: * @return Pipeline
415: */
416: Pipeline getPipeline();
417:
418: /**
419: * Set the current pipeline
420: * @param pipeline
421: */
422: void setPipeline(Pipeline pipeline);
423:
424: /**
425: * Gets the Jetspeed primary user principal associated with the authorized entity.
426: *
427: * @return The primary principal on this request.
428: */
429: Principal getUserPrincipal();
430:
431: /**
432: * Locates a specific page using the profiler and site manager location algorithms
433: * from a generalized non-profiled path to the first page matching the path
434: *
435: * @param profiler The profiler component to use in the search
436: * @return A Content Page located by the profiler, or null if not found
437: */
438: ContentPage locatePage(Profiler profiler, String nonProfiledPath);
439:
440: /**
441: * Return a map of Jetspeed Request Context objects configured via Spring Map
442: *
443: * @return a Map of request context objects
444: * @since 2.1.2
445: */
446: Map getObjects();
447: }
|