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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidClear the cache that stores the configuration.compileAttribute(String attribute, String typeCode) Compiles one attribute.compileAttributeByTypeAndMode(String typeCode, String mode) Compiles attributes for provided type and mode.compileAttributes(String attributes, String typeCode) Compiles the list of attributes for provided type.protected com.google.common.base.Supplier<List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration>>Build the attribute configuration for CMS ITEM APIprotected 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 ofCMSItemModel.getAttributes(String typeCode) Returns the list of attributes.getAttributes(String typeCode, String mode) Returns the list of attributes by mode.getAttributesByTypeAndMode(String typeCode, String mode) Returns attributes that must be returned by CMS ITEM API for provided type and mode.protected List<CMSItemTypeAttributeFilterConfigModel>getConfigurationsByType(String typeCode) Returns all configurations by its type.protected Map<String,List<CMSItemTypeAttributeFilterConfigModel>> 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.protected com.google.common.base.Supplier<Long>Returns the expiration time for the configuration.getMode()Method retrieves the attribute mode from the session.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.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.protected com.google.common.base.Supplier<List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration>>initializeCompiledConfigurations(Long defaultTimeExpiration, TimeUnit timeUnit) Compiles the configuration.booleanisAttributeAllowed(String typeCode, String attribute) Verifies whether the attribute is allowed or not.protected booleanVerifies whether the value represents a mode for a type.protected booleanisReferenceAttribute(String attribute) Verifies whether the attribute is a reference attribute.protected booleanVerifies whether the value represents a type.protected List<de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration>Reads configurations defined by user.voidsetCmsItemTypeAttributeFilterConfigDao(CMSItemTypeAttributeFilterConfigDao cmsItemTypeAttributeFilterConfigDao) voidsetConfigurationService(ConfigurationService configurationService) voidMethod saves the mode that should be used to retrieve the list of attributes to the session.voidsetSessionService(SessionService sessionService) voidsetTypeService(TypeService typeService)
-
Field Details
-
CMS_ITEM_ATTRIBUTE_FILTER_SEPARATOR
- See Also:
-
CMS_ITEM_ATTRIBUTE_FILTER_REFERENCE_SEPARATOR
- See Also:
-
CMS_ITEM_ATTRIBUTE_FILTER_ENABLER_MODE_CACHE_KEY
- See Also:
-
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
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
getAttributes
Description copied from interface:CMSItemAttributeFilterEnablerServiceReturns the list of attributes by mode.- Specified by:
getAttributesin interfaceCMSItemAttributeFilterEnablerService- Parameters:
typeCode- the type for which the list of attributes should be returnedmode- the mode that represents the list of fields.- Returns:
- the list of fields.
-
getAttributes
Description copied from interface:CMSItemAttributeFilterEnablerServiceReturns the list of attributes. The mode is retrieved from the session if it was set byCMSItemAttributeFilterEnablerService.setMode(String).- Specified by:
getAttributesin interfaceCMSItemAttributeFilterEnablerService- Parameters:
typeCode- the type for which the list of attributes should be returned- Returns:
- the list of fields.
-
isAttributeAllowed
Description copied from interface:CMSItemAttributeFilterEnablerServiceVerifies whether the attribute is allowed or not.- Specified by:
isAttributeAllowedin interfaceCMSItemAttributeFilterEnablerService- Parameters:
typeCode- the type code where the attribute existsattribute- the attribute qualifier.- Returns:
- true if the attribute is allowed, false otherwise
-
setMode
Description copied from interface:CMSItemAttributeFilterEnablerServiceMethod saves the mode that should be used to retrieve the list of attributes to the session.- Specified by:
setModein interfaceCMSItemAttributeFilterEnablerService- Parameters:
mode- the mode that should be used to retrieve the list of attributes.
-
getMode
Description copied from interface:CMSItemAttributeFilterEnablerServiceMethod retrieves the attribute mode from the session.- Specified by:
getModein interfaceCMSItemAttributeFilterEnablerService- Returns:
- the mode, null if mode has not been set.
-
clearCache
Description copied from interface:CMSItemAttributeFilterEnablerServiceClear the cache that stores the configuration.- Specified by:
clearCachein interfaceCMSItemAttributeFilterEnablerService- Throws:
InterruptedException- if thread is interrupted
-
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
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 typemode- 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 ofCMSItemModel.- Parameters:
definedConfigs- user based configurations- Returns:
- the list of
DefaultCMSItemAttributeFilterEnablerService.TypeConfigurationconfigurations 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.TypeConfigurationconfigurations 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 itemprebuildConfigs- the user defined configs- Returns:
- the optional
DefaultCMSItemAttributeFilterEnablerService.TypeConfiguration
-
compileAttributes
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
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
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
Verifies whether the attribute is a reference attribute. If the attribute containsCMS_ITEM_ATTRIBUTE_FILTER_REFERENCE_SEPARATORit 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
Verifies whether the value represents a type.- Parameters:
value- the value to verify.- Returns:
- true if the value represents the type, false otherwise.
-
isMode
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
Returns all configurations by its type.- Parameters:
typeCode- the type for which configurations will be returned.- Returns:
- the list of configurations.
-
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
-
setCmsItemTypeAttributeFilterConfigDao
public void setCmsItemTypeAttributeFilterConfigDao(CMSItemTypeAttributeFilterConfigDao cmsItemTypeAttributeFilterConfigDao) -
getTypeService
-
setTypeService
-
getSessionService
-
setSessionService
-
getConfigurationService
-
setConfigurationService
-