com.ibm.portal.struts.portlet
Class WpRequestProcessor

java.lang.Object
  extended by RequestProcessor
      extended by com.ibm.portal.struts.portlet.WpRequestProcessor
Direct Known Subclasses:
WpTilesRequestProcessor

public class WpRequestProcessor
extends RequestProcessor

WpRequestProcessor contains the processing logic that the Struts controller portlet performs as it receives each request from the container. The WpRequestProcessor is a customized version of the base Struts RequestProcessor to allow the Struts application to execute in Portal. This class or subclasses must be the Struts request processor used for Struts applications in portal. The WpRequestProcessor class can be extended to support customizing the Struts processing in Portal, but the super method implementations should be invoked.

Since:
5.1

Field Summary
protected static Log log
          Commons Logging instance for this class
protected static MessageResources messages
          The message resources for the Struts Portlet Framework.
 
Constructor Summary
WpRequestProcessor()
          WpRequestProcessor constructor
 
Method Summary
protected  void doForward(java.lang.String uri, HttpServletRequest request, HttpServletResponse response)
          Forwards are not directly supported in Portal.
protected  void doInclude(java.lang.String uri, HttpServletRequest request, HttpServletResponse response)
          Do an include of specified uri.
 java.lang.String getApplicationPrefix()
          Get the application prefix associated with this command processor.
protected  ModuleContext getModuleContext()
          Return the module context object
protected  ServletContext getServletContext()
          Returns the servlet context object
 StrutsInfo getStrutsInfo()
          Get the StrutsInfo object associated with this command processor.
 void init(ActionServlet servlet, ModuleConfig moduleConfig)
          Initialize this request processor instance.
protected  ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping)
          Ask the specified Action instance to handle this request.
protected  void processContent(HttpServletRequest request, HttpServletResponse response)
          Override the default function to do nothing since we set the content type elsewhere.
protected  ActionForward processException(HttpServletRequest request, HttpServletResponse response, java.lang.Exception exception, ActionForm form, ActionMapping mapping)
          This implementation calls the super implementation.
protected  void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward)
          This implementation will process the ForwardConfig and then call doFoward.
protected  ActionMapping processMapping(HttpServletRequest request, HttpServletResponse response, java.lang.String path)
          Calls the super processMapping implementation.
protected  HttpServletRequest processMultipart(HttpServletRequest request)
          If this is a multipart request, wrap it with a special wrapper.
static void processNewActionUri(java.lang.String uri, PortletRequest request, PortletResponse response, ServletContext servletContext)
          This method will implement the necessary steps to simulate a forward to a Struts Action.
protected  void processNoCache(HttpServletRequest request, HttpServletResponse response)
          This method does not call the Struts Request Processor processNoCache implementation.
protected  void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping)
          Calls the inherited processPopulate.
protected  boolean processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
          This method will call the super implementation for processing J2EE roles.
protected  java.lang.String processUri(HttpServletRequest request, HttpServletResponse response)
          Identify and return the path component from the request URI.
 void setServletContext(ServletContext sContext)
          Set the servlet context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected static MessageResources messages
The message resources for the Struts Portlet Framework.


log

protected static Log log
Commons Logging instance for this class

Constructor Detail

WpRequestProcessor

public WpRequestProcessor()
WpRequestProcessor constructor

Method Detail

processMultipart

protected HttpServletRequest processMultipart(HttpServletRequest request)
If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.

Parameters:
request - The HttpServletRequest we are processing
Returns:
returns a wrapper request object if needed

init

public void init(ActionServlet servlet,
                 ModuleConfig moduleConfig)
          throws ServletException
Initialize this request processor instance.

Parameters:
servlet - The ActionServlet we are associated with
moduleConfig - The ModuleConfig we are associated with.
Throws:
ServletException - If an error occor during initialization

getModuleContext

protected ModuleContext getModuleContext()
Return the module context object

Returns:
returns the module context

processActionPerform

protected ActionForward processActionPerform(HttpServletRequest request,
                                             HttpServletResponse response,
                                             Action action,
                                             ActionForm form,
                                             ActionMapping mapping)
                                      throws java.io.IOException,
                                             ServletException
Ask the specified Action instance to handle this request. Return the ActionForward instance (if any) returned by the called Action for further processing. This implementation will also check for the Portal friendly StrutsAction class and call the execute method with the portlet objects instead of the http servlet interfaces.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
action - The Action instance to be used
form - The ActionForm instance to pass to this Action
mapping - The ActionMapping instance to pass to this Action
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

processForwardConfig

protected void processForwardConfig(HttpServletRequest request,
                                    HttpServletResponse response,
                                    ForwardConfig forward)
                             throws java.io.IOException,
                                    ServletException
This implementation will process the ForwardConfig and then call doFoward. Redirects are not supported, and instead are handled as a forward. The path is modified as necessary depending on the context relative setting and the path is then passed into doForward.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
forward - The ActionForward controlling where we go next
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

processException

protected ActionForward processException(HttpServletRequest request,
                                         HttpServletResponse response,
                                         java.lang.Exception exception,
                                         ActionForm form,
                                         ActionMapping mapping)
                                  throws java.io.IOException,
                                         ServletException
This implementation calls the super implementation. If the exception is not handled and is a WpsStrutsException then response.sendError with the exception information is called.

Parameters:
request - The servlet request we are processing
response - The servlet response we are processing
exception - The exception being handled
form - The ActionForm we are processing
mapping - The ActionMapping we are using
Returns:
returns the ActionForward, can be null
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

processMapping

protected ActionMapping processMapping(HttpServletRequest request,
                                       HttpServletResponse response,
                                       java.lang.String path)
                                throws java.io.IOException
Calls the super processMapping implementation. Then the ActionMapping type is checked to see if the Action implements the IStrutsPrepareRender interface. If so the Request Processor processing stops.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
path - The portion of the request URI for selecting a mapping
Returns:
returns the action mapping, can be null
Throws:
java.io.IOException - if an input/output error occurs

processNoCache

protected void processNoCache(HttpServletRequest request,
                              HttpServletResponse response)
This method does not call the Struts Request Processor processNoCache implementation. This method is a nop in Portal

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating

doForward

protected void doForward(java.lang.String uri,
                         HttpServletRequest request,
                         HttpServletResponse response)
                  throws java.io.IOException,
                         ServletException
Forwards are not directly supported in Portal. This implementation calls doInclude.

Parameters:
uri - Uri or Definition name to forward
request - Current page request
response - Current page response
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

doInclude

protected void doInclude(java.lang.String uri,
                         HttpServletRequest request,
                         HttpServletResponse response)
                  throws java.io.IOException,
                         ServletException
Do an include of specified uri. This implementation will include files, or recursively call the RequestProcessor for Struts actions.

Parameters:
uri - Uri of page to include
request - Current page request
response - Current page response
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

processNewActionUri

public static void processNewActionUri(java.lang.String uri,
                                       PortletRequest request,
                                       PortletResponse response,
                                       ServletContext servletContext)
                                throws java.io.IOException,
                                       ServletException
This method will implement the necessary steps to simulate a forward to a Struts Action. The appropriate Request Processor is looked up and the process method is called. The URI is the path for the Struts Action and can contain a query string. If the URI is not a path for a Struts Action, then the URI will be passed to the ViewCommandFactory.

Parameters:
uri - the new URI
request - the request
response - the response
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

setServletContext

public void setServletContext(ServletContext sContext)
Set the servlet context

Parameters:
sContext - the servlet context object

getServletContext

protected ServletContext getServletContext()
Returns the servlet context object

Returns:
returns the servlet context object, can be null if not set

getStrutsInfo

public StrutsInfo getStrutsInfo()
Get the StrutsInfo object associated with this command processor.

Returns:
returns the Struts Info object

getApplicationPrefix

public java.lang.String getApplicationPrefix()
Get the application prefix associated with this command processor.

Returns:
application prefix, can be null

processRoles

protected boolean processRoles(HttpServletRequest request,
                               HttpServletResponse response,
                               ActionMapping mapping)
                        throws java.io.IOException,
                               ServletException
This method will call the super implementation for processing J2EE roles. If the application was configured to use Portal Groups instead then the ActionMapping roles are compared to the user's Portal groups.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
mapping - The mapping we are using
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet exception occurs

processPopulate

protected void processPopulate(HttpServletRequest request,
                               HttpServletResponse response,
                               ActionForm form,
                               ActionMapping mapping)
                        throws ServletException
Calls the inherited processPopulate. If file upload is used and the max length exceeded is detected then this method will get the request input stream and reads the byte stream.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
form - The ActionForm instance we are populating
mapping - The ActionMapping we are using
Throws:
ServletException - if thrown by RequestUtils.populate()

processUri

protected java.lang.String processUri(HttpServletRequest request,
                                      HttpServletResponse response)
                               throws java.io.IOException
Identify and return the path component from the request URI. The path will include the extension mapping. If no such path can be identified, create an error response and return null.

Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
Throws:
java.io.IOException - if an input/output error occurs

processContent

protected void processContent(HttpServletRequest request,
                              HttpServletResponse response)
Override the default function to do nothing since we set the content type elsewhere.

See Also:
StrutsViewCommand.execute(RenderRequest, RenderResponse, ViewCommandExecutionContext), org.apache.struts.action.RequestProcessor#processContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)