Class BaseRequestProcessor

java.lang.Object
org.apache.struts.action.RequestProcessor
org.apache.struts.tiles.TilesRequestProcessor
com.softslate.commerce.customer.core.BaseRequestProcessor
Direct Known Subclasses:
com.softslate.commerce.customer.core.CheckEERequestProcessor, InstallerRequestProcessor

public class BaseRequestProcessor extends org.apache.struts.tiles.TilesRequestProcessor
Subclass of TilesRequestProcessor that negotiates each application request. The subclasses of this class, CustomerRequestProcessor and AdministratorRequestProcessor, are specified in the <controller> tags of the struts-config.xml files, as the request processors for the customer and adminstrator applications respectively.
Author:
David Tobey
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    Path to forward the request to if an error occurs when connecting to the database.
    static String
    Path to forward the request to if the installer is not locked.
    (package private) static org.apache.commons.logging.Log
     

    Fields inherited from class org.apache.struts.tiles.TilesRequestProcessor

    definitionsFactory

    Fields inherited from class org.apache.struts.action.RequestProcessor

    actions, INCLUDE_PATH_INFO, INCLUDE_SERVLET_PATH, moduleConfig, servlet
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.common.eventbus.EventBus
    createEventBus(javax.servlet.http.HttpServletRequest request)
     
    com.google.inject.Injector
    createGuiceInjector(javax.servlet.http.HttpServletRequest request)
     
    protected void
    doForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Overrides the regular forward to use the user's custom layout.
     
    getRequestParamsDebugMessage(javax.servlet.http.HttpServletRequest request)
    Given a request object, converts all the incoming parameters to a string for debugging.
    void
    initializeEventBus(com.google.common.eventbus.EventBus eventBus, javax.servlet.http.HttpServletRequest request)
     
    com.google.inject.Injector
    initializeGuice(javax.servlet.http.HttpServletRequest request)
     
    protected void
    internalModuleRelativeForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
     
    void
    process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
     
    void
    processAuditLogging(javax.servlet.http.HttpServletRequest request)
    Create log entries in the application's audit logs, containing all the key information about each request.
    protected org.apache.struts.action.ActionForward
    processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
     
    protected void
    processForwardConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.config.ForwardConfig forward)
     
    protected boolean
    processPreprocess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Runs initializations and other necessary routines before every request.
    boolean
    sscOnPreRequestBegin(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Performs custom processing at the beginning of each call to processPreProcess.
    boolean
    sscOnPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Performs custom processing at the end of each call to processPreProcess.
    boolean
    sscOnPreRequestMiddle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Performs custom processing in the middle of each call to processPreProcess, directly after the daoFactory has been initialized.

    Methods inherited from class org.apache.struts.tiles.TilesRequestProcessor

    getDefinitionsFactory, init, initDefinitionsMapping, internalModuleRelativeInclude, processTilesDefinition, processTilesDefinition

    Methods inherited from class org.apache.struts.action.RequestProcessor

    destroy, doInclude, getInternal, getServletContext, processActionCreate, processActionForm, processActionPerform, processCachedMessages, processContent, processForward, processInclude, processLocale, processMapping, processMultipart, processNoCache, processPath, processPopulate, processRoles, processValidate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      static org.apache.commons.logging.Log log
    • installerPath

      public static String installerPath
      Path to forward the request to if the installer is not locked. This value is /installer/Installer.do.
    • errorPath

      public static String errorPath
      Path to forward the request to if an error occurs when connecting to the database. By default this value is /installer/Installer.do.
  • Constructor Details

    • BaseRequestProcessor

      public BaseRequestProcessor()
  • Method Details

    • processPreprocess

      protected boolean processPreprocess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Runs initializations and other necessary routines before every request.

      Here are the steps this method takes for each request:

      1. Calls sscOnPreRequestBegin(), which can be overridden by a subclass to provide customizations.
      2. If the appSettings or appComponents objects do not exist in the application scope, initializes them.
      3. If a BusinessObjectFactory does not exist in the request scope, initializes a new one.
      4. If a DAOFactory does not exist in the application scope, initializes a new one, including initializing Hibernate.
      5. Assigns the application scope's DAOFactory to the request's BusinessObjectFactory.
      6. If a Settings instance does not exist in the application scope, initializes a new one in the application and request scope, and assigns it to the application's DAOFactory and the request's BusinessObjectFactory.
      7. If a User does not exist in the session scope, or if the user's order has just been placed or has been corrupted somehow, initializes a new one in the session scope.
      8. Assigns the session scope's User to the request's BusinessObjectFactory.
      9. If the store's categoryTree, builtInCategories or statesAndCountries attributes do not exist in the application scope, initializes them using ProductInitializer and OrderInitializer.
      10. Calls sscOnPreRequestEnd(), which can be overridden by a subclass to provide customizations.
      Overrides:
      processPreprocess in class org.apache.struts.action.RequestProcessor
      Parameters:
      request - The servlet request we are processing.
      response - The servlet response we are creating.
    • createEventBus

      public com.google.common.eventbus.EventBus createEventBus(javax.servlet.http.HttpServletRequest request)
    • initializeEventBus

      public void initializeEventBus(com.google.common.eventbus.EventBus eventBus, javax.servlet.http.HttpServletRequest request)
    • initializeGuice

      public com.google.inject.Injector initializeGuice(javax.servlet.http.HttpServletRequest request)
    • createGuiceInjector

      public com.google.inject.Injector createGuiceInjector(javax.servlet.http.HttpServletRequest request)
    • sscOnPreRequestBegin

      public boolean sscOnPreRequestBegin(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Performs custom processing at the beginning of each call to processPreProcess. It is intended to be overridden by subclasses for customizations. This method should return false to signal processPreProcess to stop futher processing and return false itself.
      Parameters:
      request - The servlet request we are processing.
      response - The servlet response we are creating.
      Returns:
      true if the processing was successful, false if processing in the request should stop.
    • sscOnPreRequestMiddle

      public boolean sscOnPreRequestMiddle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Performs custom processing in the middle of each call to processPreProcess, directly after the daoFactory has been initialized. It is intended to be overridden by subclasses for customizations. This method should return false to signal processPreProcess to stop futher processing and return false itself.
      Parameters:
      request - The servlet request we are processing.
      response - The servlet response we are creating.
      Returns:
      true if the processing was successful, false if processing in the request should stop.
    • sscOnPreRequestEnd

      public boolean sscOnPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Performs custom processing at the end of each call to processPreProcess. This method should return false to signal processPreProcess to return false itself.
      Parameters:
      request - The servlet request we are processing.
      response - The servlet response we are creating.
      Returns:
      true if the processing was successful, false if processing should stop.
    • process

      public void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
      Overrides:
      process in class org.apache.struts.action.RequestProcessor
      Throws:
      IOException
      javax.servlet.ServletException
    • processException

      protected org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping) throws IOException, javax.servlet.ServletException
      Overrides:
      processException in class org.apache.struts.action.RequestProcessor
      Throws:
      IOException
      javax.servlet.ServletException
    • getExceptionAsString

      public String getExceptionAsString(Throwable exception)
    • processForwardConfig

      protected void processForwardConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.config.ForwardConfig forward) throws IOException, javax.servlet.ServletException
      Overrides:
      processForwardConfig in class org.apache.struts.tiles.TilesRequestProcessor
      Throws:
      IOException
      javax.servlet.ServletException
    • internalModuleRelativeForward

      protected void internalModuleRelativeForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
      Overrides:
      internalModuleRelativeForward in class org.apache.struts.tiles.TilesRequestProcessor
      Throws:
      IOException
      javax.servlet.ServletException
    • doForward

      protected void doForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
      Overrides the regular forward to use the user's custom layout. Replaces pages matching the system layout directory with the user's custom layout directory. If the resulting page doesn't map to an existing file, uses the original instead.

      This method affects the forwards to the Tiles definitions for leftLayout, centerLayout, and layout. The same process happens in AppInsertTag to handle forwards coming from tiles insert tags.

      Overrides:
      doForward in class org.apache.struts.tiles.TilesRequestProcessor
      Parameters:
      uri - The URI we're forwarding the request to, which may be modified in this method.
      request - The servlet request we are processing.
      response - The servlet response we are creating.
      Throws:
      IOException
      javax.servlet.ServletException
    • getRequestParamsDebugMessage

      public String getRequestParamsDebugMessage(javax.servlet.http.HttpServletRequest request)
      Given a request object, converts all the incoming parameters to a string for debugging. The values of certain parameters such as passwords are masked for security.
      Parameters:
      request - The current request object.
      Returns:
      A String representing the name value pairs of the request parameters.
    • processAuditLogging

      public void processAuditLogging(javax.servlet.http.HttpServletRequest request)
      Create log entries in the application's audit logs, containing all the key information about each request.
      Parameters:
      request - The current request object.