com.ibm.wps.portlets.struts
Class WpsRequestProcessor

java.lang.Object
  extended by RequestProcessor
      extended by com.ibm.wps.portlets.struts.WpsRequestProcessor

public class WpsRequestProcessor
extends RequestProcessor

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

Since:
4.1

Field Summary
protected static Log log
          The commons-logging instance for this class.
protected static MessageResources messages
          The message resources for the Struts Portlet Framework.
 
Constructor Summary
WpsRequestProcessor()
          WpsRequestProcessor constructor.
 
Method Summary
protected  void doForward(java.lang.String uri, HttpServletRequest request, HttpServletResponse response)
          Calls doInclude.
protected  void doInclude(java.lang.String uri, HttpServletRequest request, HttpServletResponse response)
          Includes a specified URI.
 java.lang.String getApplicationPrefix()
          Gets the application prefix associated with this command processor.
protected  ModuleContext getModuleContext()
          Returns the module context object.
protected  ServletContext getServletContext()
          Returns the servlet context object.
 WpsStrutsInfo getStrutsInfo()
          Gets the WpsStrutsInfo object associated with this command processor.
 void init(ActionServlet servlet, ModuleConfig moduleConfig)
          Initializes this request processor instance.
protected  ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping)
          Asks the specified Action instance to handle this request.
protected  ActionForward processException(HttpServletRequest request, HttpServletResponse response, java.lang.Exception exception, ActionForm form, ActionMapping mapping)
          Calls the super implementation.
protected  void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward)
          Processes the ForwardConfig and then calls 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, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Simulates a forward to a Struts action.
protected  void processNoCache(HttpServletRequest request, HttpServletResponse response)
          This method is overridden so that the Struts request processor processNoCache method is not called.
protected  void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping)
          Calls the inherited processPopulate.
protected  boolean processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
          Calls the super implementation for processing J2EE roles.
protected  java.lang.String processUri(HttpServletRequest request, HttpServletResponse response)
          Identifies and returns the path component from the request URI.
 void ServletContext)">setServletContext(ServletContext sContext)
          Sets 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
The commons-logging instance for this class.

Constructor Detail

WpsRequestProcessor

public WpsRequestProcessor()
WpsRequestProcessor 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:
HttpServletRequest the wrappered request object if a multipart request

init

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

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

getModuleContext

protected ModuleContext getModuleContext()
Returns the module context object.

Returns:
returns the ModuleContext object

processActionPerform

protected ActionForward processActionPerform(HttpServletRequest request,
                                             HttpServletResponse response,
                                             Action action,
                                             ActionForm form,
                                             ActionMapping mapping)
                                      throws java.io.IOException,
                                             ServletException
Asks 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
Processes the ForwardConfig and then calls 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
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
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. It then checks the ActionMapping type 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
Throws:
java.io.IOException - if an input/output error occurs

processNoCache

protected void processNoCache(HttpServletRequest request,
                              HttpServletResponse response)
This method is overridden so that the Struts request processor processNoCache method is not called. This method is a no-op 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
Calls doInclude. Forwards are not directly supported in Portal.

Parameters:
uri - Uri or Definition name to forward
request - Current page request
response - Current page response
Throws:
java.io.IOException
ServletException

doInclude

protected void doInclude(java.lang.String uri,
                         HttpServletRequest request,
                         HttpServletResponse response)
                  throws java.io.IOException,
                         ServletException
Includes a specified URI. This implementation includes files, or recursively calls the RequestProcessor for Struts actions.

Parameters:
uri - Uri of page to include
request - Current page request
response - Current page response
Throws:
java.io.IOException
ServletException

processNewActionUri

public static void processNewActionUri(java.lang.String uri,
                                       HttpServletRequest request,
                                       HttpServletResponse response,
                                       ServletContext servletContext)
                                throws java.io.IOException,
                                       ServletException
Simulates 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
ServletException

ServletContext)">

setServletContext

public void setServletContext(ServletContext sContext)
Sets 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 WpsStrutsInfo getStrutsInfo()
Gets the WpsStrutsInfo object associated with this command processor.

Returns:
returns the WpsStrutsInfo object

getApplicationPrefix

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

Returns:
returns the application prefix, can be null

processRoles

protected boolean processRoles(HttpServletRequest request,
                               HttpServletResponse response,
                               ActionMapping mapping)
                        throws java.io.IOException,
                               ServletException
Calls 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 maximum length is exceeded then this method gets 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
Identifies and returns the path component from the request URI. The path includes the extension mapping. If no such path can be identified, it creates an error response and returns 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