com.liferay.faces.bridge.container
Class PortletContainerImpl

java.lang.Object
  extended by com.liferay.faces.bridge.container.PortletContainerCompatImpl
      extended by com.liferay.faces.bridge.container.PortletContainerImpl
All Implemented Interfaces:
PortletContainer, Serializable, EventListener, javax.faces.event.PhaseListener
Direct Known Subclasses:
PortletContainerLiferayCompatImpl, PortletContainerPlutoImpl

public class PortletContainerImpl
extends PortletContainerCompatImpl

Author:
Neil Griffin
See Also:
Serialized Form

Constructor Summary
PortletContainerImpl(javax.portlet.PortletRequest portletRequest, BridgeConfig bridgeConfig)
           
 
Method Summary
 void afterPhase(javax.faces.event.PhaseEvent phaseEvent)
           
 void beforePhase(javax.faces.event.PhaseEvent event)
           
protected  void copyRequestParameters(String fromURL, javax.portlet.BaseURL toURL)
          Copies any query paramters present in the specified "from" URL to the specified "to" URL.
protected  javax.portlet.PortletURL createActionURL(javax.portlet.MimeResponse mimeResponse)
           
 javax.portlet.PortletURL createActionURL(String fromURL)
          Creates a portlet action URL and copies query parameters that might be present in the specified URL.
 javax.portlet.ResourceURL createPartialActionURL(String fromURL)
          Creates a portlet resource URL that is suitable for partial requests (Ajax).
 javax.portlet.PortletURL createRedirectURL(String fromURL, Map<String,List<String>> parameters)
          Note that this default method implementation doesn't help when a is present in the navigation-rule.
protected  javax.portlet.PortletURL createRenderURL(javax.portlet.MimeResponse mimeResponse)
           
 javax.portlet.PortletURL createRenderURL(String fromURL)
          Creates a portlet render URL and copies query parameters that might be present in the specified URL.
protected  javax.portlet.ResourceURL createResourceURL(javax.portlet.MimeResponse mimeResponse)
           
 javax.portlet.ResourceURL createResourceURL(String fromURL)
          Creates a portlet resource URL and copies the javax.faces.resource value and query parameters that might be present in the specified URL.
 String fixRequestParameterValue(String value)
          This method provides the portlet conainer with an opportunity to fix/correct/massage the specified request parameter value.
protected  boolean getContextParamAbleToSetHttpStatusCode(boolean defaultValue)
           
 String[] getHeader(String name)
          Returns the value of the header with the specified name from the underlying HttpServletRequest.
 long getHttpServletRequestDateHeader(String name)
          Returns the value of the specified header name from the HttpServletRequest that is wrapped by the current PortletRequest.
 javax.faces.event.PhaseId getPhaseId()
           
 String getRequestParameter(String name)
          This is a convenience method that gets the specified request parameter value.
 String[] getRequestParameterValues(String name)
          This is a convenience method that gets the specified request parameter values.
 String getRequestQueryString()
          Gets the query string part of the URL requested by the user-agent (browser) by getting the attribute named "javax.servlet.forward.query_string" from the request.
 String getRequestURL()
          Returns the URL requested by the user-agent (browser).
 String getResponseNamespace()
          Returns the response namespace.
 boolean isAbleToAddScriptResourceToHead()
          Determines whether or not the portlet container has the ability (standard or vendor-specific) to add <script src=".." /> resource to the <head>...</head> section of the rendered portal page.
 boolean isAbleToAddScriptTextToHead()
          Determines whether or not the portlet container has the ability (standard or vendor-specific) to add <script> text to the <head>...</head> section of the rendered portal page.
 boolean isAbleToAddStyleSheetResourceToHead()
          Determines whether or not the portlet container has the ability (standard or vendor-specific) to add stylesheet <link> tags to the <head>...</head> section of the rendered portal page.
 boolean isAbleToForwardOnDispatch()
          Determines whether or not the portlet container has the ability to issue a forward when a dispatch occurs.
 boolean isAbleToSetHttpStatusCode()
          Determines whether or not the portlet container has the ability to support the Portlet 2.0 standard mechanism of setting the ResourceResponse.HTTP_STATUS_CODE property on the ResourceResponse.
 boolean isAbleToSetResourceResponseBufferSize()
          Determines whether or not the portlet container has the ability to set the buffer size on its javax.portlet.ResourceResponse implementation.
protected  boolean isMarkupHeadElementSupported()
          Determines whether or not the portlet container supports the standard Portlet 2.0 mechanism for adding resources to the ... section of the rendered portal page.
 boolean isNamespacedParameters()
          Determines whether or not the portlet container requires parameters to be namespaced.
 boolean isPostRedirectGetSupported()
          Flag indicating whether or not the portlet container supports/implements the POST-REDIRECT-GET design pattern, meaning that the ACTION_PHASE originates from an HTTP POST request, and the RENDER_PHASE is a subsequent HTTP GET request.
 void maintainRenderParameters(javax.portlet.EventRequest eventRequest, javax.portlet.EventResponse eventResponse)
          FACES-1453: Since EventResponse.setRenderParameters(EventRequest) would end up clobbering existing public/private render parameters, it is necessary to iterate through all of them and only maintain the ones that don't already exist in StateAwareResponse.getRenderParameterMap().
protected  List<RequestParameter> parseRequestParameters(String url)
          Parses the specified URL and returns a list of query parameters that are found.
 void redirect(String url)
          Delegates to the underlying ActionResponse to perform a redirect to the specified URL.
 void setMimeResponseContentType(javax.portlet.MimeResponse mimeResponse, String contentType)
          Layer of abstraction over the MimeResponse.setContentType(String) method.
 
Methods inherited from class com.liferay.faces.bridge.container.PortletContainerCompatImpl
getHeadResponseWriter, isJSF2PartialRequest, redirectJSF2PartialResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletContainerImpl

public PortletContainerImpl(javax.portlet.PortletRequest portletRequest,
                            BridgeConfig bridgeConfig)
Method Detail

afterPhase

public void afterPhase(javax.faces.event.PhaseEvent phaseEvent)

beforePhase

public void beforePhase(javax.faces.event.PhaseEvent event)

createActionURL

public javax.portlet.PortletURL createActionURL(String fromURL)
                                         throws MalformedURLException
Description copied from interface: PortletContainer
Creates a portlet action URL and copies query parameters that might be present in the specified URL.

Parameters:
fromURL - The URL to copy from.
Returns:
The resulting portlet action URL.
Throws:
MalformedURLException

createPartialActionURL

public javax.portlet.ResourceURL createPartialActionURL(String fromURL)
                                                 throws MalformedURLException
Description copied from interface: PortletContainer
Creates a portlet resource URL that is suitable for partial requests (Ajax).

Parameters:
fromURL - The URL to copy from.
Returns:
The resulting partial action resource URL.
Throws:
MalformedURLException

createRedirectURL

public javax.portlet.PortletURL createRedirectURL(String fromURL,
                                                  Map<String,List<String>> parameters)
                                           throws MalformedURLException
Note that this default method implementation doesn't help when a is present in the navigation-rule. That's because the JSF implementation will end up calling this method during the Portlet 2.0 ACTION_PHASE, and it's impossible for us to get a redirect URL (really, a render URL) from an ActionResponse. This method will need to be overridden for each portlet container and handled in a container-dependent way.

Parameters:
fromURL - The URL to copy from.
Returns:
The resulting portlet action URL.
Throws:
MalformedURLException

createRenderURL

public javax.portlet.PortletURL createRenderURL(String fromURL)
                                         throws MalformedURLException
Description copied from interface: PortletContainer
Creates a portlet render URL and copies query parameters that might be present in the specified URL.

Parameters:
fromURL - The URL to copy from.
Returns:
The resulting portlet action URL.
Throws:
MalformedURLException

createResourceURL

public javax.portlet.ResourceURL createResourceURL(String fromURL)
                                            throws MalformedURLException
Description copied from interface: PortletContainer
Creates a portlet resource URL and copies the javax.faces.resource value and query parameters that might be present in the specified URL.

Parameters:
fromURL - The URL to copy from. Example expected value: /portlet-context-path/*\/javax.faces.resource/jsf.js?ln=javax.faces
Returns:
The resulting portlet resource URL.
Throws:
MalformedURLException

fixRequestParameterValue

public String fixRequestParameterValue(String value)
Description copied from interface: PortletContainer
This method provides the portlet conainer with an opportunity to fix/correct/massage the specified request parameter value.

Parameters:
value - The request parameter value that needs to be fixed.
Returns:
The fixed value.

maintainRenderParameters

public void maintainRenderParameters(javax.portlet.EventRequest eventRequest,
                                     javax.portlet.EventResponse eventResponse)
FACES-1453: Since EventResponse.setRenderParameters(EventRequest) would end up clobbering existing public/private render parameters, it is necessary to iterate through all of them and only maintain the ones that don't already exist in StateAwareResponse.getRenderParameterMap().


redirect

public void redirect(String url)
              throws IOException
Description copied from interface: PortletContainer
Delegates to the underlying ActionResponse to perform a redirect to the specified URL.

Throws:
IOException

copyRequestParameters

protected void copyRequestParameters(String fromURL,
                                     javax.portlet.BaseURL toURL)
                              throws MalformedURLException
Copies any query paramters present in the specified "from" URL to the specified "to" URL.

Parameters:
fromURL - The String-based URL to copy query parameters from.
toURL - The portlet-based URL to copy query parameters to.
Throws:
MalformedURLException

createActionURL

protected javax.portlet.PortletURL createActionURL(javax.portlet.MimeResponse mimeResponse)

createRenderURL

protected javax.portlet.PortletURL createRenderURL(javax.portlet.MimeResponse mimeResponse)

createResourceURL

protected javax.portlet.ResourceURL createResourceURL(javax.portlet.MimeResponse mimeResponse)

parseRequestParameters

protected List<RequestParameter> parseRequestParameters(String url)
                                                 throws MalformedURLException
Parses the specified URL and returns a list of query parameters that are found.

Parameters:
url - The URL to parse.
Returns:
The list of query parameters found.
Throws:
MalformedURLException

getContextParamAbleToSetHttpStatusCode

protected boolean getContextParamAbleToSetHttpStatusCode(boolean defaultValue)

isAbleToAddScriptResourceToHead

public boolean isAbleToAddScriptResourceToHead()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability (standard or vendor-specific) to add <script src=".." /> resource to the <head>...</head> section of the rendered portal page.

Returns:
True if the portlet container supports it.

isAbleToAddScriptTextToHead

public boolean isAbleToAddScriptTextToHead()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability (standard or vendor-specific) to add <script> text to the <head>...</head> section of the rendered portal page.

Returns:
True if the portlet container supports it.

isAbleToAddStyleSheetResourceToHead

public boolean isAbleToAddStyleSheetResourceToHead()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability (standard or vendor-specific) to add stylesheet <link> tags to the <head>...</head> section of the rendered portal page.

Returns:
True if the portlet container supports it.

isPostRedirectGetSupported

public boolean isPostRedirectGetSupported()
Description copied from interface: PortletContainer
Flag indicating whether or not the portlet container supports/implements the POST-REDIRECT-GET design pattern, meaning that the ACTION_PHASE originates from an HTTP POST request, and the RENDER_PHASE is a subsequent HTTP GET request.

Returns:
true if the POST-REDIRECT-GET design pattern is supported, otherwise false.

isMarkupHeadElementSupported

protected boolean isMarkupHeadElementSupported()
Determines whether or not the portlet container supports the standard Portlet 2.0 mechanism for adding resources to the ... section of the rendered portal page. Section PLT.12.5.4 of the Portlet 2.0 spec indicates that this is an "optional" feature for vendors to implement.

Returns:
True if the portlet container supports the standard Portlet 2.0 mechanism for adding resources.

isAbleToSetHttpStatusCode

public boolean isAbleToSetHttpStatusCode()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability to support the Portlet 2.0 standard mechanism of setting the ResourceResponse.HTTP_STATUS_CODE property on the ResourceResponse.


isAbleToSetResourceResponseBufferSize

public boolean isAbleToSetResourceResponseBufferSize()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability to set the buffer size on its javax.portlet.ResourceResponse implementation.

Returns:
True if the portlet container supports it.

isAbleToForwardOnDispatch

public boolean isAbleToForwardOnDispatch()
Description copied from interface: PortletContainer
Determines whether or not the portlet container has the ability to issue a forward when a dispatch occurs. If unable to forward, then an include must happen during the dispatch instead.

Returns:
true if able, otherwise false.

getHeader

public String[] getHeader(String name)
Description copied from interface: PortletContainer
Returns the value of the header with the specified name from the underlying HttpServletRequest.


getHttpServletRequestDateHeader

public long getHttpServletRequestDateHeader(String name)
Description copied from interface: PortletContainer
Returns the value of the specified header name from the HttpServletRequest that is wrapped by the current PortletRequest.


setMimeResponseContentType

public void setMimeResponseContentType(javax.portlet.MimeResponse mimeResponse,
                                       String contentType)
Description copied from interface: PortletContainer
Layer of abstraction over the MimeResponse.setContentType(String) method.

contentType - The contentType that is to be set on the specified MimeResponse.

getPhaseId

public javax.faces.event.PhaseId getPhaseId()

getRequestParameter

public String getRequestParameter(String name)
Description copied from interface: PortletContainer
This is a convenience method that gets the specified request parameter value. While this could normally be done by simply calling PortletRequest.getParameter(String), this method provides the portlet container abstraction layer with an opportunity to fix/correct/massage the parameter value as required. Therefore, any implementing class of this method must call the PortletContainer.getRequestParameter(String) method before returning a value.

Parameters:
name - The request parameter name.
Returns:
The request parameter value.

getRequestParameterValues

public String[] getRequestParameterValues(String name)
Description copied from interface: PortletContainer
This is a convenience method that gets the specified request parameter values. While this could normally be done by simply calling PortletRequest.getParameterValues(String), this method provides the portlet container abstraction layer with an opportunity to fix/correct/massage the parameter values as required. Therefore, any implementing class of this method must call the PortletContainer.getRequestParameter(String) method before returning a value.

Parameters:
name - The request parameter name.
Returns:
The request parameter value.

getRequestQueryString

public String getRequestQueryString()
Description copied from interface: PortletContainer
Gets the query string part of the URL requested by the user-agent (browser) by getting the attribute named "javax.servlet.forward.query_string" from the request.

Returns:
The query_string part of the URL requested by the user-agent (browser).

getRequestURL

public String getRequestURL()
Description copied from interface: PortletContainer
Returns the URL requested by the user-agent (browser).


getResponseNamespace

public String getResponseNamespace()
Description copied from interface: PortletContainer
Returns the response namespace.


isNamespacedParameters

public boolean isNamespacedParameters()
Description copied from interface: PortletContainer
Determines whether or not the portlet container requires parameters to be namespaced.

Returns:
True if the portlet container requires parameters to be namespaced. Otherwise, returns false.


Copyright © 2014 Liferay, Inc.. All Rights Reserved.