org.apache.cocoon.environment.portlet
Class PortletEnvironment

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.environment.AbstractEnvironment
          extended by org.apache.cocoon.environment.portlet.PortletEnvironment
All Implemented Interfaces:
LogEnabled, Environment, PermanentRedirector, Redirector, SourceResolver

public class PortletEnvironment
extends AbstractEnvironment
implements Redirector, PermanentRedirector

Implements Environment interface for the JSR-168 Portlet environment.

Version:
CVS $Id: PortletEnvironment.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Alex Rudnev, Vadim Gritsenko

Field Summary
static String HEADER_PORTLET_MODE
          This header can be read from any portlet request, and can be set on action response.
static String HEADER_PORTLET_TITLE
          This header can be set only, and only on render response.
static String HEADER_WINDOW_STATE
          This header can be read from any portlet request, and can be set on action response.
static String PARAMETER_PATH_INFO
          As portlets do not have a pathInfo in the request, we can simulate this by passing a parameter.
static String SESSION_APPLICATION_SCOPE
          This is the prefix for application scope session attributes.
static String SESSION_PORTLET_SCOPE
          This is the prefix for portlet scope session attributes.
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, avalonToCocoonSourceWrapper, initializedComponents, manager, objectModel, outputStream, prefix, rootContext, secureOutputStream, sourceResolver, uris, view
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
PortletEnvironment(String servletPath, String pathInfo, String uri, String root, javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, javax.portlet.PortletContext portletContext, Context context, String containerEncoding, String defaultFormEncoding, int defaultSessionScope)
          Constructs a PortletEnvironment object from a PortletRequest and PortletResponse objects
PortletEnvironment(String servletPath, String pathInfo, String uri, String root, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, javax.portlet.PortletContext portletContext, Context context, String containerEncoding, String defaultFormEncoding, int defaultSessionScope)
          Constructs a PortletEnvironment object from a PortletRequest and PortletResponse objects
 
Method Summary
 String getContentType()
          Get the ContentType
 OutputStream getOutputStream(int bufferSize)
          Get the output stream where to write the generated resource.
 boolean hasRedirected()
          Was one of the redirection methods called ?
 boolean isExternal()
          Always return true.
 boolean isResponseModified(long lastModified)
          This method always returns true because portlet environment does not support response codes.
 void permanentRedirect(boolean sessionmode, String newURL)
          In portlet environment this is the same as redirect(boolean, String)
 void redirect(boolean sessionmode, String newURL)
          Redirect to the given URL
 void sendStatus(int sc)
          Portlet environment does not support response status code.
 void setContentLength(int length)
          Portlet environment does not support response content length.
 void setContentType(String contentType)
          Set the ContentType
 void setResponseIsNotModified()
          Portlet environment does not support response status code.
 void setStatus(int statusCode)
          Portlet environment does not support response status code.
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from class org.apache.cocoon.environment.AbstractEnvironment
changeContext, commitResponse, extractAction, extractView, finishingProcessing, getAction, getAttribute, getAttributeNames, getContext, getObjectModel, getOutputStream, getRootContext, getURI, getURIPrefix, getView, globalRedirect, hasAttribute, initComponents, isInternalRedirect, release, removeAttribute, resolve, resolveURI, resolveURI, setAction, setAttribute, setContext, setContext, setURIPrefix, setView, startingProcessing
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.environment.Redirector
globalRedirect
 

Field Detail

PARAMETER_PATH_INFO

public static final String PARAMETER_PATH_INFO
As portlets do not have a pathInfo in the request, we can simulate this by passing a parameter. If parameter is null, this will translate to the absent pathInfo, and portlets will be matched in the sitemap using only servletPath.

See Also:
Constant Field Values

HEADER_PORTLET_MODE

public static final String HEADER_PORTLET_MODE
This header can be read from any portlet request, and can be set on action response.

See Also:
Constant Field Values

HEADER_WINDOW_STATE

public static final String HEADER_WINDOW_STATE
This header can be read from any portlet request, and can be set on action response.

See Also:
Constant Field Values

HEADER_PORTLET_TITLE

public static final String HEADER_PORTLET_TITLE
This header can be set only, and only on render response.

See Also:
Constant Field Values

SESSION_APPLICATION_SCOPE

public static final String SESSION_APPLICATION_SCOPE
This is the prefix for application scope session attributes.

See Also:
Constant Field Values

SESSION_PORTLET_SCOPE

public static final String SESSION_PORTLET_SCOPE
This is the prefix for portlet scope session attributes.

See Also:
Constant Field Values
Constructor Detail

PortletEnvironment

public PortletEnvironment(String servletPath,
                          String pathInfo,
                          String uri,
                          String root,
                          javax.portlet.ActionRequest request,
                          javax.portlet.ActionResponse response,
                          javax.portlet.PortletContext portletContext,
                          Context context,
                          String containerEncoding,
                          String defaultFormEncoding,
                          int defaultSessionScope)
                   throws IOException
Constructs a PortletEnvironment object from a PortletRequest and PortletResponse objects

Throws:
IOException

PortletEnvironment

public PortletEnvironment(String servletPath,
                          String pathInfo,
                          String uri,
                          String root,
                          javax.portlet.RenderRequest request,
                          javax.portlet.RenderResponse response,
                          javax.portlet.PortletContext portletContext,
                          Context context,
                          String containerEncoding,
                          String defaultFormEncoding,
                          int defaultSessionScope)
                   throws IOException
Constructs a PortletEnvironment object from a PortletRequest and PortletResponse objects

Throws:
IOException
Method Detail

redirect

public void redirect(boolean sessionmode,
                     String newURL)
              throws IOException
Description copied from interface: Redirector
Redirect to the given URL

Specified by:
redirect in interface Environment
Specified by:
redirect in interface Redirector
Throws:
IOException

permanentRedirect

public void permanentRedirect(boolean sessionmode,
                              String newURL)
                       throws IOException
In portlet environment this is the same as redirect(boolean, String)

Specified by:
permanentRedirect in interface PermanentRedirector
Throws:
IOException

hasRedirected

public boolean hasRedirected()
Description copied from interface: Redirector
Was one of the redirection methods called ?

Specified by:
hasRedirected in interface Redirector

setStatus

public void setStatus(int statusCode)
Portlet environment does not support response status code.

Specified by:
setStatus in interface Environment
Overrides:
setStatus in class AbstractEnvironment

sendStatus

public void sendStatus(int sc)
Portlet environment does not support response status code.

Specified by:
sendStatus in interface Redirector
Parameters:
sc - an http status code.

setContentType

public void setContentType(String contentType)
Set the ContentType

Specified by:
setContentType in interface Environment

getContentType

public String getContentType()
Get the ContentType

Specified by:
getContentType in interface Environment

setContentLength

public void setContentLength(int length)
Portlet environment does not support response content length. This method does nothing.

Specified by:
setContentLength in interface Environment

isResponseModified

public boolean isResponseModified(long lastModified)
This method always returns true because portlet environment does not support response codes.

Specified by:
isResponseModified in interface Environment
Overrides:
isResponseModified in class AbstractEnvironment
Returns:
true if the response is modified or if the environment is not able to test it

setResponseIsNotModified

public void setResponseIsNotModified()
Portlet environment does not support response status code. This method does nothing.

Specified by:
setResponseIsNotModified in interface Environment
Overrides:
setResponseIsNotModified in class AbstractEnvironment

tryResetResponse

public boolean tryResetResponse()
                         throws IOException
Reset the response if possible. This allows error handlers to have a higher chance to produce clean output if the pipeline that raised the error has already output some data.

Specified by:
tryResetResponse in interface Environment
Overrides:
tryResetResponse in class AbstractEnvironment
Returns:
true if the response was successfully reset
Throws:
IOException

getOutputStream

public OutputStream getOutputStream(int bufferSize)
                             throws IOException
Get the output stream where to write the generated resource. The returned stream is buffered by the environment. If the buffer size is -1 then the complete output is buffered. If the buffer size is 0, no buffering takes place. This method replaces AbstractEnvironment.getOutputStream().

Specified by:
getOutputStream in interface Environment
Overrides:
getOutputStream in class AbstractEnvironment
Throws:
IOException

isExternal

public boolean isExternal()
Always return true.

Specified by:
isExternal in interface Environment
Returns:
true if this environment is external


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