org.apache.pluto.internal.impl
Class StateAwareResponseImpl

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.apache.pluto.internal.impl.PortletResponseImpl
              extended by org.apache.pluto.internal.impl.StateAwareResponseImpl
All Implemented Interfaces:
PortletResponse, StateAwareResponse, javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse, InternalPortletResponse
Direct Known Subclasses:
ActionResponseImpl, EventResponseImpl

public class StateAwareResponseImpl
extends PortletResponseImpl
implements StateAwareResponse

Implementation of JSR-286 StateAwareResponse.

Since:
2.0

Field Summary
protected  PortalCallbackService callback
           
protected  boolean redirected
           
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
StateAwareResponseImpl(PortletContainer container, InternalPortletWindow internalPortletWindow, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)
           
 
Method Summary
 void addDateHeader(java.lang.String arg0, long arg1)
           
 void addHeader(java.lang.String arg0, java.lang.String arg1)
           
 void addIntHeader(java.lang.String arg0, int arg1)
           
 void flushBuffer()
           
 int getBufferSize()
           
 PortletMode getChangedPortletMode()
           
 WindowState getChangedWindowState()
           
 java.lang.String getCharacterEncoding()
           
 java.lang.String getContentType()
           
 java.util.Locale getLocale()
           
 javax.servlet.ServletOutputStream getOutputStream()
          TODO: javadoc about why we are using a wrapped writer here.
 PortletMode getPortletMode()
          Returns the currently set portlet mode on this reponse.
 java.util.Map<java.lang.String,java.lang.String[]> getPublicRenderParameter()
           
 java.lang.String getRedirectLocation()
           
 java.util.Map<java.lang.String,java.lang.String[]> getRenderParameterMap()
          Returns a Map of the render parameters currently set on this response.
 java.util.Map getRenderParameters()
           
 WindowState getWindowState()
          Returns the currently set window state on this response.
 java.io.PrintWriter getWriter()
           
 boolean isCommitted()
           
protected  boolean isPortletModeAllowed(PortletMode mode)
           
protected  boolean isPortletModeAllowedByPortal(PortletMode mode)
           
protected  boolean isPortletModeAllowedByPortlet(PortletMode mode)
           
protected  boolean isWindowStateAllowed(WindowState state)
           
 void removePublicRenderParameter(java.lang.String name)
          Removes the specified public render parameter.
 void reset()
           
 void resetBuffer()
           
 void sendRedirect(java.lang.String location)
           
 void setBufferSize(int arg0)
           
 void setCharacterEncoding(java.lang.String arg0)
           
 void setContentLength(int arg0)
           
 void setContentType(java.lang.String arg0)
           
 void setDateHeader(java.lang.String arg0, long arg1)
           
 void setEvent(javax.xml.namespace.QName qname, java.io.Serializable value)
          Publishes an Event with the given payload.
 void setEvent(java.lang.String name, java.io.Serializable value)
          Publishes an Event with the given payload in the default namespace.
 void setHeader(java.lang.String arg0, java.lang.String arg1)
           
 void setIntHeader(java.lang.String arg0, int arg1)
           
 void setLocale(java.util.Locale arg0)
           
 void setNextPossiblePortletModes(java.util.Enumeration portletModes)
           
 void setPortletMode(PortletMode portletMode)
          Sets the portlet mode of a portlet to the given portlet mode.
 void setRenderParameter(java.lang.String key, java.lang.String value)
          Sets a String parameter for the render request.
 void setRenderParameter(java.lang.String key, java.lang.String[] values)
          Sets a String array parameter for the render request.
 void setRenderParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)
          Sets a parameter map for the render request.
 void setStatus(int arg0)
           
 void setStatus(int arg0, java.lang.String arg1)
           
 void setWindowState(WindowState windowState)
          Sets the window state of a portlet to the given window state.
 
Methods inherited from class org.apache.pluto.internal.impl.PortletResponseImpl
addCookie, addProperty, addProperty, addProperty, addProperty, containsHeader, createActionURL, createElement, createRenderURL, createResourceURL, createResourceURL, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getContainer, getHttpServletRequest, getHttpServletResponse, getInternalPortletWindow, getNamespace, isForwarded, isIncluded, sendError, sendError, setForwarded, setIncluded, setProperty
 
Methods inherited from class javax.servlet.ServletResponseWrapper
getResponse, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.portlet.PortletResponse
addProperty, addProperty, createElement, encodeURL, getNamespace, setProperty
 

Field Detail

redirected

protected boolean redirected

callback

protected PortalCallbackService callback
Constructor Detail

StateAwareResponseImpl

public StateAwareResponseImpl(PortletContainer container,
                              InternalPortletWindow internalPortletWindow,
                              javax.servlet.http.HttpServletRequest servletRequest,
                              javax.servlet.http.HttpServletResponse servletResponse)
Method Detail

setEvent

public void setEvent(javax.xml.namespace.QName qname,
                     java.io.Serializable value)
              throws java.lang.IllegalArgumentException
Description copied from interface: StateAwareResponse
Publishes an Event with the given payload.

The object type of the value must be compliant with the specified event type in the portlet deployment descriptor.

The value must have a valid JAXB binding and be serializable.

Specified by:
setEvent in interface StateAwareResponse
Parameters:
qname - the event name to publish, must not be null
value - the value of this event, must have a valid JAXB binding and be serializable, or null.
Throws:
java.lang.IllegalArgumentException - if name is null, the value is not serializable, the value does not have a valid JAXB binding, the object type of the value is not the same as specified in the portlet deployment descriptor for this event name.

setEvent

public void setEvent(java.lang.String name,
                     java.io.Serializable value)
Description copied from interface: StateAwareResponse
Publishes an Event with the given payload in the default namespace.

The name is treated as local part of the event QName and the namespace is either taken from the default-event-namespace element in the portlet deployment descriptor, or if this element is not provided the XML default namespace XMLConstants.NULL_NS_URI is used.

The object type of the value must be compliant with the specified event type in the portlet deployment descriptor.

The value must have a valid JAXB binding and be serializable.

Specified by:
setEvent in interface StateAwareResponse
Parameters:
name - the local part of the event name to publish, must not be null
value - the value of this event, must have a valid JAXB binding and be serializable, or null.

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Overrides:
sendRedirect in class javax.servlet.http.HttpServletResponseWrapper
Throws:
java.io.IOException

getRedirectLocation

public java.lang.String getRedirectLocation()

setWindowState

public void setWindowState(WindowState windowState)
                    throws WindowStateException
Description copied from interface: StateAwareResponse
Sets the window state of a portlet to the given window state.

Possible values are the standard window states and any custom window states supported by the portal and the portlet. Standard window states are:

Specified by:
setWindowState in interface StateAwareResponse
Parameters:
windowState - the new portlet window state
Throws:
WindowStateException - if the portlet cannot switch to the specified window state. To avoid this exception the portlet can check the allowed window states with Request.isWindowStateAllowed().
See Also:
WindowState

setPortletMode

public void setPortletMode(PortletMode portletMode)
                    throws PortletModeException
Description copied from interface: StateAwareResponse
Sets the portlet mode of a portlet to the given portlet mode.

Possible values are the standard portlet modes and any custom portlet modes supported by the portal and the portlet. Portlets must declare in the deployment descriptor the portlet modes they support for each markup type. Standard portlet modes are:

Note: The portlet may still be called in a different window state in the next render call, depending on the portlet container / portal.

Specified by:
setPortletMode in interface StateAwareResponse
Parameters:
portletMode - the new portlet mode
Throws:
PortletModeException - if the portlet cannot switch to this portlet mode, because the portlet or portal does not support it for this markup, or the current user is not allowed to switch to this portlet mode. To avoid this exception the portlet can check the allowed portlet modes with Request.isPortletModeAllowed().

setRenderParameters

public void setRenderParameters(java.util.Map<java.lang.String,java.lang.String[]> parameters)
Description copied from interface: StateAwareResponse
Sets a parameter map for the render request.

All previously set render parameters are cleared.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a new request is targeted to the portlet.

The given parameters do not need to be encoded prior to calling this method.

The portlet should not modify the map any further after calling this method.

Specified by:
setRenderParameters in interface StateAwareResponse
Parameters:
parameters - Map containing parameter names for the render phase as keys and parameter values as map values. The keys in the parameter map must be of type String. The values in the parameter map must be of type String array (String[]).

setRenderParameter

public void setRenderParameter(java.lang.String key,
                               java.lang.String value)
Description copied from interface: StateAwareResponse
Sets a String parameter for the render request.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a request is targeted to the portlet.

This method replaces all parameters with the given key.

The given parameter do not need to be encoded prior to calling this method.

Specified by:
setRenderParameter in interface StateAwareResponse
Parameters:
key - key of the render parameter
value - value of the render parameter

setRenderParameter

public void setRenderParameter(java.lang.String key,
                               java.lang.String[] values)
Description copied from interface: StateAwareResponse
Sets a String array parameter for the render request.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a request is targeted to the portlet.

This method replaces all parameters with the given key.

The given parameter do not need to be encoded prior to calling this method.

Specified by:
setRenderParameter in interface StateAwareResponse
Parameters:
key - key of the render parameter
values - values of the render parameter

getRenderParameters

public java.util.Map getRenderParameters()

getRenderParameterMap

public java.util.Map<java.lang.String,java.lang.String[]> getRenderParameterMap()
Description copied from interface: StateAwareResponse
Returns a Map of the render parameters currently set on this response.

The values in the returned Map are from type String array (String[]).

If no parameters exist this method returns an empty Map.

Specified by:
getRenderParameterMap in interface StateAwareResponse
Returns:
Map containing render parameter names as keys and parameter values as map values, or an empty Map if no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type String array (String[]).

getPublicRenderParameter

public java.util.Map<java.lang.String,java.lang.String[]> getPublicRenderParameter()

getChangedPortletMode

public PortletMode getChangedPortletMode()

getPortletMode

public PortletMode getPortletMode()
Description copied from interface: StateAwareResponse
Returns the currently set portlet mode on this reponse.

Specified by:
getPortletMode in interface StateAwareResponse
Returns:
the portlet mode, or null if none is set

getChangedWindowState

public WindowState getChangedWindowState()

getWindowState

public WindowState getWindowState()
Description copied from interface: StateAwareResponse
Returns the currently set window state on this response.

Specified by:
getWindowState in interface StateAwareResponse
Returns:
the window state, or null if none is set

isPortletModeAllowed

protected boolean isPortletModeAllowed(PortletMode mode)

isPortletModeAllowedByPortlet

protected boolean isPortletModeAllowedByPortlet(PortletMode mode)

isPortletModeAllowedByPortal

protected boolean isPortletModeAllowedByPortal(PortletMode mode)

isWindowStateAllowed

protected boolean isWindowStateAllowed(WindowState state)

setNextPossiblePortletModes

public void setNextPossiblePortletModes(java.util.Enumeration portletModes)

reset

public void reset()
Specified by:
reset in interface javax.servlet.ServletResponse
Overrides:
reset in class javax.servlet.ServletResponseWrapper

resetBuffer

public void resetBuffer()
Specified by:
resetBuffer in interface javax.servlet.ServletResponse
Overrides:
resetBuffer in class javax.servlet.ServletResponseWrapper

setBufferSize

public void setBufferSize(int arg0)
Specified by:
setBufferSize in interface javax.servlet.ServletResponse
Overrides:
setBufferSize in class javax.servlet.ServletResponseWrapper

setCharacterEncoding

public void setCharacterEncoding(java.lang.String arg0)
Specified by:
setCharacterEncoding in interface javax.servlet.ServletResponse
Overrides:
setCharacterEncoding in class javax.servlet.ServletResponseWrapper

setContentLength

public void setContentLength(int arg0)
Specified by:
setContentLength in interface javax.servlet.ServletResponse
Overrides:
setContentLength in class javax.servlet.ServletResponseWrapper

setContentType

public void setContentType(java.lang.String arg0)
Specified by:
setContentType in interface javax.servlet.ServletResponse
Overrides:
setContentType in class javax.servlet.ServletResponseWrapper

setLocale

public void setLocale(java.util.Locale arg0)
Specified by:
setLocale in interface javax.servlet.ServletResponse
Overrides:
setLocale in class javax.servlet.ServletResponseWrapper

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.lang.IllegalStateException,
                                                         java.io.IOException
Description copied from class: PortletResponseImpl
TODO: javadoc about why we are using a wrapped writer here.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Overrides:
getOutputStream in class PortletResponseImpl
Throws:
java.lang.IllegalStateException
java.io.IOException
See Also:
PrintWriterServletOutputStream

getWriter

public java.io.PrintWriter getWriter()
                              throws java.lang.IllegalStateException,
                                     java.io.IOException
Specified by:
getWriter in interface javax.servlet.ServletResponse
Overrides:
getWriter in class PortletResponseImpl
Throws:
java.lang.IllegalStateException
java.io.IOException

addDateHeader

public void addDateHeader(java.lang.String arg0,
                          long arg1)
Specified by:
addDateHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addDateHeader in class javax.servlet.http.HttpServletResponseWrapper

addHeader

public void addHeader(java.lang.String arg0,
                      java.lang.String arg1)
Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addHeader in class javax.servlet.http.HttpServletResponseWrapper

addIntHeader

public void addIntHeader(java.lang.String arg0,
                         int arg1)
Specified by:
addIntHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addIntHeader in class javax.servlet.http.HttpServletResponseWrapper

setStatus

public void setStatus(int arg0,
                      java.lang.String arg1)
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Overrides:
setStatus in class javax.servlet.http.HttpServletResponseWrapper

setDateHeader

public void setDateHeader(java.lang.String arg0,
                          long arg1)
Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setDateHeader in class javax.servlet.http.HttpServletResponseWrapper

setHeader

public void setHeader(java.lang.String arg0,
                      java.lang.String arg1)
Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setHeader in class javax.servlet.http.HttpServletResponseWrapper

setIntHeader

public void setIntHeader(java.lang.String arg0,
                         int arg1)
Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setIntHeader in class javax.servlet.http.HttpServletResponseWrapper

setStatus

public void setStatus(int arg0)
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Overrides:
setStatus in class javax.servlet.http.HttpServletResponseWrapper

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Overrides:
flushBuffer in class javax.servlet.ServletResponseWrapper
Throws:
java.io.IOException

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface javax.servlet.ServletResponse
Overrides:
getBufferSize in class javax.servlet.ServletResponseWrapper

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse
Overrides:
getCharacterEncoding in class javax.servlet.ServletResponseWrapper

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface javax.servlet.ServletResponse
Overrides:
getContentType in class javax.servlet.ServletResponseWrapper

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface javax.servlet.ServletResponse
Overrides:
getLocale in class javax.servlet.ServletResponseWrapper

isCommitted

public boolean isCommitted()
Specified by:
isCommitted in interface javax.servlet.ServletResponse
Overrides:
isCommitted in class javax.servlet.ServletResponseWrapper

removePublicRenderParameter

public void removePublicRenderParameter(java.lang.String name)
Description copied from interface: StateAwareResponse
Removes the specified public render parameter. The name must reference a public render parameter defined in the portlet deployment descriptor under the public-render-parameter element with the identifier mapping to the parameter name.

Specified by:
removePublicRenderParameter in interface StateAwareResponse
Parameters:
name - a String specifying the name of the public render parameter to be removed


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.