atg.commerce.promotion
Class CouponFormHandler

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.promotion.CouponFormHandler
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class CouponFormHandler
extends GenericFormHandler

This FormHandler is used to "claim" a promotion and then stick this promotion into the users current list of promotions. The idea is that a coupon is just another mechanism to deliver a promotion to the user, i.e. they explicitly obtain the promotion by entering a coupon claim number and then obtaining the promotion.

The handleClaimCoupon method is responsible for actually doing the work and obtaining the promotion.

See Also:
PromotionTools, ClaimableTools

Field Summary
static java.lang.String CLASS_VERSION
           
 
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
CouponFormHandler()
          Empty Constructor
 
Method Summary
 boolean checkPromotionType(RepositoryItem pPromotion)
          Checks to see if the type of the promotion is valid.
protected  void claimCoupon(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Claim the coupon.
 ClaimableManager getClaimableManager()
          Return the ClaimableManager property.
 ClaimableTools getClaimableTools()
          Return the ClaimableTools property.
 java.lang.String getClaimCouponErrorURL()
          Return the claimCouponErrorURL property.
 java.lang.String getClaimCouponSuccessURL()
          Return the claimCouponSuccessURL property.
 java.lang.String getCouponClaimCode()
          Return the couponClaimCode property.
 Profile getProfile()
          Return the Profile property.
 PromotionTools getPromotionTools()
          Return the PromotionTools property.
 javax.transaction.TransactionManager getTransactionManager()
          Return the TransactionManager property.
 java.lang.String getTransactionType()
          Return the TransactionType property.
protected  java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest)
          Obtain the users locale by examining the request object first and then getting the default Locale object.
 java.lang.String[] getValidCouponItemTypes()
          The list of acceptable item types for promotions when claiming a coupon.
 boolean handleClaimCoupon(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Method that is invoked to claim a coupon.
protected  void processError(java.lang.String pErrorCodeId, java.lang.Exception e, DynamoHttpServletRequest pRequest)
          If an error occurs, this method will obtain the correct Msg resource string based upon the users locale from the getUserLocale method.
 void setClaimableManager(ClaimableManager pClaimableManager)
          Set the ClaimableManager property.
 void setClaimableTools(ClaimableTools pClaimableTools)
          Set the ClaimableTools property.
 void setClaimCouponErrorURL(java.lang.String pClaimCouponErrorURL)
          Set the claimCouponErrorURL property.
 void setClaimCouponSuccessURL(java.lang.String pClaimCouponSuccessURL)
          Set the claimCouponSuccessURL property.
 void setCouponClaimCode(java.lang.String pCouponClaimCode)
          Set the couponClaimCode property.
 void setProfile(Profile pProfile)
          Set the Profile property.
 void setPromotionTools(PromotionTools pPromotionTools)
          Set the PromotionTools property.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Set the TransactionManager property.
 void setTransactionType(java.lang.String pTransactionType)
          Set the TransactionType property.
 void setValidCouponItemTypes(java.lang.String[] pValidCouponItemTypes)
           
 
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, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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
Constructor Detail

CouponFormHandler

public CouponFormHandler()
Empty Constructor

Method Detail

setTransactionManager

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


getTransactionManager

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


setTransactionType

public void setTransactionType(java.lang.String pTransactionType)
Set the TransactionType property.


getTransactionType

public java.lang.String getTransactionType()
Return the TransactionType property.


setClaimableTools

public void setClaimableTools(ClaimableTools pClaimableTools)
Set the ClaimableTools property.


getClaimableTools

public ClaimableTools getClaimableTools()
Return the ClaimableTools property.


setClaimCouponSuccessURL

public void setClaimCouponSuccessURL(java.lang.String pClaimCouponSuccessURL)
Set the claimCouponSuccessURL property.


getClaimCouponSuccessURL

public java.lang.String getClaimCouponSuccessURL()
Return the claimCouponSuccessURL property.


setClaimCouponErrorURL

public void setClaimCouponErrorURL(java.lang.String pClaimCouponErrorURL)
Set the claimCouponErrorURL property.


getClaimCouponErrorURL

public java.lang.String getClaimCouponErrorURL()
Return the claimCouponErrorURL property.


setCouponClaimCode

public void setCouponClaimCode(java.lang.String pCouponClaimCode)
Set the couponClaimCode property.


getCouponClaimCode

public java.lang.String getCouponClaimCode()
Return the couponClaimCode property.


setProfile

public void setProfile(Profile pProfile)
Set the Profile property.


getProfile

public Profile getProfile()
Return the Profile property.


setPromotionTools

public void setPromotionTools(PromotionTools pPromotionTools)
Set the PromotionTools property.


getPromotionTools

public PromotionTools getPromotionTools()
Return the PromotionTools property.


setClaimableManager

public void setClaimableManager(ClaimableManager pClaimableManager)
Set the ClaimableManager property.


getClaimableManager

public ClaimableManager getClaimableManager()
Return the ClaimableManager property.


setValidCouponItemTypes

public void setValidCouponItemTypes(java.lang.String[] pValidCouponItemTypes)

getValidCouponItemTypes

public java.lang.String[] getValidCouponItemTypes()
The list of acceptable item types for promotions when claiming a coupon. Used in handleClaimCoupon


claimCoupon

protected void claimCoupon(DynamoHttpServletRequest pRequest,
                           DynamoHttpServletResponse pResponse)
                    throws ClaimableException
Claim the coupon. Called by handleClaimCoupon() to perform the actual claiming of the coupon. This method simply calls claimableManager.claimCopon(). Override this method to customize the coupon claiming process.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
pResponse - a value of type 'DynamoHttpServletResponse'
Throws:
ClaimableException

handleClaimCoupon

public boolean handleClaimCoupon(DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse)
                          throws javax.servlet.ServletException,
                                 java.io.IOException
Method that is invoked to claim a coupon. First, the property couponClaimCode is checked to make sure that the user entered a claim code for the coupon. Next, using that claim code the claimableManager is used to try and actually claim the coupon using the claimItem call. If no coupon object is returned, than an error is logged. Else promotionTools is used to add the promotion to the users profile.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
pResponse - a value of type 'DynamoHttpServletResponse'
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs

processError

protected void processError(java.lang.String pErrorCodeId,
                            java.lang.Exception e,
                            DynamoHttpServletRequest pRequest)
                     throws javax.servlet.ServletException,
                            java.io.IOException
If an error occurs, this method will obtain the correct Msg resource string based upon the users locale from the getUserLocale method.

Parameters:
pErrorCodeId - the error key that is used to obtain the error string
Throws:
javax.servlet.ServletException
java.io.IOException

getUserLocale

protected java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest)
                                  throws javax.servlet.ServletException,
                                         java.io.IOException
Obtain the users locale by examining the request object first and then getting the default Locale object.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
Returns:
a value of type 'Locale'
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs

checkPromotionType

public boolean checkPromotionType(RepositoryItem pPromotion)
Checks to see if the type of the promotion is valid. All valid types appear in the list validCouponItemTypes

Parameters:
pPromotion -
Returns:
true if the item type is in the validCouponItemTypes list.