public class DefaultCouponCodeGenerationService extends java.lang.Object implements CouponCodeGenerationService
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
UNEXPECTED_ERROR_MSG |
| Constructor and Description |
|---|
DefaultCouponCodeGenerationService() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected MediaModel |
createMedia(MultiCodeCouponModel coupon,
int quantity) |
protected <any> |
extractClearTextAndCipherText(MultiCodeCouponModel coupon,
java.lang.String couponCode)
returns a string pair containing the clear text and the cipher text part of the given coupon code.
|
java.lang.String |
extractCouponPrefix(java.lang.String couponCode)
tries to find the prefix substring of the given coupon code.
|
java.lang.String |
generateCouponAlphabet()
generates the alphabet used for a coupon.
|
java.lang.String |
generateCouponCode(MultiCodeCouponModel coupon)
Generates a code for the given multi code coupon.
|
java.util.Optional<MediaModel> |
generateCouponCodes(MultiCodeCouponModel multiCodeCoupon,
int quantity)
Generates codes for the given multi-code coupon.
|
java.lang.String |
generateCouponSignature()
generates a base64 encoded String representing the signature of the multi code coupon.
|
protected java.util.Optional<MediaModel> |
generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon,
int quantity) |
protected java.lang.String |
getAndValidateAlgorithm()
validates the configured algorithm used for the cipher part of the coupon code
|
protected int |
getAndValidateAlphabetLength(java.lang.String globalCharacterSet)
validates the coupon alphabet length and returns it
|
protected java.lang.String |
getAndValidateGlobalCharacterSet()
validates that the global character set doesn't contain the defined code separators and that all characters are
single-byte characters.
|
protected java.lang.Integer |
getBatchSize() |
protected int |
getCipherTextLength(MultiCodeCouponModel coupon)
returns the amount of cipher-text characters to be created for the given coupon.
|
protected CouponCodeCipherTextGenerationStrategy |
getCipherTextStrategy() |
protected int |
getClearTextLength(MultiCodeCouponModel coupon)
returns the amount of clear-text characters to be created for the given coupon.
|
protected CouponCodeClearTextGenerationStrategy |
getClearTextStrategy() |
protected java.lang.String |
getCodeSeparatorPattern() |
protected ConfigurationService |
getConfigurationService() |
protected CouponCodesGenerator |
getCouponCodesGenerator() |
protected KeyGenerator |
getKeyGenerator() |
protected int |
getLengthFor(MultiCodeCouponModel coupon,
boolean clearText) |
protected MediaFolderModel |
getMediaFolderForCouponCodes() |
protected MediaService |
getMediaService() |
protected ModelService |
getModelService() |
boolean |
isValidCodeSeparator(java.lang.String codeSeparator)
verifies if the given string is a valid code separator
|
protected java.lang.String |
removeCodeSeparators(java.lang.String codeWithOutPrefix,
MultiCodeCouponModel coupon)
removes the code separator from the given
codeWithoutPrefix. |
void |
setCipherTextStrategy(CouponCodeCipherTextGenerationStrategy cipherTextStrategy) |
void |
setClearTextStrategy(CouponCodeClearTextGenerationStrategy clearTextStrategy) |
void |
setCodeSeparatorPattern(java.lang.String codeSeparatorPattern) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setCouponCodesGenerator(CouponCodesGenerator couponCodesGenerator) |
void |
setKeyGenerator(KeyGenerator keyGenerator) |
void |
setMediaService(MediaService mediaService) |
void |
setModelService(ModelService modelService) |
protected boolean |
validateCouponFormat(MultiCodeCouponModel coupon,
java.lang.String couponCode)
validates the given coupon code with regards to its format (i.e.
|
protected boolean |
verifyCipherText(MultiCodeCouponModel coupon,
java.lang.String couponCode) |
boolean |
verifyCouponCode(MultiCodeCouponModel coupon,
java.lang.String couponCode)
verifies if the given
couponCode is valid for the given coupon. |
protected boolean |
verifyUsedCouponCodeNumber(MultiCodeCouponModel coupon,
<any> pair) |
protected static final java.lang.String UNEXPECTED_ERROR_MSG
public void afterPropertiesSet()
public java.lang.String generateCouponSignature()
CouponCodeGenerationServicegenerateCouponSignature in interface CouponCodeGenerationServicepublic java.lang.String generateCouponAlphabet()
CouponCodeGenerationServicegenerateCouponAlphabet in interface CouponCodeGenerationServicepublic java.lang.String generateCouponCode(MultiCodeCouponModel coupon)
CouponCodeGenerationServicecouponCodeNumber attribute)generateCouponCode in interface CouponCodeGenerationServicecoupon - multi code couponCouponCodeGenerationExceptionpublic java.util.Optional<MediaModel> generateCouponCodes(MultiCodeCouponModel multiCodeCoupon, int quantity)
CouponCodeGenerationServicequantity coupon codes or less. It contains less codes if the
requested quantity cannot be generated (e.g. if the limit of codes has been reached). If no coupon codes could be
generated an Optional.empty() is returned.generateCouponCodes in interface CouponCodeGenerationServicemultiCodeCoupon - Multi code coupon instancequantity - number of coupon codes to be generatedOptional.empty() is returned.protected java.util.Optional<MediaModel> generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon, int quantity)
protected MediaModel createMedia(MultiCodeCouponModel coupon, int quantity)
protected MediaFolderModel getMediaFolderForCouponCodes()
public java.lang.String extractCouponPrefix(java.lang.String couponCode)
CouponCodeGenerationServiceextractCouponPrefix in interface CouponCodeGenerationServicecouponCode - coupon code to extract prefix substringpublic boolean verifyCouponCode(MultiCodeCouponModel coupon, java.lang.String couponCode)
CouponCodeGenerationServicecouponCode is valid for the given coupon.verifyCouponCode in interface CouponCodeGenerationServicecoupon - Coupon against which check will be firedcouponCode - Coupon code to verifyprotected boolean validateCouponFormat(MultiCodeCouponModel coupon, java.lang.String couponCode)
protected boolean verifyCipherText(MultiCodeCouponModel coupon, java.lang.String couponCode)
protected boolean verifyUsedCouponCodeNumber(MultiCodeCouponModel coupon, <any> pair)
public boolean isValidCodeSeparator(java.lang.String codeSeparator)
CouponCodeGenerationServiceisValidCodeSeparator in interface CouponCodeGenerationServicecodeSeparator - Code separatorprotected <any> extractClearTextAndCipherText(MultiCodeCouponModel coupon, java.lang.String couponCode)
protected java.lang.String removeCodeSeparators(java.lang.String codeWithOutPrefix,
MultiCodeCouponModel coupon)
codeWithoutPrefix. Note: Expects the given code to be without
its prefix.java.lang.IllegalArgumentException - if the given code doesn't match with the required length of the given coupon's configurationprotected int getCipherTextLength(MultiCodeCouponModel coupon)
protected int getClearTextLength(MultiCodeCouponModel coupon)
protected int getLengthFor(MultiCodeCouponModel coupon, boolean clearText)
protected int getAndValidateAlphabetLength(java.lang.String globalCharacterSet)
protected java.lang.String getAndValidateGlobalCharacterSet()
CouponCodeGenerationException - if the validation failsprotected java.lang.String getAndValidateAlgorithm()
protected ConfigurationService getConfigurationService()
public void setConfigurationService(ConfigurationService configurationService)
protected CouponCodeClearTextGenerationStrategy getClearTextStrategy()
public void setClearTextStrategy(CouponCodeClearTextGenerationStrategy clearTextStrategy)
protected CouponCodeCipherTextGenerationStrategy getCipherTextStrategy()
public void setCipherTextStrategy(CouponCodeCipherTextGenerationStrategy cipherTextStrategy)
protected ModelService getModelService()
public void setModelService(ModelService modelService)
protected MediaService getMediaService()
public void setMediaService(MediaService mediaService)
protected java.lang.String getCodeSeparatorPattern()
public void setCodeSeparatorPattern(java.lang.String codeSeparatorPattern)
protected CouponCodesGenerator getCouponCodesGenerator()
public void setCouponCodesGenerator(CouponCodesGenerator couponCodesGenerator)
protected java.lang.Integer getBatchSize()
protected KeyGenerator getKeyGenerator()
public void setKeyGenerator(KeyGenerator keyGenerator)
Copyright © 2018 SAP SE. All Rights Reserved.