org.jasig.portal.container.services.information
Class PortletStateManager

java.lang.Object
  extended by org.jasig.portal.container.services.information.PortletStateManager

public class PortletStateManager
extends java.lang.Object

The PortletStateManager implementation. Analyzes the incoming request parameters for the given PortletWindow, changes the window states/portlet modes, stores them in the static hash maps, builds a portlet URL based on the changed modes/states and portlet render parameters for the current PortletWindow.

Version:
$Revision: 1.44.2.1 $
Author:
Michael Ivanov, mvi@immagic.com

Field Summary
static java.lang.String ACTION
           
private  boolean isAction
           
private static org.apache.commons.logging.Log LOG
           
static java.lang.String MIN_CHAN_ID
           
private static java.lang.String MINIMIZED
           
private  boolean nextAction
           
private  javax.portlet.PortletMode nextMode
           
private  javax.portlet.WindowState nextState
           
private  java.util.Map params
           
private static java.lang.String ROOT
           
static java.lang.String UP_EDIT_TARGET
           
static java.lang.String UP_HELP_TARGET
           
static java.lang.String UP_PARAM_PREFIX
           
static java.lang.String UP_ROOT
           
static java.lang.String UP_TCATTR
           
static java.lang.String UP_VIEW_TARGET
           
static java.lang.String UP_WINDOW_STATE
           
private  PortletWindowImpl windowOfAction
           
 
Constructor Summary
PortletStateManager(org.apache.pluto.om.window.PortletWindow window)
          Creates a new PortletStateManager instance which can be used for generating a URL for the specified PortletWindow.
 
Method Summary
private  void analyzeRequestInformation()
          Analyzes the request parameters and sets portlet modes/window states for the current PortletWindow
 void clearParameters()
          Clears the render parameters for the current PortletWindow
static void clearState(org.apache.pluto.om.window.PortletWindow window)
          Clears the PorletMode and WindowState information for the specifid PortletWindow
private  java.lang.String decodeString(java.lang.String text)
          Generates the UTF-8 URL decoded version of the string, wrapping the possible UnsupportedEncodingException in a RuntimeException.
private  java.lang.String encodeString(java.lang.String text)
          Generates the UTF-8 URL encoded version of the string, wrapping the possible UnsupportedEncodingException in a RuntimeException.
 java.lang.String getActionURL()
          Returns a full portlet URL including uP file
private  java.lang.String getEncodedParameterString()
          Generates the string representation of the request parameters for the portlet based on it's current state.
private static java.lang.String getKey(org.apache.pluto.om.window.PortletWindow window)
          Generates a key from the PortletWindow id.
static javax.portlet.PortletMode getMode(org.apache.pluto.om.window.PortletWindow window)
          Returns the current portlet mode for the given PortletWindow
static javax.portlet.PortletMode getPrevMode(org.apache.pluto.om.window.PortletWindow window)
          Returns the previous portlet mode for the given PortletWindow
static javax.portlet.WindowState getPrevState(org.apache.pluto.om.window.PortletWindow window)
          Returns the previous portlet state for the given PortletWindow
private static javax.servlet.http.HttpSession getSession(org.apache.pluto.om.window.PortletWindow window)
          Gets a HttpSession for the specified PortletWindow.
static javax.portlet.WindowState getState(org.apache.pluto.om.window.PortletWindow window)
          Returns the current portlet state for the given PortletWindow
private static PortletWindowStateInfo getStateInfo(org.apache.pluto.om.window.PortletWindow window)
          Gets PortletWindowStateInfo for the PortletWindow, creates one if nessesary.
private static javax.servlet.http.HttpServletRequest getUnwrapedRequest(javax.servlet.http.HttpServletRequest request)
          Recursivly unwrapps a HttpServletRequest.
 boolean isAction()
          Returns true if the current PortletRequest is ActionRequest, false - otherwise
 void setAction()
          Setting the portlet action parameter for the next request
static void setMode(org.apache.pluto.om.window.PortletWindow window, javax.portlet.PortletMode mode)
          Sets the portlet mode for the given PortletWindow
 void setNextMode(javax.portlet.PortletMode mode)
          Sets the next portlet mode for the current PortletWindow
 void setNextState(javax.portlet.WindowState state)
          Sets the next window state for the current PortletWindow
 void setParameters(java.util.Map parameters)
          Adds the render parameters to the portlet URL
static void setState(org.apache.pluto.om.window.PortletWindow window, javax.portlet.WindowState state)
          Sets the window state for the given PortletWindow
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.commons.logging.Log LOG

UP_PARAM_PREFIX

public static final java.lang.String UP_PARAM_PREFIX
See Also:
Constant Field Values

ACTION

public static final java.lang.String ACTION
See Also:
Constant Field Values

UP_ROOT

public static final java.lang.String UP_ROOT
See Also:
Constant Field Values

UP_TCATTR

public static final java.lang.String UP_TCATTR
See Also:
Constant Field Values

UP_HELP_TARGET

public static final java.lang.String UP_HELP_TARGET
See Also:
Constant Field Values

UP_EDIT_TARGET

public static final java.lang.String UP_EDIT_TARGET
See Also:
Constant Field Values

UP_VIEW_TARGET

public static final java.lang.String UP_VIEW_TARGET
See Also:
Constant Field Values

UP_WINDOW_STATE

public static final java.lang.String UP_WINDOW_STATE
See Also:
Constant Field Values

MIN_CHAN_ID

public static final java.lang.String MIN_CHAN_ID
See Also:
Constant Field Values

MINIMIZED

private static final java.lang.String MINIMIZED
See Also:
Constant Field Values

ROOT

private static final java.lang.String ROOT
See Also:
Constant Field Values

windowOfAction

private final PortletWindowImpl windowOfAction

isAction

private boolean isAction

nextAction

private boolean nextAction

nextMode

private javax.portlet.PortletMode nextMode

nextState

private javax.portlet.WindowState nextState

params

private final java.util.Map params
Constructor Detail

PortletStateManager

public PortletStateManager(org.apache.pluto.om.window.PortletWindow window)
Creates a new PortletStateManager instance which can be used for generating a URL for the specified PortletWindow.

Parameters:
window - The PortletWindow to generate a URL for.
Method Detail

setNextMode

public void setNextMode(javax.portlet.PortletMode mode)
Sets the next portlet mode for the current PortletWindow

Parameters:
mode - a portlet mode

setNextState

public void setNextState(javax.portlet.WindowState state)
Sets the next window state for the current PortletWindow

Parameters:
state - a window state

setAction

public void setAction()
Setting the portlet action parameter for the next request


setParameters

public void setParameters(java.util.Map parameters)
Adds the render parameters to the portlet URL

Parameters:
parameters - a Map containing the render parameters

isAction

public boolean isAction()
Returns true if the current PortletRequest is ActionRequest, false - otherwise


clearParameters

public void clearParameters()
Clears the render parameters for the current PortletWindow


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getActionURL

public java.lang.String getActionURL()
Returns a full portlet URL including uP file


getEncodedParameterString

private java.lang.String getEncodedParameterString()
Generates the string representation of the request parameters for the portlet based on it's current state.


analyzeRequestInformation

private void analyzeRequestInformation()
Analyzes the request parameters and sets portlet modes/window states for the current PortletWindow


encodeString

private java.lang.String encodeString(java.lang.String text)
Generates the UTF-8 URL encoded version of the string, wrapping the possible UnsupportedEncodingException in a RuntimeException.

Parameters:
text - The string to encode.
Returns:
The encoded version of the string.

decodeString

private java.lang.String decodeString(java.lang.String text)
Generates the UTF-8 URL decoded version of the string, wrapping the possible UnsupportedEncodingException in a RuntimeException.

Parameters:
text - The string to decode.
Returns:
The decoded version of the string.

clearState

public static void clearState(org.apache.pluto.om.window.PortletWindow window)
Clears the PorletMode and WindowState information for the specifid PortletWindow

Parameters:
window - The PortletWindow to clear the state information for

getMode

public static javax.portlet.PortletMode getMode(org.apache.pluto.om.window.PortletWindow window)
Returns the current portlet mode for the given PortletWindow

Parameters:
window - a portlet window
Returns:
a PortletMode instance

getPrevMode

public static javax.portlet.PortletMode getPrevMode(org.apache.pluto.om.window.PortletWindow window)
Returns the previous portlet mode for the given PortletWindow

Parameters:
window - a portlet window
Returns:
a PortletMode instance

getState

public static javax.portlet.WindowState getState(org.apache.pluto.om.window.PortletWindow window)
Returns the current portlet state for the given PortletWindow

Parameters:
window - a portlet window
Returns:
a WindowState instance

getPrevState

public static javax.portlet.WindowState getPrevState(org.apache.pluto.om.window.PortletWindow window)
Returns the previous portlet state for the given PortletWindow

Parameters:
window - a portlet window
Returns:
a WindowState instance

setMode

public static void setMode(org.apache.pluto.om.window.PortletWindow window,
                           javax.portlet.PortletMode mode)
Sets the portlet mode for the given PortletWindow

Parameters:
window - a portlet window
mode - a portlet mode

setState

public static void setState(org.apache.pluto.om.window.PortletWindow window,
                            javax.portlet.WindowState state)
Sets the window state for the given PortletWindow

Parameters:
window - a portlet window
state - a window state

getSession

private static javax.servlet.http.HttpSession getSession(org.apache.pluto.om.window.PortletWindow window)
Gets a HttpSession for the specified PortletWindow. Will create one if needed.

Parameters:
window - The PortletWindow to get the HttpSession for.
Returns:
The HttpSession for the PortletWindow.
Throws:
java.lang.IllegalStateException - If the PortletWindow doesn't have an associated HttpServletRequest object.

getUnwrapedRequest

private static javax.servlet.http.HttpServletRequest getUnwrapedRequest(javax.servlet.http.HttpServletRequest request)
Recursivly unwrapps a HttpServletRequest. Determines if the current object implements HttpServletRequestWrapper, gets the wrapped request and tries to un wrap it until a base HttpServletRequest is found.

Parameters:
request - The request to unwrap.
Returns:
The unwrapped request.

getStateInfo

private static PortletWindowStateInfo getStateInfo(org.apache.pluto.om.window.PortletWindow window)
Gets PortletWindowStateInfo for the PortletWindow, creates one if nessesary.

Parameters:
window - The PortletWindow to get the PortletWindowStateInfo for.
Returns:
The PortletWindowStateInfo for the PortletWindow.

getKey

private static java.lang.String getKey(org.apache.pluto.om.window.PortletWindow window)
Generates a key from the PortletWindow id.

Parameters:
window - The PortletWindow to generate the key from.
Returns:
The key for the PortletWindow.