org.apache.jetspeed.mockobjects.request
Class MockRequestContext

java.lang.Object
  extended by org.apache.jetspeed.mockobjects.request.MockRequestContext
All Implemented Interfaces:
RequestContext

public class MockRequestContext
extends java.lang.Object
implements RequestContext

MockRequestContext

Version:
$Id: MockRequestContext.java,v 1.1.2.1 2004/04/20 19:40:40 weaver Exp $
Author:
David Sean Taylor

Field Summary
 
Fields inherited from interface org.apache.jetspeed.request.RequestContext
REQUEST_PORTALENV
 
Constructor Summary
MockRequestContext()
           
MockRequestContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
MockRequestContext(java.lang.String path)
           
 
Method Summary
 void clearThreadContext()
          Clears the request context from the current thread
 boolean ensureThreadContext()
          The RequestContext itself is kept in a ThreadLocal, calling this method from another (parallel) thread ensures its ThreadLocal instance will be synchronized with this instance as well.
 PortletWindow getActionWindow()
          Get the target Action Window
 java.lang.Object getAttribute(java.lang.String key)
          Get a request attribute associated with this single request.
 CapabilityMap getCapabilityMap()
          Get the Capability Map
 java.lang.String getCharacterEncoding()
          get the character encoding
 javax.servlet.ServletConfig getConfig()
          Gets the HTTP Servlet Config
 PortletWindow getCurrentPortletWindow()
           
 PortletWindow getInstantlyCreatedPortletWindow(java.lang.String windowId, java.lang.String portletUniqueName)
           
 java.util.Locale getLocale()
          Gets the locale associated with this request.
 java.lang.String getMediaType()
          get the Media Type
 java.util.List<KeyValue<java.lang.String,HeadElement>> getMergedHeadElements()
          Merges and returns the head elements contributed by portlets.
 java.lang.String getMimeType()
          Get the mimeType for the request
 NavigationalState getNavigationalState()
           
 java.util.Map getObjects()
          Return a map of Jetspeed Request Context objects configured via Spring Map
 ContentPage getPage()
          Gets the target page for this request
 java.util.Map getParameterMap()
          Use this method to get a map of request parameters on the generalized request, decoupling request parameter manipulation from servlet API.
 java.lang.String getPath()
           Returns any extra path information associated with the URL the client sent when it made this request.
 Pipeline getPipeline()
          Get the current executing pipeline
 PortalURL getPortalURL()
          Gets the Portal URL for the current request.
 PortletWindow getPortletWindow(ContentFragment fragment)
           
 PortletWindow getPortletWindow(java.lang.String windowId)
           
 Language getPreferedLanguage(PortletDefinition portlet)
           getPreferedLanguage
 java.util.Map getProfileLocators()
          Gets the profile locators for this request
 javax.servlet.http.HttpServletRequest getRequest()
          Gets the HTTP Servlet Request.
 javax.servlet.http.HttpServletRequest getRequestForWindow(PortletWindow window)
           
 java.lang.String getRequestParameter(java.lang.String key)
          Use this method to get a request parameter on the generalized request, decoupling request parameter manipulation from servlet API.
 javax.servlet.http.HttpServletResponse getResponse()
          Gets the HTTP Servlet Response.
 javax.servlet.http.HttpServletResponse getResponseForWindow(PortletWindow window)
           
 java.lang.Object getSessionAttribute(java.lang.String key)
          Gets an attribute from the session.
 javax.security.auth.Subject getSubject()
          Gets the subject associated with the authorized entity.
 java.util.Map getUserInfoMap(java.lang.String appName)
          Returns the user info map of user attributes for a given portlet application.
 java.security.Principal getUserPrincipal()
          Gets the Jetspeed primary user principal associated with the authorized entity.
 ContentPage locatePage(Profiler profiler, PageLayoutComponent pageLayoutComponent, java.lang.String nonProfiledPath)
          Locates a specific page using the profiler and site manager location algorithms from a generalized non-profiled path to the first page matching the path
 java.lang.Throwable popActionFailure(PortletWindow window)
           
 PortletWindow resolvePortletWindow(java.lang.String windowId)
           
 void setActionFailure(PortletWindow window, java.lang.Throwable actionFailure)
           
 void setActionWindow(PortletWindow window)
          Sets the target Portlet Window
 void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute into the request.
 void setCapabilityMap(CapabilityMap map)
          Set the capabilityMap.
 void setCharacterEncoding(java.lang.String enc)
          set character encoding
 void setCurrentPortletWindow(PortletWindow window)
           
 void setLocale(java.util.Locale locale)
          Sets the locale associated with this request.
 void setMediaType(java.lang.String mediaType)
          Set the mediaType.
 void setMimeType(java.lang.String mimeType)
          Set the Mimetype.
 void setObjects(java.util.Map objects)
           
 void setPage(ContentPage page)
          Sets the target page for this request
 void setPath(java.lang.String path)
           setPath
 void setPipeline(Pipeline pipeline)
          Set the current pipeline
 void setPortalURL(PortalURL url)
          Sets the Portal URL for the current request.
 void setProfileLocators(java.util.Map locators)
          Sets the target page profile locators for this request
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the HTTP Servlet Request.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets the HTTP Servlet Response.
 void setSessionAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute into the session.
 void setSubject(javax.security.auth.Subject subject)
          Sets the subject associated with the authorized entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockRequestContext

public MockRequestContext(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)

MockRequestContext

public MockRequestContext()

MockRequestContext

public MockRequestContext(java.lang.String path)
Method Detail

getUserInfoMap

public java.util.Map getUserInfoMap(java.lang.String appName)
Description copied from interface: RequestContext
Returns the user info map of user attributes for a given portlet application.

Specified by:
getUserInfoMap in interface RequestContext
Parameters:
appName - The portlet application name.
Returns:
The PortletRequest.USER_INFO map.

getActionWindow

public PortletWindow getActionWindow()
Description copied from interface: RequestContext
Get the target Action Window

Specified by:
getActionWindow in interface RequestContext
Returns:
PortletWindow The target portlet action window

getCapabilityMap

public CapabilityMap getCapabilityMap()
Description copied from interface: RequestContext
Get the Capability Map

Specified by:
getCapabilityMap in interface RequestContext

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from interface: RequestContext
get the character encoding

Specified by:
getCharacterEncoding in interface RequestContext

getConfig

public javax.servlet.ServletConfig getConfig()
Description copied from interface: RequestContext
Gets the HTTP Servlet Config

Specified by:
getConfig in interface RequestContext
Returns:
ServletConfig

getLocale

public java.util.Locale getLocale()
Description copied from interface: RequestContext
Gets the locale associated with this request.

Specified by:
getLocale in interface RequestContext
Returns:
The locale associated with this request.

getMediaType

public java.lang.String getMediaType()
Description copied from interface: RequestContext
get the Media Type

Specified by:
getMediaType in interface RequestContext

getMimeType

public java.lang.String getMimeType()
Description copied from interface: RequestContext
Get the mimeType for the request

Specified by:
getMimeType in interface RequestContext

getNavigationalState

public NavigationalState getNavigationalState()

getPage

public ContentPage getPage()
Description copied from interface: RequestContext
Gets the target page for this request

Specified by:
getPage in interface RequestContext
Returns:
Page

getPortalURL

public PortalURL getPortalURL()
Description copied from interface: RequestContext
Gets the Portal URL for the current request.

Specified by:
getPortalURL in interface RequestContext
Returns:
The Portal URL object for the current request. This method will never return a null value.

setPortalURL

public void setPortalURL(PortalURL url)
Description copied from interface: RequestContext
Sets the Portal URL for the current request.

Specified by:
setPortalURL in interface RequestContext

getProfileLocators

public java.util.Map getProfileLocators()
Description copied from interface: RequestContext
Gets the profile locators for this request

Specified by:
getProfileLocators in interface RequestContext
Returns:
Profile locators by locator name

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Description copied from interface: RequestContext
Gets the HTTP Servlet Request. This is the Servlet containers raw request object. This request should be wrapped using getPortletRequestForWindow() before being processed by the portlet container.

Specified by:
getRequest in interface RequestContext
Returns:
HttpServletRequest

getRequestForWindow

public javax.servlet.http.HttpServletRequest getRequestForWindow(PortletWindow window)

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Description copied from interface: RequestContext
Gets the HTTP Servlet Response. This is the Servlet containers raw response object. This response should be wrapped using getPortletResponseForWindow() before being processed by the portlet container.

Specified by:
getResponse in interface RequestContext
Returns:
HttpServletResponse

getResponseForWindow

public javax.servlet.http.HttpServletResponse getResponseForWindow(PortletWindow window)

getSubject

public javax.security.auth.Subject getSubject()
Description copied from interface: RequestContext
Gets the subject associated with the authorized entity. This subject can be used to provide credentials and principals.

Specified by:
getSubject in interface RequestContext
Returns:
The JAAS subject on this request.

getUserPrincipal

public java.security.Principal getUserPrincipal()
Description copied from interface: RequestContext
Gets the Jetspeed primary user principal associated with the authorized entity.

Specified by:
getUserPrincipal in interface RequestContext
Returns:
The primary principal on this request.

setActionWindow

public void setActionWindow(PortletWindow window)
Description copied from interface: RequestContext
Sets the target Portlet Window

Specified by:
setActionWindow in interface RequestContext

setCapabilityMap

public void setCapabilityMap(CapabilityMap map)
Description copied from interface: RequestContext
Set the capabilityMap. Used by the CapabilityValve

Specified by:
setCapabilityMap in interface RequestContext

setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
Description copied from interface: RequestContext
set character encoding

Specified by:
setCharacterEncoding in interface RequestContext

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: RequestContext
Sets the locale associated with this request.

Specified by:
setLocale in interface RequestContext

setMediaType

public void setMediaType(java.lang.String mediaType)
Description copied from interface: RequestContext
Set the mediaType. Set by the CapabilityValve

Specified by:
setMediaType in interface RequestContext

setMimeType

public void setMimeType(java.lang.String mimeType)
Description copied from interface: RequestContext
Set the Mimetype. Set by the CapabilityValve

Specified by:
setMimeType in interface RequestContext

setPage

public void setPage(ContentPage page)
Description copied from interface: RequestContext
Sets the target page for this request

Specified by:
setPage in interface RequestContext
Parameters:
page - The target page

setProfileLocators

public void setProfileLocators(java.util.Map locators)
Description copied from interface: RequestContext
Sets the target page profile locators for this request

Specified by:
setProfileLocators in interface RequestContext
Parameters:
locators - The target profile locators by locator name

setSubject

public void setSubject(javax.security.auth.Subject subject)
Description copied from interface: RequestContext
Sets the subject associated with the authorized entity. This subject can be used to provide credentials and principals.

Specified by:
setSubject in interface RequestContext
Parameters:
subject - The JAAS subject on this request.

getRequestParameter

public java.lang.String getRequestParameter(java.lang.String key)
Description copied from interface: RequestContext
Use this method to get a request parameter on the generalized request, decoupling request parameter manipulation from servlet API. This parameter could be on the Http Servlet request, in that case it simply passes through to the servlet request.

Specified by:
getRequestParameter in interface RequestContext
Parameters:
key - The parameter unique key
Returns:
The object associated with the uniqu

getParameterMap

public java.util.Map getParameterMap()
Description copied from interface: RequestContext
Use this method to get a map of request parameters on the generalized request, decoupling request parameter manipulation from servlet API. The parameters returned could be on the Http Servlet request, in that case it simply passes through to the servlet request.

Specified by:
getParameterMap in interface RequestContext
Returns:

setSessionAttribute

public void setSessionAttribute(java.lang.String key,
                                java.lang.Object value)
Description copied from interface: RequestContext
Sets an attribute into the session. This method is decoupled from the servlet api request to facilitate abstractions for testing and other programs not connected to a servlet application.

Specified by:
setSessionAttribute in interface RequestContext
Parameters:
key - The key of the session attribute
value - The value of the session attribute

getSessionAttribute

public java.lang.Object getSessionAttribute(java.lang.String key)
Description copied from interface: RequestContext
Gets an attribute from the session. This method is decoupled from the servlet api request to facilitate abstractions for testing and other programs not connected to a servlet application.

Specified by:
getSessionAttribute in interface RequestContext
Parameters:
key - The key of the attribute
Returns:
The value of the attribute

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Description copied from interface: RequestContext
Sets an attribute into the request. This method is decoupled from the servlet api request to facilitate abstractions for testing and other programs not connected to a servlet application.

Specified by:
setAttribute in interface RequestContext
Parameters:
key - The key of the request attribute
value - The value of the request attribute

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Description copied from interface: RequestContext
Get a request attribute associated with this single request.

Specified by:
getAttribute in interface RequestContext
Parameters:
key - The key of the request attribute
Returns:
The value of the request attribute

getPath

public java.lang.String getPath()
Description copied from interface: RequestContext

Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.

This method should function identically to HttpServletRequest.getPathInfo() except for that it removes ALL portal/portlet navigational state information from the path info string.

Specified by:
getPath in interface RequestContext
Returns:
the path

getPreferedLanguage

public Language getPreferedLanguage(PortletDefinition portlet)

getPreferedLanguage

Specified by:
getPreferedLanguage in interface RequestContext
Parameters:
portlet -
Returns:
See Also:
org.apache.jetspeed.request.RequestContext#getPreferedLanguage(org.apache.pluto.container.om.portlet.PortletDefinition)

setPath

public void setPath(java.lang.String path)

setPath

Specified by:
setPath in interface RequestContext
Parameters:
path -
See Also:
RequestContext.setPath(java.lang.String)

popActionFailure

public java.lang.Throwable popActionFailure(PortletWindow window)
Specified by:
popActionFailure in interface RequestContext
Returns:

setActionFailure

public void setActionFailure(PortletWindow window,
                             java.lang.Throwable actionFailure)
Specified by:
setActionFailure in interface RequestContext

getPipeline

public Pipeline getPipeline()
Get the current executing pipeline

Specified by:
getPipeline in interface RequestContext
Returns:
Pipeline

setPipeline

public void setPipeline(Pipeline pipeline)
Set the current pipeline

Specified by:
setPipeline in interface RequestContext
Parameters:
pipeline -

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Description copied from interface: RequestContext
Sets the HTTP Servlet Request. This is the Servlet containers raw request object. This request should be wrapped using getPortletRequestForWindow() before being processed by the portlet container.

Specified by:
setRequest in interface RequestContext
Parameters:
request - The request to set.

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Description copied from interface: RequestContext
Sets the HTTP Servlet Response. This is the Servlet containers raw response object. This response should be wrapped using getPortletResponseForWindow() before being processed by the portlet container.

Specified by:
setResponse in interface RequestContext
Parameters:
response - The request to set.

locatePage

public ContentPage locatePage(Profiler profiler,
                              PageLayoutComponent pageLayoutComponent,
                              java.lang.String nonProfiledPath)
Description copied from interface: RequestContext
Locates a specific page using the profiler and site manager location algorithms from a generalized non-profiled path to the first page matching the path

Specified by:
locatePage in interface RequestContext
Parameters:
profiler - The profiler component to use in the search
pageLayoutComponent - The page layout component used to assemble the returned page
Returns:
A Content Page located by the profiler, or null if not found

getObjects

public java.util.Map getObjects()
Description copied from interface: RequestContext
Return a map of Jetspeed Request Context objects configured via Spring Map

Specified by:
getObjects in interface RequestContext
Returns:
a Map of request context objects

setObjects

public void setObjects(java.util.Map objects)

getCurrentPortletWindow

public PortletWindow getCurrentPortletWindow()
Specified by:
getCurrentPortletWindow in interface RequestContext

setCurrentPortletWindow

public void setCurrentPortletWindow(PortletWindow window)
Specified by:
setCurrentPortletWindow in interface RequestContext

getPortletWindow

public PortletWindow getPortletWindow(ContentFragment fragment)
Specified by:
getPortletWindow in interface RequestContext

getPortletWindow

public PortletWindow getPortletWindow(java.lang.String windowId)
Specified by:
getPortletWindow in interface RequestContext

getInstantlyCreatedPortletWindow

public PortletWindow getInstantlyCreatedPortletWindow(java.lang.String windowId,
                                                      java.lang.String portletUniqueName)
Specified by:
getInstantlyCreatedPortletWindow in interface RequestContext

resolvePortletWindow

public PortletWindow resolvePortletWindow(java.lang.String windowId)
Specified by:
resolvePortletWindow in interface RequestContext

clearThreadContext

public void clearThreadContext()
Description copied from interface: RequestContext
Clears the request context from the current thread

Specified by:
clearThreadContext in interface RequestContext

ensureThreadContext

public boolean ensureThreadContext()
Description copied from interface: RequestContext
The RequestContext itself is kept in a ThreadLocal, calling this method from another (parallel) thread ensures its ThreadLocal instance will be synchronized with this instance as well.

This method will return true if this thread its ThreadLocal didn't yet have this RequestContext value set. In that case the calling code block, preferably in a finally statement should call clearThreadContext() to ensure the reference to this instance is removed again from its ThreadLocal instance as Thread Pool solutions might reuse threads.

Specified by:
ensureThreadContext in interface RequestContext
Returns:
true if the current thread didn't have this request context set or contained a different (stale/left over?) request context

getMergedHeadElements

public java.util.List<KeyValue<java.lang.String,HeadElement>> getMergedHeadElements()
Description copied from interface: RequestContext
Merges and returns the head elements contributed by portlets.

Specified by:
getMergedHeadElements in interface RequestContext
Returns:


Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.