com.softslate.commerce.customer.core
Class BaseRequestProcessor

java.lang.Object
  extended by org.apache.struts.action.RequestProcessor
      extended by org.apache.struts.tiles.TilesRequestProcessor
          extended by com.softslate.commerce.customer.core.BaseRequestProcessor
Direct Known Subclasses:
AdministratorRequestProcessor, CheckRequestProcessor, 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
static java.lang.String errorPath
          Path to forward the request to if an error occurs when connecting to the database.
static java.lang.String installerPath
          Path to forward the request to if the installer is not locked.
(package private) static org.apache.commons.logging.Log 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
BaseRequestProcessor()
           
 
Method Summary
protected  void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Overrides the regular forward to use the user's custom layout.
 java.lang.String getExceptionAsString(java.lang.Throwable exception)
          Recursively loops through a given exception and its causes, and returns a string containing all of the chained exceptions' stack traces.
 java.lang.String getRequestParamsDebugMessage(javax.servlet.http.HttpServletRequest request)
          Given a request object, converts all the incoming parameters to a string for debugging.
protected  org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
          Overrides the default processException method to ensure all handled exceptions are logged in the application log file.
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, internalModuleRelativeForward, internalModuleRelativeInclude, processForwardConfig, processTilesDefinition
 
Methods inherited from class org.apache.struts.action.RequestProcessor
destroy, doInclude, getInternal, getServletContext, log, log, process, 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 Detail

log

static org.apache.commons.logging.Log log

installerPath

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


errorPath

public static java.lang.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 Detail

BaseRequestProcessor

public BaseRequestProcessor()
Method Detail

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.

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.

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.

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.

Returns:
true if the processing was successful, false if processing should stop.

processException

protected org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request,
                                                                  javax.servlet.http.HttpServletResponse response,
                                                                  java.lang.Exception exception,
                                                                  org.apache.struts.action.ActionForm form,
                                                                  org.apache.struts.action.ActionMapping mapping)
                                                           throws java.io.IOException,
                                                                  javax.servlet.ServletException
Overrides the default processException method to ensure all handled exceptions are logged in the application log file. There should be no unhandled exceptions originating in a Struts action, unless the struts-config.xml file is changed to eliminate the global exception configuration for java.lang.Exception. (It is also possible for an exception to be thrown to the servlet container in this method, if one happens in the course of the exception handling itself.)

Overrides:
processException in class org.apache.struts.action.RequestProcessor
Throws:
java.io.IOException
javax.servlet.ServletException

getExceptionAsString

public java.lang.String getExceptionAsString(java.lang.Throwable exception)
Recursively loops through a given exception and its causes, and returns a string containing all of the chained exceptions' stack traces. Used for logging exceptions.


doForward

protected void doForward(java.lang.String uri,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.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
Throws:
java.io.IOException
javax.servlet.ServletException

getRequestParamsDebugMessage

public java.lang.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.


Copyright ? SoftSlate, LLC 2003?2005