Class DefaultCMSItemAttributeFilterEnablerService

java.lang.Object
de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService
All Implemented Interfaces:
CMSItemAttributeFilterEnablerService, org.springframework.beans.factory.InitializingBean

public class DefaultCMSItemAttributeFilterEnablerService extends Object implements CMSItemAttributeFilterEnablerService, org.springframework.beans.factory.InitializingBean
Default implementation of CMSItemAttributeFilterEnablerService
  • Field Details

    • CMS_ITEM_ATTRIBUTE_FILTER_SEPARATOR

      public static final String CMS_ITEM_ATTRIBUTE_FILTER_SEPARATOR
      See Also:
    • CMS_ITEM_ATTRIBUTE_FILTER_REFERENCE_SEPARATOR

      public static final String CMS_ITEM_ATTRIBUTE_FILTER_REFERENCE_SEPARATOR
      See Also:
    • CMS_ITEM_ATTRIBUTE_FILTER_ENABLER_MODE_CACHE_KEY

      public static final String CMS_ITEM_ATTRIBUTE_FILTER_ENABLER_MODE_CACHE_KEY
      See Also:
    • CMS_ITEM_ATTRIBUTE_FILTER_CONFIG_EXPIRATION_TIME_KEY

      public static final String CMS_ITEM_ATTRIBUTE_FILTER_CONFIG_EXPIRATION_TIME_KEY
      See Also:
    • DEFAULT_EXPIRATION_TIME

      public static final long DEFAULT_EXPIRATION_TIME
      See Also:
    • ATTRIBUTE_MIN_LENGTH

      public static final int ATTRIBUTE_MIN_LENGTH
      See Also:
  • Constructor Details

    • DefaultCMSItemAttributeFilterEnablerService

      public DefaultCMSItemAttributeFilterEnablerService()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getAttributes

      public List<String> getAttributes(String typeCode, String mode)
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Returns the list of attributes by mode.
      Specified by:
      getAttributes in interface CMSItemAttributeFilterEnablerService
      Parameters:
      typeCode - the type for which the list of attributes should be returned
      mode - the mode that represents the list of fields.
      Returns:
      the list of fields.
    • getAttributes

      public List<String> getAttributes(String typeCode)
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Returns the list of attributes. The mode is retrieved from the session if it was set by CMSItemAttributeFilterEnablerService.setMode(String).
      Specified by:
      getAttributes in interface CMSItemAttributeFilterEnablerService
      Parameters:
      typeCode - the type for which the list of attributes should be returned
      Returns:
      the list of fields.
    • isAttributeAllowed

      public boolean isAttributeAllowed(String typeCode, String attribute)
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Verifies whether the attribute is allowed or not.
      Specified by:
      isAttributeAllowed in interface CMSItemAttributeFilterEnablerService
      Parameters:
      typeCode - the type code where the attribute exists
      attribute - the attribute qualifier.
      Returns:
      true if the attribute is allowed, false otherwise
    • setMode

      public void setMode(String mode)
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Method saves the mode that should be used to retrieve the list of attributes to the session.
      Specified by:
      setMode in interface CMSItemAttributeFilterEnablerService
      Parameters:
      mode - the mode that should be used to retrieve the list of attributes.
    • getMode

      public String getMode()
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Method retrieves the attribute mode from the session.
      Specified by:
      getMode in interface CMSItemAttributeFilterEnablerService
      Returns:
      the mode, null if mode has not been set.
    • clearCache

      public void clearCache() throws InterruptedException
      Description copied from interface: CMSItemAttributeFilterEnablerService
      Clear the cache that stores the configuration.
      Specified by:
      clearCache in interface CMSItemAttributeFilterEnablerService
      Throws:
      InterruptedException - if thread is interrupted
    • getExpirationTime

      protected com.google.common.base.Supplier<Long> getExpirationTime()
      Returns the expiration time for the configuration.
      Returns:
    • initializeCompiledConfigurations

      protected com.google.common.base.Supplier<List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration>> initializeCompiledConfigurations(Long defaultTimeExpiration, TimeUnit timeUnit)
      Compiles the configuration.
    • getAttributesByTypeAndMode

      protected List<String> getAttributesByTypeAndMode(String typeCode, String mode)
      Returns attributes that must be returned by CMS ITEM API for provided type and mode. If the mode does not exist the parent type will be analyzed and if it contains necessary mode it will be used.
      Parameters:
      typeCode - the type
      mode - the mode
      Returns:
      the list of attributes
    • compileTypeConfigurations

      protected com.google.common.base.Supplier<List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration>> compileTypeConfigurations()
      Build the attribute configuration for CMS ITEM API
      Returns:
      the supplier that provides the list of configurations.
    • compileTypeConfigurationsForAllCMSTypes

      protected List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> compileTypeConfigurationsForAllCMSTypes(List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> definedConfigs)
      Builds configurations for all subtypes of CMSItemModel.
      Parameters:
      definedConfigs - user based configurations
      Returns:
      the list of DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration configurations for all defined platform types.
    • readDefinedConfigurations

      protected List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> readDefinedConfigurations()
      Reads configurations defined by user.
      Returns:
      the list of DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration configurations defined by users
    • getRelatedPrebuiltConfigByTypeCode

      protected Optional<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> getRelatedPrebuiltConfigByTypeCode(String typeCode, List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> prebuildConfigs)
      Returns the config for the type code. How? 1. It retrieves all supertypes for the type. 2. For all supertypes+currenttype it retrieves the configuration added by user: 0 = "ContentPage" null 1 = "AbstractPage" BASIC;CMSItem:BASIC,slots 2 = "CMSItem" BASIC;itemtype,uid,catalogVersion,uuid SELECT;BASIC,name,label 3 = "GenericItem" null 4 = "LocalizableItem" null 5 = "ExtensibleItem" null 6 = "Item" null 3. Then it converts the list to map using the mode as a key. The child mode always overrides the parent (see (config1, config2) -> config1)) 4. The new TypeConfiguration is build based on built structure.
      Returns:
      the config for the type code. If the code for current code does not exist the method tries to find a config for the parent and so on until the config is found. If not found will return empty Optional.
    • getPrebuiltConfigByTypeCode

      protected Optional<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> getPrebuiltConfigByTypeCode(String typeCode, List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration> prebuildConfigs)
      Returns the config (that defined by user) for the type code.
      Parameters:
      typeCode - the type code of the item
      prebuildConfigs - the user defined configs
      Returns:
      the optional DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration
    • compileAttributes

      protected List<String> compileAttributes(String attributes, String typeCode)
      Compiles the list of attributes for provided type.
      Parameters:
      attributes - the list of comma separated attributes.
      typeCode - the type
      Returns:
      the list of compiled attributes.
    • compileAttribute

      protected List<String> compileAttribute(String attribute, String typeCode)
      Compiles one attribute.
      Parameters:
      attribute - the attribute to compile.
      typeCode - the type code which contains the attribute
      Returns:
      the list that contains either one attribute if it's simple (e.g. "uid"), or many attributes if it represents a reference (e.g. "AbstractPage:BASIC")
    • compileAttributeByTypeAndMode

      protected List<String> compileAttributeByTypeAndMode(String typeCode, String mode)
      Compiles attributes for provided type and mode.
      Parameters:
      typeCode - the type for which the attributes must be compiled.
      mode - the mode for which the attributes must be compiled.
      Returns:
      the list of attributes.
    • isReferenceAttribute

      protected boolean isReferenceAttribute(String attribute)
      Verifies whether the attribute is a reference attribute. If the attribute contains CMS_ITEM_ATTRIBUTE_FILTER_REFERENCE_SEPARATOR it means it's a reference attribute. For example: AbstractPage:BASIC
      Parameters:
      attribute - the attribute to verify.
      Returns:
      true if the attribute is a reference attribute, false otherwise.
    • isType

      protected boolean isType(String value)
      Verifies whether the value represents a type.
      Parameters:
      value - the value to verify.
      Returns:
      true if the value represents the type, false otherwise.
    • isMode

      protected boolean isMode(String typeCode, String value)
      Verifies whether the value represents a mode for a type.
      Parameters:
      typeCode - the type for which value is validated.
      value - the value to verify
      Returns:
      true if the value represents a mode for a type, false otherwise.
    • getConfigurationsByType

      protected List<CMSItemTypeAttributeFilterConfigModel> getConfigurationsByType(String typeCode)
      Returns all configurations by its type.
      Parameters:
      typeCode - the type for which configurations will be returned.
      Returns:
      the list of configurations.
    • getConfigurationsMap

      protected Map<String,List<CMSItemTypeAttributeFilterConfigModel>> getConfigurationsMap()
      Returns a map of configurations for all types where the entry key represents the type and the entry value contains the list of configurations defined for a given type.
      Returns:
      the grouped configurations.
    • getCmsItemTypeAttributeFilterConfigDao

      public CMSItemTypeAttributeFilterConfigDao getCmsItemTypeAttributeFilterConfigDao()
    • setCmsItemTypeAttributeFilterConfigDao

      public void setCmsItemTypeAttributeFilterConfigDao(CMSItemTypeAttributeFilterConfigDao cmsItemTypeAttributeFilterConfigDao)
    • getTypeService

      public TypeService getTypeService()
    • setTypeService

      public void setTypeService(TypeService typeService)
    • getSessionService

      public SessionService getSessionService()
    • setSessionService

      public void setSessionService(SessionService sessionService)
    • getConfigurationService

      public ConfigurationService getConfigurationService()
    • setConfigurationService

      public void setConfigurationService(ConfigurationService configurationService)