View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.request;
18  
19  import java.security.Principal;
20  import java.util.Locale;
21  import java.util.Map;
22  
23  import javax.security.auth.Subject;
24  import javax.servlet.ServletConfig;
25  import javax.servlet.http.HttpServletRequest;
26  import javax.servlet.http.HttpServletResponse;
27  
28  import org.apache.jetspeed.PortalReservedParameters;
29  import org.apache.jetspeed.aggregator.ContentDispatcher;
30  import org.apache.jetspeed.capabilities.CapabilityMap;
31  import org.apache.jetspeed.container.url.PortalURL;
32  import org.apache.jetspeed.om.page.ContentPage;
33  import org.apache.jetspeed.pipeline.Pipeline;
34  import org.apache.jetspeed.profiler.Profiler;
35  import org.apache.pluto.om.common.Language;
36  import org.apache.pluto.om.common.ObjectID;
37  import org.apache.pluto.om.portlet.PortletDefinition;
38  import org.apache.pluto.om.window.PortletWindow;
39  
40  /***
41   * Portal Request Context is associated with each request
42   *
43   * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
44   * @version $Id: RequestContext.java,v 1.14 2005/04/29 14:00:48 weaver Exp $
45   */
46  public interface RequestContext
47  {
48      public final static String REQUEST_PORTALENV = PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE;
49  
50      /***
51       * Gets the HTTP Servlet Request.  This is the Servlet
52       * containers raw request object.  This request should
53       * be wrapped using <code>getPortletRequestForWindow()</code> before
54       * being processed by the portlet container.
55       *
56       * @return HttpServletRequest
57       */
58      public HttpServletRequest getRequest();
59  
60      /***
61       * Sets the HTTP Servlet Request.  This is the Servlet
62       * containers raw request object.  This request should
63       * be wrapped using <code>getPortletRequestForWindow()</code> before
64       * being processed by the portlet container.
65       *
66       * @return HttpServletRequest
67       */    
68      public void setRequest(HttpServletRequest request);
69      
70      /***
71       * Gets the HTTP Servlet Response.  This is the Servlet
72       * containers raw response object.  This response should
73       * be wrapped using <code>getPortletResponseForWindow()</code> before
74       * being processed by the portlet container.
75       * @return HttpServletResponse
76       */
77      public HttpServletResponse getResponse();
78  
79      /***
80       * Sets the HTTP Servlet Response.  This is the Servlet
81       * containers raw response object.  This response should
82       * be wrapped using <code>getPortletResponseForWindow()</code> before
83       * being processed by the portlet container.
84       * @return HttpServletResponse
85       */    
86      public void setResponse(HttpServletResponse response);
87      
88      /***
89       * Gets the HTTP Servlet Config
90       *
91       * @return ServletConfig
92       */
93      public ServletConfig getConfig();
94  
95      /***
96       * Gets the profile locators for this request
97       *
98       * @return Profile locators by locator name
99       */
100     public Map getProfileLocators();
101 
102     /***
103      * Sets the target page profile locators for this request
104      *
105      * @param locators The target profile locators by locator name
106      */
107     public void setProfileLocators(Map locators);
108 
109     /***
110      * Gets the target page for this request
111      *
112      * @return Page
113      */
114     public ContentPage getPage();
115 
116     /***
117      * Sets the target page  for this request
118      *
119      * @param page The target page
120      */
121     public void setPage(ContentPage page);
122 
123     /***
124      * Gets the content dispatcher for this request
125      *
126      * @return ContentDispatcher
127      */
128     public ContentDispatcher getContentDispatcher();
129 
130     /***
131      * Sets the content dispatcher for this request
132      *
133      * @param dispatcher The ContentDispatcher to use for this request
134      */
135     public void setContentDispatcher(ContentDispatcher dispatcher);
136 
137     /***
138      * Set the capabilityMap. Used by the CapabilityValve
139      *
140      * @param capabilityMap
141      */
142     public void setCapabilityMap(CapabilityMap map);
143 
144     /***
145      * Get the Capability Map
146      *
147      */
148     public CapabilityMap getCapabilityMap();
149 
150     /***
151      * Set the Mimetype. Set by the CapabilityValve
152      *
153      * @param mimeType
154      */
155     public void setMimeType(String mimeType);
156 
157     /***
158      * Get the mimeType for the request
159      *
160      */
161     public String getMimeType();
162 
163     /***
164      * Set the mediaType. Set by the CapabilityValve
165      *
166      * @param mediaType
167      */
168     public void setMediaType(String mediaType);
169 
170     /***
171      * get the Media Type
172      *
173      */
174     public String getMediaType();
175     
176     /***
177      * Gets the Portal URL for the current request.
178      * 
179      * @return The Portal URL object for the current request.  This method will never
180      * return a <code>null</code> value.
181      * @throws IllegalStateException if <code>portalUrl</code>
182      * if has not been set.
183      */
184     public PortalURL getPortalURL();
185     
186     /***
187      * Sets the Portal URL for the current request.
188      * 
189      * @throws IllegalStateException if <code>portalUrl</code>
190      * has been set already.
191      * @throws IllegalArgumentException if a null value is passed in.
192      */
193     public void setPortalURL(PortalURL portalUrl);
194     
195     /***
196      * Get the target Action Window
197      *
198      * @return PortletWindow The target portlet action window
199      */
200     public PortletWindow getActionWindow();
201 
202     /***
203      * Sets the target Portlet Window
204      *
205      * @param window
206      */
207     public void setActionWindow(PortletWindow window);
208 
209     /***
210      * get the character encoding
211      *
212      *
213      */
214     public String getCharacterEncoding();
215 
216     /***
217      * set character encoding
218      *
219      * @param enc
220      */
221     public void setCharacterEncoding(String enc);
222 
223     /***
224      *
225      * <p>
226      * getRequestForWindow
227      * </p>
228      *
229      * Takes a PortletWindow and generates a HttpServletRequest that
230      * accurately represents that PortletWindow's request parameters
231      *
232      *
233      * @param window PortletWindow that we are build a request for
234      * @return HttpServletRequest that wraps the existing servlet
235      * container's request that can interpret encoded portlet information
236      * for this PortletWindow
237      *
238      */
239     HttpServletRequest getRequestForWindow(PortletWindow window);
240 
241     /***
242      *
243      * <p>
244      * getResponseForWindow
245      * </p>
246      *
247      * Takes a PortletWindow and generates a HttpServletResponse that
248      * accurately represents that PortletWindow's request parameters.
249      *
250      *
251      * @param window PortletWindow that we are build a response for
252      * @return HttpServletRequest that wraps the existing servlet
253      * container's request that can interpret encoded portlet information
254      * for this PortletWindow
255      *
256      *
257      */
258     HttpServletResponse getResponseForWindow(PortletWindow window);
259 
260     /***
261      * Gets the subject associated with the authorized entity.
262      * This subject can be used to provide credentials and principals.
263      *
264      * @return The JAAS subject on this request.
265      */
266     Subject getSubject();
267 
268     /***
269      * Sets the subject associated with the authorized entity.
270      * This subject can be used to provide credentials and principals.
271      *
272      * @param subject The JAAS subject on this request.
273      */
274     void setSubject(Subject subject);
275 
276     /***
277      * Gets the locale associated with this request.
278      *
279      * @return The locale associated with this request.
280      */
281     Locale getLocale();
282 
283     /***
284      * Sets the locale associated with this request.
285      *
286      * @param The locale associated with this request.
287      */
288     void setLocale(Locale locale);
289 
290     /***
291      * Use this method to get a request parameter on the generalized request,
292      * decoupling request parameter manipulation from servlet API.
293      * This parameter could be on the Http Servlet request,
294      * in that case it simply passes through to the servlet request.
295      *
296      * @param key The parameter unique key
297      * @return The object associated with the uniqu
298      */
299     String getRequestParameter(String key);
300 
301     /***
302      * Use this method to get a map of request parameters on the generalized request,
303      * decoupling request parameter manipulation from servlet API.
304      * The parameters returned could be on the Http Servlet request,
305      * in that case it simply passes through to the servlet request.
306      *
307      * @return
308      */
309     Map getParameterMap();
310 
311 
312     /***
313      * Gets an attribute from the session.
314      * This method is decoupled from the servlet api request to
315      * facilitate abstractions for testing and other programs not
316      * connected to a servlet application.
317      *
318      * @param key The key of the attribute
319      * @return The value of the attribute
320      */
321     Object getSessionAttribute(String key);
322 
323     /***
324      * Sets an attribute into the session.
325      * This method is decoupled from the servlet api request to
326      * facilitate abstractions for testing and other programs not
327      * connected to a servlet application.
328      *
329      * @param key The key of the session attribute
330      * @param value The value of the session attribute
331      */
332     void setSessionAttribute(String key, Object value);
333 
334     /***
335      * Get a request attribute associated with this single request.
336      *
337      * @param key The key of the request attribute
338      * @return The value of the request attribute
339      */
340     Object getAttribute(String key);
341 
342     /***
343      * Sets an attribute into the request.
344      * This method is decoupled from the servlet api request to
345      * facilitate abstractions for testing and other programs not
346      * connected to a servlet application.
347      *
348      * @param key The key of the request attribute
349      * @param value The value of the request attribute
350      */
351     void setAttribute(String key, Object value);
352 
353     /***
354      * <p>
355      * Returns any extra path information associated with the URL the
356      * client sent when it made this request. The extra path information
357      * follows the servlet path but precedes the query string.
358      * This method returns null if there was no extra path information.
359      * </p>
360      * <p>
361      * This method should function identically to <code>HttpServletRequest.getPathInfo()</code>
362      * except for that it removes ALL portal/portlet navigational state information from the
363      * path info string.
364      * </p>
365      *
366      * @return the path
367      */
368     String getPath();
369     
370     /***
371      * 
372      * <p>
373      * setPath
374      * </p>
375      * Allows the manual overriding of path Jetspeed 2 will look to resolves pages and folders.
376      *
377      * @param path
378      */
379     void setPath(String path);
380     
381     /***
382      * Returns the user info map of user attributes for a given portlet application.</p>
383      * @param oid The portlet application object id.
384      * @return The PortletRequest.USER_INFO map.
385      */
386     Map getUserInfoMap(ObjectID oid);
387     
388     /***
389      * 
390      * <p>
391      * getPreferedLanguage
392      * </p>
393      * Returns the Language object for the <code>portlet</code> which most
394      * closely matches the prefences of the currently requesting client.
395      * 
396      * @param portlet
397      * @return <code>Language</code> that matches, as closely as possible, that of
398      * the requesting client.
399      */
400     Language getPreferedLanguage( PortletDefinition portlet );
401     
402     /***
403      * 
404      * @return
405      */
406     Throwable popActionFailure(PortletWindow window); 
407 
408 
409     /***
410      * @param actionFailed The actionFailed to set.
411      */
412     void setActionFailure(PortletWindow window, Throwable actionFailure);
413         
414     /***
415      * Get the current executing pipeline
416      * 
417      * @return Pipeline
418      */
419     Pipeline getPipeline();
420     
421     /***
422      * Set the current pipeline
423      * @param pipeline
424      */
425     void setPipeline(Pipeline pipeline);
426 
427     /***
428      * Gets the Jetspeed primary user principal associated with the authorized entity.
429      *
430      * @return The primary principal on this request.
431      */
432     Principal getUserPrincipal();
433     
434     /***
435      * Locates a specific page using the profiler and site manager location algorithms
436      * from a generalized non-profiled path to the first page matching the path
437      * 
438      *  @param profiler The profiler component to use in the search
439      *  @return A Content Page located by the profiler, or null if not found
440      */
441     ContentPage locatePage(Profiler profiler, String nonProfiledPath);
442     
443     /***
444      * Return a map of Jetspeed Request Context objects configured via Spring Map
445      * 
446      * @return a Map of request context objects
447      * @since 2.1.2
448      */
449     Map getObjects();
450 }
451