public class DefaultCouponCodeGenerationService extends Object implements CouponCodeGenerationService
| Modifier and Type | Field and Description |
|---|---|
protected static String |
UNEXPECTED_ERROR_MSG |
| Constructor and Description |
|---|
DefaultCouponCodeGenerationService() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected MediaModel |
createMedia(List<String> codes,
String actionCode)
Deprecated.
as of ver 6.3. please consider using createMedia(List codes, int quantity) instead
|
protected MediaModel |
createMedia(MultiCodeCouponModel coupon,
int quantity) |
protected <any> |
extractClearTextAndCipherText(MultiCodeCouponModel coupon,
String couponCode)
returns a string pair containing the clear text and the cipher text part of the given coupon code.
|
String |
extractCouponPrefix(String couponCode)
tries to find the prefix substring of the given coupon code.
|
String |
generateCouponAlphabet()
generates the alphabet used for a coupon.
|
String |
generateCouponCode(MultiCodeCouponModel coupon)
Generates a code for the given multi code coupon.
|
Optional<MediaModel> |
generateCouponCodes(MultiCodeCouponModel multiCodeCoupon,
int quantity)
Generates codes for the given multi-code coupon.
|
String |
generateCouponSignature()
generates a base64 encoded String representing the signature of the multi code coupon.
|
protected Optional<MediaModel> |
generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon,
int quantity) |
protected Optional<MediaModel> |
generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon,
List<String> generatedCodes)
Deprecated.
as of ver 6.3. Please consider using generatedMediaForMultiCodeCoupons(
MultiCodeCouponModel,
int quantity) instead |
protected String |
getAndValidateAlgorithm()
validates the configured algorithm used for the cipher part of the coupon code
|
protected int |
getAndValidateAlphabetLength(String globalCharacterSet)
validates the coupon alphabet length and returns it
|
protected String |
getAndValidateGlobalCharacterSet()
validates that the global character set doesn't contain the defined code separators and that all characters are
single-byte characters.
|
protected 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 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() |
protected String |
insertCodeSeparators(String generatedCode,
MultiCodeCouponModel coupon)
Deprecated.
as of ver 6.3. Please consider using
CouponCodesGenerator.insertCodeSeparators instead |
boolean |
isValidCodeSeparator(String codeSeparator)
verifies if the given string is a valid code separator
|
protected String |
printCodeLengths()
Deprecated.
as of ver 6.3. Please consider using
CouponCodesGenerator method |
protected String |
removeCodeSeparators(String codeWithOutPrefix,
MultiCodeCouponModel coupon)
removes the code separator from the given
codeWithoutPrefix. |
void |
setCipherTextStrategy(CouponCodeCipherTextGenerationStrategy cipherTextStrategy) |
void |
setClearTextStrategy(CouponCodeClearTextGenerationStrategy clearTextStrategy) |
void |
setCodeSeparatorPattern(String codeSeparatorPattern) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setCouponCodesGenerator(CouponCodesGenerator couponCodesGenerator) |
void |
setKeyGenerator(KeyGenerator keyGenerator) |
void |
setMediaService(MediaService mediaService) |
void |
setModelService(ModelService modelService) |
protected boolean |
verifyCipherText(MultiCodeCouponModel coupon,
String couponCode) |
boolean |
verifyCouponCode(MultiCodeCouponModel coupon,
String couponCode)
verifies if the given
couponCode is valid for the given coupon. |
protected boolean |
verifyUsedCouponCodeNumber(MultiCodeCouponModel coupon,
<any> pair) |
protected static final String UNEXPECTED_ERROR_MSG
public void afterPropertiesSet()
public String generateCouponSignature()
CouponCodeGenerationServicegenerateCouponSignature in interface CouponCodeGenerationServicepublic String generateCouponAlphabet()
CouponCodeGenerationServicegenerateCouponAlphabet in interface CouponCodeGenerationServicepublic String generateCouponCode(MultiCodeCouponModel coupon) throws CouponCodeGenerationException
CouponCodeGenerationServicecouponCodeNumber attribute)generateCouponCode in interface CouponCodeGenerationServicecoupon - multi code couponCouponCodeGenerationExceptionpublic 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 CouponCodeGenerationServicequantity - number of coupon codes to be generatedOptional.empty() is returned.@Deprecated protected Optional<MediaModel> generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon, List<String> generatedCodes)
MultiCodeCouponModel,
int quantity) insteadmultiCodeCoupon - generatedCodes - protected Optional<MediaModel> generateMediaForMultiCodeCoupon(MultiCodeCouponModel multiCodeCoupon, int quantity)
@Deprecated protected MediaModel createMedia(List<String> codes, String actionCode)
codes - actionCode - protected MediaModel createMedia(MultiCodeCouponModel coupon, int quantity)
protected MediaFolderModel getMediaFolderForCouponCodes()
public String extractCouponPrefix(String couponCode)
CouponCodeGenerationServiceextractCouponPrefix in interface CouponCodeGenerationServicecouponCode - coupon code to extract prefix substringpublic boolean verifyCouponCode(MultiCodeCouponModel coupon, String couponCode)
CouponCodeGenerationServicecouponCode is valid for the given coupon.verifyCouponCode in interface CouponCodeGenerationServiceprotected boolean verifyCipherText(MultiCodeCouponModel coupon, String couponCode)
protected boolean verifyUsedCouponCodeNumber(MultiCodeCouponModel coupon, <any> pair)
public boolean isValidCodeSeparator(String codeSeparator)
CouponCodeGenerationServiceisValidCodeSeparator in interface CouponCodeGenerationServiceprotected <any> extractClearTextAndCipherText(MultiCodeCouponModel coupon, String couponCode)
@Deprecated protected String insertCodeSeparators(String generatedCode, MultiCodeCouponModel coupon)
CouponCodesGenerator.insertCodeSeparators insteadgeneratedCode - coupon - protected String removeCodeSeparators(String codeWithOutPrefix, MultiCodeCouponModel coupon)
codeWithoutPrefix. Note: Expects the given code to be without
its prefix.IllegalArgumentException - if the given code doesn't match with the required length of the given coupon's configuration@Deprecated protected String printCodeLengths()
CouponCodesGenerator methodprotected int getCipherTextLength(MultiCodeCouponModel coupon)
protected int getClearTextLength(MultiCodeCouponModel coupon)
protected int getLengthFor(MultiCodeCouponModel coupon, boolean clearText)
protected int getAndValidateAlphabetLength(String globalCharacterSet)
protected String getAndValidateGlobalCharacterSet()
CouponCodeGenerationException - if the validation failsprotected 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 String getCodeSeparatorPattern()
public void setCodeSeparatorPattern(String codeSeparatorPattern)
protected CouponCodesGenerator getCouponCodesGenerator()
public void setCouponCodesGenerator(CouponCodesGenerator couponCodesGenerator)
protected Integer getBatchSize()
protected KeyGenerator getKeyGenerator()
public void setKeyGenerator(KeyGenerator keyGenerator)
Copyright © 2017 SAP SE. All Rights Reserved.