public class DefaultGenericPromotionCodeManager extends java.lang.Object implements GenericPromotionCodeManager
GenericPromotionCodeManager
interface provides default implementation of the promotion code manager.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright
|
PROMO_CODE_IN_USE, PROMO_CODE_USED
Constructor and Description |
---|
DefaultGenericPromotionCodeManager()
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addCodeForOrder(java.lang.String code,
OrderKey okey)
Add a promotion code to an order
|
void |
addCodeForOrder(java.lang.String code,
OrderKey okey,
java.util.Date date)
Add a promotion code to an order
|
static void |
clearErrorMessageCodeCache()
A static method to clear error message code cache
It is used with Promotion Registry flush to ensure no message stay in the cache for too long
|
static void |
clearErrorMessageTextCache()
A static method to clear error message text cache
It is used with Promotion Registry flush to ensure no message stay in the cache for too long
|
void |
fromXML(org.w3c.dom.Node node)
Transforms the XML node into its corresponding real Object.
|
java.lang.String |
getAllMessagesInCache()
A public method to retrieve all the messages currently stored in the cache
|
static DefaultGenericPromotionCodeManager |
getInstance()
Singleton get instance method
|
GenericPromotionCodeResolver |
getPromotionCodeResolver()
Returns the promotion code resolver used by this promotion code manager.
|
static java.lang.Boolean |
isPromotionCodesErrorsLoggingEnabled()
A method to check config flag (enableInvalidPromotionCodesLogging) for the value of whether logging promotion codes errors or not.
|
java.lang.String[] |
listCodeForOrder(OrderKey okey)
List all the codes that are used in an order
|
void |
logErrorInfoForInvalidCodes(java.lang.String pid,
java.lang.String code,
java.lang.String msgCode,
java.lang.Number numStoreId)
This method logs the promotion code error information into the log
under two conditions, either a specific code has been entered incorrectly
X times, or if the overall hashmap cache limit Y has been reached.
|
void |
printAllErrorMessagesTolog()
A public method to print all current error messages stored in the cache to log
However, this does not flush the cache, only prints the current content stored in cache
|
void |
removeAllCodesForOrder(OrderKey okey)
Removes all promotion codes entered for an order
|
void |
removeCodeForOrder(java.lang.String code,
OrderKey okey)
Removes a promotion code entered for an order
|
void |
resourceBundleLookUp()
This method looks up the values in resource bundle and set the parameters in the
class instance and cache to their appropriate translation values.
|
void |
setPromotionCodeResolver(GenericPromotionCodeResolver resolver)
This method is used to set the PromotionCodeResolver object.
|
java.lang.String |
toXML()
Converts the object into its corresponding XML format representation.
|
java.lang.String |
translateKeyToMessage(java.lang.String[] keyValues)
This method looks up the Error Message Code stored in keyValues[2] (which contains either
typeInvalid, typeRedemp, typeRedempShopper or typeInactive) and replaces this code with the translated
Error Message Code Text message that has been stored in the errorMessageTextCache.
|
java.lang.String |
translateKeyToMessage(java.lang.String key,
int value)
Deprecated.
Use translateKeyToMessage(String[] keyValues) instead.
|
PromotionErrorReport |
validatePromotionCode(java.lang.String code,
CustomerKey ukey,
StoreKey storeKey)
Validates a promotion code.
|
PromotionErrorReport |
validatePromotionCode(java.lang.String code,
CustomerKey ukey,
StoreKey storeKey,
java.util.Date date)
Validates a promotion code.
|
public static final java.lang.String COPYRIGHT
public DefaultGenericPromotionCodeManager()
public static DefaultGenericPromotionCodeManager getInstance()
public void addCodeForOrder(java.lang.String code, OrderKey okey) throws PromotionApplicationException
addCodeForOrder
in interface GenericPromotionCodeManager
code
- The promotion code to add to the order.okey
- The OrderKey object.PromotionApplicationException
- is thrown when system enters a problem trying to add a
promotion code to an order.public void addCodeForOrder(java.lang.String code, OrderKey okey, java.util.Date date) throws PromotionApplicationException
addCodeForOrder
in interface GenericPromotionCodeManager
code
- The promotion code to add to the order.okey
- The OrderKey object.date
- The date on which the code is enteredPromotionApplicationException
- is thrown when system enters a problem trying to add a
promotion code to an order.public java.lang.String[] listCodeForOrder(OrderKey okey)
listCodeForOrder
in interface GenericPromotionCodeManager
okey
- The OrderKey object.public void removeCodeForOrder(java.lang.String code, OrderKey okey) throws PromotionApplicationException
removeCodeForOrder
in interface GenericPromotionCodeManager
code
- The promotion codeokey
- The OrderKeyPromotionApplicationException
- is thrown when system enters a problem trying to remove a
promotion code from an order.public void removeAllCodesForOrder(OrderKey okey) throws PromotionApplicationException
removeAllCodesForOrder
in interface GenericPromotionCodeManager
okey
- The OrderKeyPromotionApplicationException
- is thrown when system enters a problem trying to remove
all promotion codes from an order.public PromotionErrorReport validatePromotionCode(java.lang.String code, CustomerKey ukey, StoreKey storeKey) throws PromotionApplicationException
validatePromotionCode
in interface GenericPromotionCodeManager
code
- the codeukey
- key of the user who entered the promotion codestoreKey
- key of the store where the transaction happensPromotionApplicationException
- if any of the 3 criteria is not satisfied.public PromotionErrorReport validatePromotionCode(java.lang.String code, CustomerKey ukey, StoreKey storeKey, java.util.Date date) throws PromotionApplicationException
validatePromotionCode
in interface GenericPromotionCodeManager
code
- the codeukey
- key of the user who entered the promotion codestoreKey
- key of the store where the transaction happensdate
- the date on which the code is enteredPromotionApplicationException
- if any of the 3 criteria is not satisfied.public void logErrorInfoForInvalidCodes(java.lang.String pid, java.lang.String code, java.lang.String msgCode, java.lang.Number numStoreId)
pid
- promotion id usedcode
- promotion code usedmsgCode
- promotion message code usednumStoreId
- store id usedpublic void printAllErrorMessagesTolog()
public java.lang.String getAllMessagesInCache()
public java.lang.String translateKeyToMessage(java.lang.String key, int value)
key
- Contains promotion id, promotion code and error code, error code is used
to look up the actual text of the errorvalue
- Number of times this error has happened in a given intervalpublic java.lang.String translateKeyToMessage(java.lang.String[] keyValues)
keyValues
- Contains promotion id, promotion code, error code which is used to look up the
actual text of the error, store id, and number of times it has been attemptedpublic void resourceBundleLookUp()
public static void clearErrorMessageCodeCache()
public static void clearErrorMessageTextCache()
public static java.lang.Boolean isPromotionCodesErrorsLoggingEnabled()
public GenericPromotionCodeResolver getPromotionCodeResolver()
GenericPromotionCodeManager
getPromotionCodeResolver
in interface GenericPromotionCodeManager
com.ibm.commerce.marketing.promotion.GenericPromotionCodeManager#getPromotionCodeResolver();
public void fromXML(org.w3c.dom.Node node) throws DeXMLizationException
XMLizable
fromXML
in interface XMLizable
node
- The node that represents an XMLizable objectDeXMLizationException
- when this process failsXMLizable.fromXML(Node)
public java.lang.String toXML() throws XMLizationException
XMLizable
toXML
in interface XMLizable
XMLizationException
- when this process failsXMLizable.toXML()
public void setPromotionCodeResolver(GenericPromotionCodeResolver resolver)
resolver
- The PromotionCodeResolver to set