atg.commerce.approval
Class ApprovalFormHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.commerce.approval.ApprovalFormHandler
All Implemented Interfaces:
atg.commerce.util.PipelineErrorHandler, DropletFormHandler, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
ApprovalFormHandler

public class ApprovalFormHandler
extends GenericFormHandler
implements atg.commerce.util.PipelineErrorHandler

This form handler is used in response to a request for an order approval. The handleApproveOrder method is called when an order should be approved and handleRejectOrder when an order is rejected for approval. The orderId property should be set to the order id which is to be approved or rejected. The approverMessage property is an optional property which can contain a message which will be added to the order when either of the two handle methods are called.


Field Summary
static java.lang.String CLASS_VERSION
           
protected static boolean FAILURE
           
protected static java.lang.String MSG_UNABLE_TO_APPROVE_ORDER
           
protected static java.lang.String MSG_UNABLE_TO_REJECT_ORDER
           
protected static boolean SUCCESS
           
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ApprovalFormHandler()
          Creates a new ApprovalFormHandler instance.
 
Method Summary
 void approveOrder(Order pOrder, RepositoryItem pProfile, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Runs the pipeline chain for approving the order and then handles the results.
 PipelineManager getApprovalPipelineManager()
          Returns property approvalPipelineManager
 java.lang.String getApprovedOrderState()
          Return the approvedOrderState property.
 java.lang.String getApproveOrderErrorURL()
          Return the approveOrderErrorURL property.
 java.lang.String getApproveOrderSuccessURL()
          Return the approveOrderSuccessURL property.
 java.lang.String getApproverMessage()
          Returns property approverMessage
protected  Order getOrder()
           
 java.lang.String getOrderApprovedChainId()
          Returns property orderApprovedChainId
 java.lang.String getOrderId()
          Return the orderId property.
 OrderManager getOrderManager()
          Return the orderManager property.
 java.lang.String getOrderRejectedChainId()
          Returns property orderRejectedChainId
 MutableRepository getOrderRepository()
          Returns property orderRepository
 OrderStates getOrderStates()
          Return the orderStates property.
 java.lang.String getRejectedOrderState()
          Return the rejectedOrderState property.
 java.lang.String getRejectOrderErrorURL()
          Return the rejectOrderErrorURL property.
 java.lang.String getRejectOrderSuccessURL()
          Return the rejectOrderSuccessURL property.
 javax.transaction.TransactionManager getTransactionManager()
          Return the TransactionManager property.
 java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns the locale associated with the request.
 boolean handleApproveOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void handlePipelineError(java.lang.Object pError, java.lang.String pErrorKey)
          Add a pipeline error to the list of form exceptions.
 boolean handleRejectOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 boolean isUseRequestLocale()
          Return the useRequestLocale property.
protected  Order loadOrder(java.lang.String pOrderId)
           
 void postApproveOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void postRejectOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void preApproveOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void preRejectOrder(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 void processException(java.lang.Exception pException, java.lang.String pMsgId, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Add a user error message to the form exceptions, and then display the exception in the logs
protected  boolean processPipelineErrors(PipelineResult pResult)
          Examine the pipeline result looking for any error messages, creates DropletFormExceptions and adds them as form exceptions
 void rejectOrder(Order pOrder, RepositoryItem pProfile, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Runs the pipeline chain for rejecting the order and then handles the results.
 void setApprovalPipelineManager(PipelineManager pApprovalPipelineManager)
          Sets property approvalPipelineManager
 void setApprovedOrderState(java.lang.String pApprovedOrderState)
          Set the approvedOrderState property.
 void setApproveOrderErrorURL(java.lang.String pApproveOrderErrorURL)
          Set the approveOrderErrorURL property.
 void setApproveOrderSuccessURL(java.lang.String pApproveOrderSuccessURL)
          Set the approveOrderSuccessURL property.
 void setApproverMessage(java.lang.String pApproverMessage)
          Sets property approverMessage
 void setOrderApprovedChainId(java.lang.String pOrderApprovedChainId)
          Sets property orderApprovedChainId
 void setOrderId(java.lang.String pOrderId)
          Set the orderId property.
 void setOrderManager(OrderManager pOrderManager)
          Set the orderManager property.
 void setOrderRejectedChainId(java.lang.String pOrderRejectedChainId)
          Sets property orderRejectedChainId
 void setOrderRepository(MutableRepository pOrderRepository)
          Sets property orderRepository
 void setOrderStates(OrderStates pOrderStates)
          Set the orderStates property.
 void setRejectedOrderState(java.lang.String pRejectedOrderState)
          Set the rejectedOrderState property.
 void setRejectOrderErrorURL(java.lang.String pRejectOrderErrorURL)
          Set the rejectOrderErrorURL property.
 void setRejectOrderSuccessURL(java.lang.String pRejectOrderSuccessURL)
          Set the rejectOrderSuccessURL property.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Set the TransactionManager property.
 void setUseRequestLocale(boolean pUseRequestLocale)
          Set the useRequestLocale property.
protected  void updateOrder(Order pOrder)
           
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, afterSet, beforeSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet, beforeGet
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

MSG_UNABLE_TO_APPROVE_ORDER

protected static final java.lang.String MSG_UNABLE_TO_APPROVE_ORDER
See Also:
Constant Field Values

MSG_UNABLE_TO_REJECT_ORDER

protected static final java.lang.String MSG_UNABLE_TO_REJECT_ORDER
See Also:
Constant Field Values

SUCCESS

protected static final boolean SUCCESS
See Also:
Constant Field Values

FAILURE

protected static final boolean FAILURE
See Also:
Constant Field Values
Constructor Detail

ApprovalFormHandler

public ApprovalFormHandler()
Creates a new ApprovalFormHandler instance.

Method Detail

getApprovalPipelineManager

public PipelineManager getApprovalPipelineManager()
Returns property approvalPipelineManager

Returns:
returns property approvalPipelineManager

setApprovalPipelineManager

public void setApprovalPipelineManager(PipelineManager pApprovalPipelineManager)
Sets property approvalPipelineManager

Parameters:
pApprovalPipelineManager - the value to set for property approvalPipelineManager

getOrderApprovedChainId

public java.lang.String getOrderApprovedChainId()
Returns property orderApprovedChainId

Returns:
returns property orderApprovedChainId

setOrderApprovedChainId

public void setOrderApprovedChainId(java.lang.String pOrderApprovedChainId)
Sets property orderApprovedChainId

Parameters:
pOrderApprovedChainId - the value to set for property orderApprovedChainId

getOrderRejectedChainId

public java.lang.String getOrderRejectedChainId()
Returns property orderRejectedChainId

Returns:
returns property orderRejectedChainId

setOrderRejectedChainId

public void setOrderRejectedChainId(java.lang.String pOrderRejectedChainId)
Sets property orderRejectedChainId

Parameters:
pOrderRejectedChainId - the value to set for property orderRejectedChainId

isUseRequestLocale

public boolean isUseRequestLocale()
Return the useRequestLocale property.

Returns:

setUseRequestLocale

public void setUseRequestLocale(boolean pUseRequestLocale)
Set the useRequestLocale property.

Parameters:
pUseRequestLocale -

getOrderManager

public OrderManager getOrderManager()
Return the orderManager property.

Returns:

setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Set the orderManager property.

Parameters:
pOrderManager -

getOrderStates

public OrderStates getOrderStates()
Return the orderStates property.

Returns:

setOrderStates

public void setOrderStates(OrderStates pOrderStates)
Set the orderStates property.

Parameters:
pOrderStates -

getApproveOrderSuccessURL

public java.lang.String getApproveOrderSuccessURL()
Return the approveOrderSuccessURL property.

Returns:

setApproveOrderSuccessURL

public void setApproveOrderSuccessURL(java.lang.String pApproveOrderSuccessURL)
Set the approveOrderSuccessURL property.

Parameters:
pApproveOrderSuccessURL -

getApproveOrderErrorURL

public java.lang.String getApproveOrderErrorURL()
Return the approveOrderErrorURL property.

Returns:

setApproveOrderErrorURL

public void setApproveOrderErrorURL(java.lang.String pApproveOrderErrorURL)
Set the approveOrderErrorURL property.

Parameters:
pApproveOrderErrorURL -

getRejectOrderSuccessURL

public java.lang.String getRejectOrderSuccessURL()
Return the rejectOrderSuccessURL property.

Returns:

setRejectOrderSuccessURL

public void setRejectOrderSuccessURL(java.lang.String pRejectOrderSuccessURL)
Set the rejectOrderSuccessURL property.

Parameters:
pRejectOrderSuccessURL -

getRejectOrderErrorURL

public java.lang.String getRejectOrderErrorURL()
Return the rejectOrderErrorURL property.

Returns:

setRejectOrderErrorURL

public void setRejectOrderErrorURL(java.lang.String pRejectOrderErrorURL)
Set the rejectOrderErrorURL property.

Parameters:
pRejectOrderErrorURL -

getApprovedOrderState

public java.lang.String getApprovedOrderState()
Return the approvedOrderState property.

Returns:

setApprovedOrderState

public void setApprovedOrderState(java.lang.String pApprovedOrderState)
Set the approvedOrderState property.

Parameters:
pApprovedOrderState -

getRejectedOrderState

public java.lang.String getRejectedOrderState()
Return the rejectedOrderState property.

Returns:

setRejectedOrderState

public void setRejectedOrderState(java.lang.String pRejectedOrderState)
Set the rejectedOrderState property.

Parameters:
pRejectedOrderState -

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Return the TransactionManager property.

Returns:

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Set the TransactionManager property.

Parameters:
pTransactionManager -

getOrderRepository

public MutableRepository getOrderRepository()
Returns property orderRepository

Returns:
returns property orderRepository

setOrderRepository

public void setOrderRepository(MutableRepository pOrderRepository)
Sets property orderRepository

Parameters:
pOrderRepository - the value to set for property orderRepository

getOrderId

public java.lang.String getOrderId()
Return the orderId property.

Returns:

setOrderId

public void setOrderId(java.lang.String pOrderId)
Set the orderId property.

Parameters:
pOrderId -

getApproverMessage

public java.lang.String getApproverMessage()
Returns property approverMessage

Returns:
returns property approverMessage

setApproverMessage

public void setApproverMessage(java.lang.String pApproverMessage)
Sets property approverMessage

Parameters:
pApproverMessage - the value to set for property approverMessage

preApproveOrder

public void preApproveOrder(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

postApproveOrder

public void postApproveOrder(DynamoHttpServletRequest pRequest,
                             DynamoHttpServletResponse pResponse)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

approveOrder

public void approveOrder(Order pOrder,
                         RepositoryItem pProfile,
                         DynamoHttpServletRequest pRequest,
                         DynamoHttpServletResponse pResponse)
                  throws java.io.IOException,
                         javax.servlet.ServletException
Runs the pipeline chain for approving the order and then handles the results.

Parameters:
pOrder - The order to approve.
pProfile - The owner of the order.
pRequest -
pResponse -
Throws:
java.io.IOException
javax.servlet.ServletException

handleApproveOrder

public boolean handleApproveOrder(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
                           throws java.io.IOException,
                                  javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

preRejectOrder

public void preRejectOrder(DynamoHttpServletRequest pRequest,
                           DynamoHttpServletResponse pResponse)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

postRejectOrder

public void postRejectOrder(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

rejectOrder

public void rejectOrder(Order pOrder,
                        RepositoryItem pProfile,
                        DynamoHttpServletRequest pRequest,
                        DynamoHttpServletResponse pResponse)
                 throws java.io.IOException,
                        javax.servlet.ServletException
Runs the pipeline chain for rejecting the order and then handles the results.

Parameters:
pOrder - The order to reject.
pProfile - The owner of the order.
pRequest -
pResponse -
Throws:
java.io.IOException
javax.servlet.ServletException

handleRejectOrder

public boolean handleRejectOrder(DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse)
                          throws java.io.IOException,
                                 javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

getOrder

protected Order getOrder()
                  throws CommerceException
Throws:
CommerceException

loadOrder

protected Order loadOrder(java.lang.String pOrderId)
                   throws CommerceException
Throws:
CommerceException

updateOrder

protected void updateOrder(Order pOrder)
                    throws CommerceException
Throws:
CommerceException

processException

public void processException(java.lang.Exception pException,
                             java.lang.String pMsgId,
                             DynamoHttpServletRequest pRequest,
                             DynamoHttpServletResponse pResponse)
                      throws javax.servlet.ServletException,
                             java.io.IOException
Add a user error message to the form exceptions, and then display the exception in the logs

Throws:
javax.servlet.ServletException
java.io.IOException

getUserLocale

public java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest,
                                      DynamoHttpServletResponse pResponse)
                               throws javax.servlet.ServletException,
                                      java.io.IOException
Returns the locale associated with the request. The method first searches for a request paramater named locale. This value can be either a java.util.Locale object or a String which represents the locale. Next if the useRequestLocale property is true, then the locale of the request will be returned. Finally, if the locale cannot be determined, the the defaultLocale property is used.

Throws:
javax.servlet.ServletException
java.io.IOException

handlePipelineError

public void handlePipelineError(java.lang.Object pError,
                                java.lang.String pErrorKey)
Add a pipeline error to the list of form exceptions.

Specified by:
handlePipelineError in interface atg.commerce.util.PipelineErrorHandler
Parameters:
pError - the error reported by the pipeline.
pErrorKey - the key of the error, used for localization.

processPipelineErrors

protected boolean processPipelineErrors(PipelineResult pResult)
Examine the pipeline result looking for any error messages, creates DropletFormExceptions and adds them as form exceptions

Parameters:
pResult - a PipelineResult value
Returns:
true if errors were found