Class DefaultCMSItemDeepCloningService
- java.lang.Object
-
- de.hybris.platform.cms2.cloning.service.impl.DefaultCMSItemDeepCloningService
-
- All Implemented Interfaces:
CMSItemDeepCloningService
public class DefaultCMSItemDeepCloningService extends java.lang.Object implements CMSItemDeepCloningService
Default implementation ofCMSItemDeepCloningServiceto deep copy item models.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringATTRIBUTE_NAME_MAX_LENGTHprotected static java.lang.StringATTRIBUTE_NAME_PREFIX_KEYprotected static java.lang.StringATTRIBUTE_NAME_SEPARATOR_KEYprotected static java.lang.StringATTRIBUTE_UID_MAX_LENGTHprotected static java.lang.StringATTRIBUTE_UID_PREFIX_KEYprotected static java.lang.StringATTRIBUTE_UID_SEPARATOR_KEYprotected static intDEFAULT_ATTRIBUTE_NAME_MAX_LENGTHprotected static java.lang.StringDEFAULT_ATTRIBUTE_NAME_PREFIXprotected static java.lang.StringDEFAULT_ATTRIBUTE_NAME_SEPARATORprotected static intDEFAULT_ATTRIBUTE_UID_MAX_LENGTHprotected static java.lang.StringDEFAULT_ATTRIBUTE_UID_PREFIXprotected static java.lang.StringDEFAULT_ATTRIBUTE_UID_SEPARATOR
-
Constructor Summary
Constructors Constructor Description DefaultCMSItemDeepCloningService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ItemModeldeepCloneComponent(ItemModel srcComponent, ModelCloningContext cloningContext)Creates a clone of the given component and deep copies all the component's attributes.protected java.lang.StringformatCloneAttributeValue(java.lang.String originalValue, java.lang.String generatedId, java.lang.String prefix, java.lang.String separator)Formats the value using the following pattern:clone_<originalUid>_<generatedId>.java.lang.StringgenerateCloneComponentName(java.lang.String originalComponentName)Creates a new name to be used on a cloned component to avoid clashing with the original one.protected java.lang.StringgenerateClonedAttributeValue(java.lang.String originalValue, java.lang.String prefix, java.lang.String separator, int maxLength)Generates a clone representation of original string value.java.lang.StringgenerateCloneItemUid()Creates a uid consisting of the prefixclone_and a generated number.java.lang.StringgenerateCloneItemUid(java.lang.String originalUid)Creates a new uid to be used on a cloned item to avoid clashing with the original one.protected PersistentKeyGeneratorgetCloneUidGenerator()protected CMSItemModelCloneCreatorgetCmsItemModelCloneCreator()ConfigurationServicegetConfigurationService()protected java.util.function.Supplier<java.lang.Integer>getPropertySupplier(java.lang.String propertyKey, java.lang.Integer defaultValue)Returns the value from the properties file.protected java.util.function.Supplier<java.lang.String>getPropertySupplier(java.lang.String propertyKey, java.lang.String defaultValue)Returns the value from the properties file.voidsetCloneUidGenerator(PersistentKeyGenerator cloneUidGenerator)voidsetCmsItemModelCloneCreator(CMSItemModelCloneCreator cmsItemModelCloneCreator)voidsetConfigurationService(ConfigurationService configurationService)
-
-
-
Field Detail
-
ATTRIBUTE_UID_PREFIX_KEY
protected static final java.lang.String ATTRIBUTE_UID_PREFIX_KEY
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_UID_PREFIX
protected static final java.lang.String DEFAULT_ATTRIBUTE_UID_PREFIX
- See Also:
- Constant Field Values
-
ATTRIBUTE_UID_SEPARATOR_KEY
protected static final java.lang.String ATTRIBUTE_UID_SEPARATOR_KEY
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_UID_SEPARATOR
protected static final java.lang.String DEFAULT_ATTRIBUTE_UID_SEPARATOR
- See Also:
- Constant Field Values
-
ATTRIBUTE_UID_MAX_LENGTH
protected static final java.lang.String ATTRIBUTE_UID_MAX_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_UID_MAX_LENGTH
protected static final int DEFAULT_ATTRIBUTE_UID_MAX_LENGTH
- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_PREFIX_KEY
protected static final java.lang.String ATTRIBUTE_NAME_PREFIX_KEY
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_NAME_PREFIX
protected static final java.lang.String DEFAULT_ATTRIBUTE_NAME_PREFIX
- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_SEPARATOR_KEY
protected static final java.lang.String ATTRIBUTE_NAME_SEPARATOR_KEY
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_NAME_SEPARATOR
protected static final java.lang.String DEFAULT_ATTRIBUTE_NAME_SEPARATOR
- See Also:
- Constant Field Values
-
ATTRIBUTE_NAME_MAX_LENGTH
protected static final java.lang.String ATTRIBUTE_NAME_MAX_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE_NAME_MAX_LENGTH
protected static final int DEFAULT_ATTRIBUTE_NAME_MAX_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
deepCloneComponent
public ItemModel deepCloneComponent(ItemModel srcComponent, ModelCloningContext cloningContext)
Description copied from interface:CMSItemDeepCloningServiceCreates a clone of the given component and deep copies all the component's attributes.- Specified by:
deepCloneComponentin interfaceCMSItemDeepCloningService- Parameters:
srcComponent- - the cms component to be clonedcloningContext- - the cloning context- Returns:
- a newly cloned component
-
generateCloneItemUid
public java.lang.String generateCloneItemUid()
Description copied from interface:CMSItemDeepCloningServiceCreates a uid consisting of the prefixclone_and a generated number.- Specified by:
generateCloneItemUidin interfaceCMSItemDeepCloningService- Returns:
- a new uid to be assigned to a cloned item; never null
-
generateCloneItemUid
public java.lang.String generateCloneItemUid(java.lang.String originalUid)
Description copied from interface:CMSItemDeepCloningServiceCreates a new uid to be used on a cloned item to avoid clashing with the original one. Consisting of the following: - prefix (cms.item.deep.clone.attribute.uid.prefix in properties file) or "clone_" by default, - separator (cms.item.deep.clone.attribute.uid.separator in properties file) or "_" be default - generated number. Never adds the prefix if it already exists. The result length must not exceed the value cms.item.deep.clone.attribute.uid.max.length from properties or 100 by default.- Input: component1 Output: clone_component1_123
- Input: component1_123 Output: clone_component1_123_456
- Input: clone_component1_123 Output: clone_component1_123_789
- Specified by:
generateCloneItemUidin interfaceCMSItemDeepCloningService- Parameters:
originalUid- - the original uid used as base for the clone uid- Returns:
- a new uid to be assigned to a cloned item; never null
-
generateCloneComponentName
public java.lang.String generateCloneComponentName(java.lang.String originalComponentName)
Description copied from interface:CMSItemDeepCloningServiceCreates a new name to be used on a cloned component to avoid clashing with the original one. Consisting of the following: - prefix (cms.item.deep.clone.attribute.name.prefix in properties file) or "Clone" by default, - separator (cms.item.deep.clone.attribute.name.separator in properties file) or " " be default - generated number. Never adds the prefix if it already exists. The result length must not exceed the value cms.item.deep.clone.attribute.name.max.length from properties or 100 by default. Examples:- Input: component1 Output: Clone component1 123
- Input: component1 123 Output: component1 123 456
- Input: this is a component Output: Clone this is a component 789
- Input: Clone this is a component Output: Clone this is a component 789
- Specified by:
generateCloneComponentNamein interfaceCMSItemDeepCloningService- Parameters:
originalComponentName- - the original name to use as a base for the clone name.- Returns:
- the name to use for the cloned component
-
generateClonedAttributeValue
protected java.lang.String generateClonedAttributeValue(java.lang.String originalValue, java.lang.String prefix, java.lang.String separator, int maxLength)Generates a clone representation of original string value. It takes the original value and adds a prefix to it as well as the generated unique id.- Parameters:
originalValue- the original value used to generate a new value.- Returns:
- the new value.
-
formatCloneAttributeValue
protected java.lang.String formatCloneAttributeValue(java.lang.String originalValue, java.lang.String generatedId, java.lang.String prefix, java.lang.String separator)Formats the value using the following pattern:clone_<originalUid>_<generatedId>. It does not adds prefix if it already exists.- Parameters:
originalValue- the original valuegeneratedId- the generated id- Returns:
- the formatted value
-
getPropertySupplier
protected java.util.function.Supplier<java.lang.String> getPropertySupplier(java.lang.String propertyKey, java.lang.String defaultValue)Returns the value from the properties file.- Parameters:
propertyKey- the property namedefaultValue- the default value- Returns:
- the
Supplierthat retrieves the property
-
getPropertySupplier
protected java.util.function.Supplier<java.lang.Integer> getPropertySupplier(java.lang.String propertyKey, java.lang.Integer defaultValue)Returns the value from the properties file.- Parameters:
propertyKey- the property namedefaultValue- the default value- Returns:
- the
Supplierthat retrieves the property
-
getCmsItemModelCloneCreator
protected CMSItemModelCloneCreator getCmsItemModelCloneCreator()
-
setCmsItemModelCloneCreator
public void setCmsItemModelCloneCreator(CMSItemModelCloneCreator cmsItemModelCloneCreator)
-
getCloneUidGenerator
protected PersistentKeyGenerator getCloneUidGenerator()
-
setCloneUidGenerator
public void setCloneUidGenerator(PersistentKeyGenerator cloneUidGenerator)
-
getConfigurationService
public ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
-