Class DefaultCMSItemDeepCloningService

java.lang.Object
de.hybris.platform.cms2.cloning.service.impl.DefaultCMSItemDeepCloningService
All Implemented Interfaces:
CMSItemDeepCloningService

public class DefaultCMSItemDeepCloningService extends Object implements CMSItemDeepCloningService
Default implementation of CMSItemDeepCloningService to deep copy item models.
  • Field Details

  • Constructor Details

    • DefaultCMSItemDeepCloningService

      public DefaultCMSItemDeepCloningService()
  • Method Details

    • deepCloneComponent

      public ItemModel deepCloneComponent(ItemModel srcComponent, ModelCloningContext cloningContext)
      Description copied from interface: CMSItemDeepCloningService
      Creates a clone of the given component and deep copies all the component's attributes.
      Specified by:
      deepCloneComponent in interface CMSItemDeepCloningService
      Parameters:
      srcComponent - - the cms component to be cloned
      cloningContext - - the cloning context
      Returns:
      a newly cloned component
    • generateCloneItemUid

      public String generateCloneItemUid()
      Description copied from interface: CMSItemDeepCloningService
      Creates a uid consisting of the prefix clone_ and a generated number.
      Specified by:
      generateCloneItemUid in interface CMSItemDeepCloningService
      Returns:
      a new uid to be assigned to a cloned item; never null
    • generateCloneItemUid

      public String generateCloneItemUid(String originalUid)
      Description copied from interface: CMSItemDeepCloningService
      Creates 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:
      generateCloneItemUid in interface CMSItemDeepCloningService
      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 String generateCloneComponentName(String originalComponentName)
      Description copied from interface: CMSItemDeepCloningService
      Creates 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:
      generateCloneComponentName in interface CMSItemDeepCloningService
      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 String generateClonedAttributeValue(String originalValue, String prefix, 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 String formatCloneAttributeValue(String originalValue, String generatedId, String prefix, 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 value
      generatedId - the generated id
      Returns:
      the formatted value
    • getPropertySupplier

      protected Supplier<String> getPropertySupplier(String propertyKey, String defaultValue)
      Returns the value from the properties file.
      Parameters:
      propertyKey - the property name
      defaultValue - the default value
      Returns:
      the Supplier that retrieves the property
    • getPropertySupplier

      protected Supplier<Integer> getPropertySupplier(String propertyKey, Integer defaultValue)
      Returns the value from the properties file.
      Parameters:
      propertyKey - the property name
      defaultValue - the default value
      Returns:
      the Supplier that 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)