com.ibm.wps.pe.pc.legacy.cmpf
Class PortletRequestWrapper

java.lang.Object
  extended by javax.servlet.http.HttpServletRequestWrapper
      extended by com.ibm.wps.pe.pc.legacy.cmpf.PortletRequestWrapper
All Implemented Interfaces:
PortletRequest

public class PortletRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
implements PortletRequest

Provides a convenient implementation of the PortletRequest interface that can be subclassed by developers who wish to wrap the request to a Portlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.

Since:
5.0
See Also:
PortletRequest

Constructor Summary
PortletRequestWrapper(PortletRequest portletRequest)
          Creates a PortletRequest adaptor wrapping the specified request object.
 
Method Summary
 Client getClient()
          Returns an object representing the client device that the user connects to the portal with.
protected  ClientWrapper getClientWrapper()
          Use this method to return a wrapped client instead of the getClient method
 PortletData getData()
          Returns the data of the concrete portlet instance
 Portlet.Mode getMode()
          Returns the mode that the portlet is running in.
protected  PortletRequest getPortletRequest()
          Returns the wrapped ServletRequest object.
 PortletSession getPortletSession()
          Returns the current session for the portlet or, if there is no current portlet session, creates one and returns it.
 PortletSession getPortletSession(boolean create)
          Returns the current session for the portlet or, if there is no current portlet session and the given flag is true, creates one and returns it.
 PortletSettings getPortletSettings()
          Returns the PortletSettings object of the concrete portlet.
 Portlet.Mode getPreviousMode()
          Returns the last mode that is kept for this portlet on the mode stack, or null if no previous mode exists.
 User getUser()
          Returns the user object.
 PortletWindow getWindow()
          Returns the window that the portlet is running in.
 void invalidateCache()
          Invalidates the cache for all window states, markups and locals
 void setModeModifier(Portlet.ModeModifier modeModifier)
          Defines which portlet mode is shown next.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.portlet.PortletRequest
getAttribute, getAttributeNames, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getInputStream, getIntHeader, getLocale, getLocales, getMethod, getParameter, getParameterMap, getParameterNames, getParameterValues, isSecure, removeAttribute, setAttribute
 

Constructor Detail

PortletRequestWrapper

public PortletRequestWrapper(PortletRequest portletRequest)
Creates a PortletRequest adaptor wrapping the specified request object.

Parameters:
portletRequest - the portlet request
Throws:
java.lang.IllegalArgumentException - if the request is null
Method Detail

getPortletRequest

protected PortletRequest getPortletRequest()
Returns the wrapped ServletRequest object.


getMode

public Portlet.Mode getMode()
Description copied from interface: PortletRequest
Returns the mode that the portlet is running in.

Specified by:
getMode in interface PortletRequest
Returns:
the portlet mode

getPreviousMode

public Portlet.Mode getPreviousMode()
Description copied from interface: PortletRequest
Returns the last mode that is kept for this portlet on the mode stack, or null if no previous mode exists.

Note that the result is not necessarily the last mode that this portlet was running in. For example, if the portlet starts in view mode, changes to edit mode and then goes back to view mode through a return URL or by using PortletMode.ModeModifier.PREVIOUS, then getPreviousMode will return null because the edit mode has already been removed from the stack.

Specified by:
getPreviousMode in interface PortletRequest
Returns:
the previous portlet mode

setModeModifier

public void setModeModifier(Portlet.ModeModifier modeModifier)
                     throws AccessDeniedException
Description copied from interface: PortletRequest
Defines which portlet mode is shown next. Once the mode is changed it cannot be changed back to Portlet.ModeModifier.REQUESTED.

This function may only be used during event processing, in any other case the call has no effect.

Specified by:
setModeModifier in interface PortletRequest
Parameters:
modeModifier - the mode modifier
Throws:
AccessDeniedException - if the portlet tries to access this function outside of the action event processing

getClient

public final Client getClient()
Description copied from interface: PortletRequest
Returns an object representing the client device that the user connects to the portal with.

Specified by:
getClient in interface PortletRequest
Returns:
the client

getClientWrapper

protected ClientWrapper getClientWrapper()
Use this method to return a wrapped client instead of the getClient method

Returns:
the wrapped client object.
See Also:
Client

getWindow

public PortletWindow getWindow()
Description copied from interface: PortletRequest
Returns the window that the portlet is running in.

Specified by:
getWindow in interface PortletRequest
Returns:
the portlet window

getData

public PortletData getData()
Description copied from interface: PortletRequest
Returns the data of the concrete portlet instance

If the portlet is run in CONFIGURE mode, the portlet data is not accessible and this method will return null.

Specified by:
getData in interface PortletRequest
Returns:
the portlet data

getUser

public User getUser()
Description copied from interface: PortletRequest
Returns the user object. The user object contains useful information about the user and his or her preferences.

If the user has not logged in or does not grant access to the portlet, this method returns null.

Specified by:
getUser in interface PortletRequest
Returns:
the user object

getPortletSession

public PortletSession getPortletSession()
Description copied from interface: PortletRequest
Returns the current session for the portlet or, if there is no current portlet session, creates one and returns it.

This method should not be called when no portal session exists, i.e. when no user is logged in and the portlet is viewed on an anonymous page. In this case, the result may be a temporary session and session contents will be lost after the request completes.

Specified by:
getPortletSession in interface PortletRequest
Returns:
the portlet session

getPortletSession

public PortletSession getPortletSession(boolean create)
Description copied from interface: PortletRequest
Returns the current session for the portlet or, if there is no current portlet session and the given flag is true, creates one and returns it.

If the given flag is false and there is no current session for the portal, this method returns null. If a session exists for the portal, but the portlet has not yet requested a session, a new portlet session will be created.

This method should not be called with an argument value of true when no portal session exists, i.e. when no user is logged in and the portlet is viewed on an anonymous page. In this case, the result may be a temporary session and session contents will be lost after the request completes.

Specified by:
getPortletSession in interface PortletRequest
Parameters:
create - true always return a portlet session, even if none exists and only a temporary session can be created. false return null if there is no current session for the portal. Never return a temporary session.
Returns:
the portlet session

getPortletSettings

public PortletSettings getPortletSettings()
Description copied from interface: PortletRequest
Returns the PortletSettings object of the concrete portlet.

Specified by:
getPortletSettings in interface PortletRequest
Returns:
the PortletSettings object, or NULL if no PortletSettings object is available.

invalidateCache

public void invalidateCache()
Description copied from interface: PortletRequest
Invalidates the cache for all window states, markups and locals

Specified by:
invalidateCache in interface PortletRequest