atg.commerce.promotion
Class CouponDroplet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.commerce.promotion.CouponDroplet
All Implemented Interfaces:
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, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class CouponDroplet
extends DynamoServlet

This droplet is used to create coupon objects in the claimable repository. A promotion is handed to the droplet via either a promotion id or promotion object parameter. The droplet then creates a coupon entry in the claimable repository, linking it to the promotion object that was handed in and then finally sets a coupon id on output. Either the promotion or promoId parmeter must be set.

Here are a list of the parmeters:

See Also:
ClaimableManager, PromotionTools

Field Summary
static java.lang.String CLASS_VERSION
           
protected static java.lang.String COUPON
           
protected static ParameterName DISPLAY_NAME
           
protected static ParameterName ERROR
           
protected static ParameterName OUTPUT
           
protected static ParameterName PROMOID
           
protected static ParameterName PROMOTION
           
protected static ParameterName PROMOTIONS
           
protected static ParameterName REDEEMABLE_ON_PROMOTION_SITES
           
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
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
CouponDroplet()
          Empty Constructor
 
Method Summary
protected  RepositoryItem createCoupon(RepositoryItem pPromotion)
          Used to create the coupon.
protected  RepositoryItem createCoupon(java.util.Set<RepositoryItem> pPromotionList, java.lang.String pDisplayName, java.lang.Boolean pUsePromotionSiteConstraint)
          Used to create the coupon.
 ClaimableManager getClaimableManager()
          Return the ClaimableManager property.
protected  RepositoryItem getPromotion(java.lang.String pPromoId)
          Obtains a promotion for a given promoId by using PromotionTools.
 PromotionTools getPromotionTools()
          Return the PromotionTools property.
protected  java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest)
          Get a users locale by trying to get it from the request object.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          The service method first obtains the promotion object.
 void setClaimableManager(ClaimableManager pClaimableManager)
          Set the ClaimableManager property.
 void setPromotionTools(PromotionTools pPromotionTools)
          Set the PromotionTools property.
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
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

COUPON

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

DISPLAY_NAME

protected static final ParameterName DISPLAY_NAME

REDEEMABLE_ON_PROMOTION_SITES

protected static final ParameterName REDEEMABLE_ON_PROMOTION_SITES

PROMOTION

protected static final ParameterName PROMOTION

PROMOTIONS

protected static final ParameterName PROMOTIONS

PROMOID

protected static final ParameterName PROMOID

OUTPUT

protected static final ParameterName OUTPUT

ERROR

protected static final ParameterName ERROR
Constructor Detail

CouponDroplet

public CouponDroplet()
Empty Constructor

Method Detail

setClaimableManager

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


getClaimableManager

public ClaimableManager getClaimableManager()
Return the ClaimableManager property.


setPromotionTools

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


getPromotionTools

public PromotionTools getPromotionTools()
Return the PromotionTools property.


service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
The service method first obtains the promotion object. This is done by first checking to see if the promotions parameter was set. If it was not set, then it tries to get a promotion by obtaining the promotion paramter. If that was not set then is tries to get the promoId parameter and using PromotionTools to get the promotion object associated with this id. If no promotion is found, then the error oparam is rendered.

If we have a promotion, then use the createCoupon method to create a coupon using the promotion that was obtained. Finally, set the coupon in the output and render the output oparam.

Overrides:
service in class DynamoServlet
Parameters:
pRequest - request object
pResponse - response object
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs

createCoupon

protected RepositoryItem createCoupon(java.util.Set<RepositoryItem> pPromotionList,
                                      java.lang.String pDisplayName,
                                      java.lang.Boolean pUsePromotionSiteConstraint)
                               throws CommerceException
Used to create the coupon. This is done by using the claimable manager and calling createClaimablePromotion on it and then initializing the claimable promotion. The new repository item is returned.

Parameters:
pPromotionList - the list of promotion objects
pDisplayName - the display name for the coupon
pUsePromotionSiteConstraint -
Returns:
the coupon
Throws:
CommerceException - if an error occurs

createCoupon

protected RepositoryItem createCoupon(RepositoryItem pPromotion)
                               throws CommerceException
Used to create the coupon. This is done by using the claimable manager and calling createClaimablePromotion on it and then initializing the claimable promotion. The new repository item is returned.

Parameters:
pPromotion - the promotion object
Returns:
the coupon
Throws:
CommerceException - if an error occurs

getPromotion

protected RepositoryItem getPromotion(java.lang.String pPromoId)
Obtains a promotion for a given promoId by using PromotionTools.

Parameters:
pPromoId - the id of a promotion
Returns:
a promotion object

getUserLocale

protected java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest)
                                  throws javax.servlet.ServletException,
                                         java.io.IOException
Get a users locale by trying to get it from the request object. If its not there, then use the default Locale of the VM.

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