Class DefaultCMSItemFacade
- java.lang.Object
-
- de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemFacade
-
- All Implemented Interfaces:
CMSItemFacade
public class DefaultCMSItemFacade extends java.lang.Object implements CMSItemFacade
Default implementation of theCMSItemFacade.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ThreadLocal<java.util.Map<java.lang.String,java.lang.Object>>convertedItemThread safe temporary storage of a convertedItem just before explicitly rollbacking the transaction in dryRun mode
-
Constructor Summary
Constructors Constructor Description DefaultCMSItemFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.Object>convertAndPopulate(CMSItemModel itemModel)Converts and populates Map to return to the frontend.protected ItemModelconvertAndPopulate(java.util.Map<java.lang.String,java.lang.Object> itemMap)Converts and populates model to saveprotected CMSItemNotFoundExceptioncreateCMSItemNotFoundException(java.lang.String uuid)Creates a newCMSItemNotFoundException.java.util.Map<java.lang.String,java.lang.Object>createItem(java.util.Map<java.lang.String,java.lang.Object> itemMap)Create CMS Items given the attribute value map.protected TypePermissionExceptioncreateTypePermissionException(java.lang.String permissionName, java.lang.String itemType)Creates a newTypePermissionExceptionwith a localized error messagevoiddeleteCMSItemByUuid(java.lang.String uuid)Deletes one single CMSItem by its uuid (Universal Unique Identifier)SearchResult<java.util.Map<java.lang.String,java.lang.Object>>findCMSItems(CMSItemSearchData cmsItemSearchData, PageableData pageableData)A paged Search for CMSItems in a given catalogversion.java.util.List<java.util.Map<java.lang.String,java.lang.Object>>findCMSItems(java.util.List<java.lang.String> uuids)A Search for CMSItems by their universally unique identifiersprotected CatalogVersionServicegetCatalogVersionService()protected CMSAdminSiteServicegetCmsAdminSiteService()java.util.Map<java.lang.String,java.lang.Object>getCMSItemByUuid(java.lang.String uuid)Get one single CMSItem by its uuid (Universal Unique Identifier) For more information about Unique Identifiers, seeUniqueItemIdentifierServiceprotected java.util.Map<java.lang.String,java.lang.Object>getCMSItemByUuid(java.lang.String uuid, boolean throwException)Get one single CMSItem by its uuid (Universal Unique Identifier)
For more information about Unique Identifiers, seeUniqueItemIdentifierServiceprotected CMSItemConvertergetCmsItemConverter()protected Converter<CMSItemSearchData,CMSItemSearchData>getCmsItemSearchDataConverter()protected org.springframework.validation.ValidatorgetCmsItemSearchDataValidator()protected CMSItemSearchServicegetCmsItemSearchService()protected FacadeValidationServicegetFacadeValidationService()protected ItemDataPopulatorProvidergetItemDataPopulatorProvider()protected ItemTypePopulatorProvidergetItemTypePopulatorProvider()protected ModelServicegetModelService()protected OriginalClonedItemProvidergetOriginalClonedItemProvider()protected PermissionCRUDServicegetPermissionCRUDService()SessionSearchRestrictionsDisablergetSessionSearchRestrictionsDisabler()protected org.springframework.transaction.PlatformTransactionManagergetTransactionManager()protected TypeServicegetTypeService()protected UniqueItemIdentifierServicegetUniqueItemIdentifierService()protected ValidationErrorsProvidergetValidationErrorsProvider()protected voidinitialUpdateValidation(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap)Checks if an item exists.protected java.util.Map<java.lang.String,java.lang.Object>saveItem(java.util.Map<java.lang.String,java.lang.Object> itemMap, java.util.function.Predicate<java.lang.String> typePermissionPredicate, java.lang.String permissionName)Saves Item using a local transaction.protected voidsetCatalogInSession(java.util.Map<java.lang.String,java.lang.Object> source)Sets the catalogVersion in the current session.voidsetCatalogVersionService(CatalogVersionService catalogVersionService)protected voidsetCloneContext(java.util.Map<java.lang.String,java.lang.Object> source)Sets the clone context in the current session.voidsetCmsAdminSiteService(CMSAdminSiteService cmsAdminSiteService)voidsetCmsItemConverter(CMSItemConverter cmsItemConverter)voidsetCmsItemSearchDataConverter(Converter<CMSItemSearchData,CMSItemSearchData> cmsItemSearchDataConverter)voidsetCmsItemSearchDataValidator(org.springframework.validation.Validator cmsItemSearchDataValidator)voidsetCmsItemSearchService(CMSItemSearchService cmsItemSearchService)voidsetFacadeValidationService(FacadeValidationService facadeValidationService)voidsetItemDataPopulatorProvider(ItemDataPopulatorProvider itemDataPopulatorProvider)voidsetItemTypePopulatorProvider(ItemTypePopulatorProvider itemTypePopulatorProvider)voidsetModelService(ModelService modelService)voidsetOriginalClonedItemProvider(OriginalClonedItemProvider originalClonedItemProvider)protected voidsetOriginalItemContext(java.util.Map<java.lang.String,java.lang.Object> source)Sets the original item context in the current session.voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService)protected voidsetRestoreContext(java.util.Map<java.lang.String,java.lang.Object> source)Sets the restore context in the current session.voidsetSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler sessionSearchRestrictionsDisabler)voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)voidsetTypeService(TypeService typeService)voidsetUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)voidsetValidationErrorsProvider(ValidationErrorsProvider validationErrorsProvider)protected voidtransformValidationException(ModelSavingException error)Parses the ModelSavingException and transforms it into validation error(s).java.util.Map<java.lang.String,java.lang.Object>updateItem(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap)Updates a CMS Item given the attribute value map and its uuid.protected java.util.Map<java.lang.String,java.lang.Object>validateItem(java.util.Map<java.lang.String,java.lang.Object> itemMap)Validates and convert the item for the sole purpose of validation.java.util.Map<java.lang.String,java.lang.Object>validateItemForCreate(java.util.Map<java.lang.String,java.lang.Object> itemMap)Validates CMS Items given the attribute value map.java.util.Map<java.lang.String,java.lang.Object>validateItemForUpdate(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap)Validates a CMS Item given the attribute value map and its uuid.
-
-
-
Method Detail
-
findCMSItems
public SearchResult<java.util.Map<java.lang.String,java.lang.Object>> findCMSItems(CMSItemSearchData cmsItemSearchData, PageableData pageableData)
Description copied from interface:CMSItemFacadeA paged Search for CMSItems in a given catalogversion. Optionally filter by name/uid or typeCode- Specified by:
findCMSItemsin interfaceCMSItemFacade- Parameters:
cmsItemSearchData- The catalog and filter informationpageableData- The paging information- Returns:
- A SearchResult containing the paging information and the results
-
findCMSItems
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> findCMSItems(java.util.List<java.lang.String> uuids) throws CMSItemNotFoundExceptionDescription copied from interface:CMSItemFacadeA Search for CMSItems by their universally unique identifiers- Specified by:
findCMSItemsin interfaceCMSItemFacade- Parameters:
uuids- The list of uuids of the CMSItems to look for- Returns:
- A list of the corresponding CMSItems
- Throws:
CMSItemNotFoundException- if the item is not found
-
getCMSItemByUuid
public java.util.Map<java.lang.String,java.lang.Object> getCMSItemByUuid(java.lang.String uuid) throws CMSItemNotFoundExceptionGet one single CMSItem by its uuid (Universal Unique Identifier) For more information about Unique Identifiers, seeUniqueItemIdentifierService- Specified by:
getCMSItemByUuidin interfaceCMSItemFacade- Parameters:
uuid- - the universal unique identifier- Returns:
- the
Map<String, Object>representation of the CMS Item - Throws:
TypePermissionException- when user does not have permission to read an instance of the given item type.CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
getCMSItemByUuid
protected java.util.Map<java.lang.String,java.lang.Object> getCMSItemByUuid(java.lang.String uuid, boolean throwException)Get one single CMSItem by its uuid (Universal Unique Identifier)
For more information about Unique Identifiers, seeUniqueItemIdentifierService- Parameters:
uuid- the universal unique identifierthrowException- determines if an exception is thrown or not if an item is not found for the given uuid- Returns:
- The CMS Item matching the provided uuid;
Can beNULLwhen user does not have READ permission for the type of the CMS Item andthrowExceptionisFALSE - Throws:
CMSItemNotFoundException- when a CMS Item can not be found for a given uuiTypePermissionException- when user does not have READ permission for the type of the CMS Item.
-
createItem
public java.util.Map<java.lang.String,java.lang.Object> createItem(java.util.Map<java.lang.String,java.lang.Object> itemMap) throws CMSItemNotFoundExceptionCreate CMS Items given the attribute value map.- Specified by:
createItemin interfaceCMSItemFacade- Parameters:
itemMap- - theMap<String, Object>that contains the attributes values for the new CMSItem.- Returns:
- the Map tha represents the newly created CMS Item.
- Throws:
TypePermissionException- when user does not have permission to create an instance of the given item type.CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
updateItem
public java.util.Map<java.lang.String,java.lang.Object> updateItem(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap) throws CMSItemNotFoundExceptionUpdates a CMS Item given the attribute value map and its uuid. For more information about Unique Identifiers, seeUniqueItemIdentifierService- Specified by:
updateItemin interfaceCMSItemFacade- Parameters:
uuid- - the universal unique identifieritemMap- - theMap<String, Object>that contains the attributes values for the new CMSItem.- Returns:
- the Map tha represents the newly created CMS Item.
- Throws:
TypePermissionException- when user does not have permission to update an instance of the given item type.CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
initialUpdateValidation
protected void initialUpdateValidation(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap) throws CMSItemNotFoundExceptionChecks if an item exists. If the item exists, then stores it in the local session for further validation.- Parameters:
uuid- the item unique identifieritemMap- the itemMap representation of the item model.- Throws:
CMSItemNotFoundException- when the item does not exist.
-
saveItem
protected java.util.Map<java.lang.String,java.lang.Object> saveItem(java.util.Map<java.lang.String,java.lang.Object> itemMap, java.util.function.Predicate<java.lang.String> typePermissionPredicate, java.lang.String permissionName)Saves Item using a local transaction. Any CMS items created or modified during this save operation will be versioned.- Parameters:
itemMap- the itemMap to be savedtypePermissionPredicate- the predicate to evaluate the type permissions for the current userpermissionName- the operation user wants to perform on the item; possible values can be found inPermissionsConstants- Returns:
- the item Map representation after saving.
- Throws:
CMSItemNotFoundException- when an item for a given uid does not exist
-
transformValidationException
protected void transformValidationException(ModelSavingException error)
Parses the ModelSavingException and transforms it into validation error(s).- Parameters:
error- the ModelSavingException
-
convertAndPopulate
protected ItemModel convertAndPopulate(java.util.Map<java.lang.String,java.lang.Object> itemMap)
Converts and populates model to save- Parameters:
itemMap- the Map representing the ItemModel to be converted and saved- Returns:
- the model ready to be saved
-
convertAndPopulate
protected java.util.Map<java.lang.String,java.lang.Object> convertAndPopulate(CMSItemModel itemModel)
Converts and populates Map to return to the frontend.- Parameters:
itemModel- the itemModel to be converted to the Map.- Returns:
- the itemMap ready to be consumed by frontend.
-
deleteCMSItemByUuid
public void deleteCMSItemByUuid(java.lang.String uuid) throws CMSItemNotFoundExceptionDeletes one single CMSItem by its uuid (Universal Unique Identifier)
The deleted CMS item will be versioned.- Specified by:
deleteCMSItemByUuidin interfaceCMSItemFacade- Parameters:
uuid- - the universal unique identifier- Throws:
TypePermissionException- when user does not have permission to remove an instance of the given item type.CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
validateItemForUpdate
public java.util.Map<java.lang.String,java.lang.Object> validateItemForUpdate(java.lang.String uuid, java.util.Map<java.lang.String,java.lang.Object> itemMap) throws CMSItemNotFoundExceptionDescription copied from interface:CMSItemFacadeValidates a CMS Item given the attribute value map and its uuid. For more information about Unique Identifiers, seeUniqueItemIdentifierService- Specified by:
validateItemForUpdatein interfaceCMSItemFacade- Parameters:
uuid- - the universal unique identifieritemMap- - theMap<String, Object>that contains the attributes values for the new CMSItem.- Returns:
- the Map that represents the CMS Item.
- Throws:
CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
validateItemForCreate
public java.util.Map<java.lang.String,java.lang.Object> validateItemForCreate(java.util.Map<java.lang.String,java.lang.Object> itemMap) throws CMSItemNotFoundExceptionDescription copied from interface:CMSItemFacadeValidates CMS Items given the attribute value map.- Specified by:
validateItemForCreatein interfaceCMSItemFacade- Parameters:
itemMap- - theMap<String, Object>that contains the attributes values for the new CMSItem.- Returns:
- the Map that represents the newly created CMS Item.
- Throws:
CMSItemNotFoundException- when a CMS Item can not be found for a givenuuid.
-
validateItem
protected java.util.Map<java.lang.String,java.lang.Object> validateItem(java.util.Map<java.lang.String,java.lang.Object> itemMap)
Validates and convert the item for the sole purpose of validation. The transaction will be rolled back at the end.- Parameters:
itemMap- the item model representation as a map- Returns:
- the converted item model into its representation after validation and conversion.
- Throws:
CMSItemNotFoundException- when any item in its map does not exist.
-
createCMSItemNotFoundException
protected CMSItemNotFoundException createCMSItemNotFoundException(java.lang.String uuid)
Creates a newCMSItemNotFoundException.- Parameters:
uuid- The string representing the UUID of the item not found.- Returns:
- the new exception.
-
createTypePermissionException
protected TypePermissionException createTypePermissionException(java.lang.String permissionName, java.lang.String itemType)
Creates a newTypePermissionExceptionwith a localized error message- Parameters:
permissionName- The permission name defined byPermissionsConstantsitemType- The type code of the item- Returns:
- a new
TypePermissionException
-
getCmsItemConverter
protected CMSItemConverter getCmsItemConverter()
-
setCmsItemConverter
public void setCmsItemConverter(CMSItemConverter cmsItemConverter)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getUniqueItemIdentifierService
protected UniqueItemIdentifierService getUniqueItemIdentifierService()
-
setUniqueItemIdentifierService
public void setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
setCatalogInSession
protected void setCatalogInSession(java.util.Map<java.lang.String,java.lang.Object> source) throws CMSItemNotFoundExceptionSets the catalogVersion in the current session.- Parameters:
source-- Throws:
CMSItemNotFoundException
-
setCloneContext
protected void setCloneContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the clone context in the current session. The clone context contains information about original catalog version.- Parameters:
source-
-
setOriginalItemContext
protected void setOriginalItemContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the original item context in the current session. The original item context is used to detect that the item is being modified by this facade class and that theRelatedPageRejectionServiceshould not save this item part of its processing.- Parameters:
source-
-
setRestoreContext
protected void setRestoreContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the restore context in the current session. The restore context contains information about whether to override while restore or not.- Parameters:
source-
-
getItemTypePopulatorProvider
protected ItemTypePopulatorProvider getItemTypePopulatorProvider()
-
setItemTypePopulatorProvider
public void setItemTypePopulatorProvider(ItemTypePopulatorProvider itemTypePopulatorProvider)
-
getCmsItemSearchService
protected CMSItemSearchService getCmsItemSearchService()
-
setCmsItemSearchService
public void setCmsItemSearchService(CMSItemSearchService cmsItemSearchService)
-
getCmsItemSearchDataValidator
protected org.springframework.validation.Validator getCmsItemSearchDataValidator()
-
setCmsItemSearchDataValidator
public void setCmsItemSearchDataValidator(org.springframework.validation.Validator cmsItemSearchDataValidator)
-
getFacadeValidationService
protected FacadeValidationService getFacadeValidationService()
-
setFacadeValidationService
public void setFacadeValidationService(FacadeValidationService facadeValidationService)
-
getCmsItemSearchDataConverter
protected Converter<CMSItemSearchData,CMSItemSearchData> getCmsItemSearchDataConverter()
-
setCmsItemSearchDataConverter
public void setCmsItemSearchDataConverter(Converter<CMSItemSearchData,CMSItemSearchData> cmsItemSearchDataConverter)
-
getValidationErrorsProvider
protected ValidationErrorsProvider getValidationErrorsProvider()
-
setValidationErrorsProvider
public void setValidationErrorsProvider(ValidationErrorsProvider validationErrorsProvider)
-
getTransactionManager
protected org.springframework.transaction.PlatformTransactionManager getTransactionManager()
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
getCatalogVersionService
protected CatalogVersionService getCatalogVersionService()
-
setCmsAdminSiteService
public void setCmsAdminSiteService(CMSAdminSiteService cmsAdminSiteService)
-
getCmsAdminSiteService
protected CMSAdminSiteService getCmsAdminSiteService()
-
getTypeService
protected TypeService getTypeService()
-
setTypeService
public void setTypeService(TypeService typeService)
-
getSessionSearchRestrictionsDisabler
public SessionSearchRestrictionsDisabler getSessionSearchRestrictionsDisabler()
-
setSessionSearchRestrictionsDisabler
public void setSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler sessionSearchRestrictionsDisabler)
-
getOriginalClonedItemProvider
protected OriginalClonedItemProvider getOriginalClonedItemProvider()
-
setOriginalClonedItemProvider
public void setOriginalClonedItemProvider(OriginalClonedItemProvider originalClonedItemProvider)
-
getItemDataPopulatorProvider
protected ItemDataPopulatorProvider getItemDataPopulatorProvider()
-
setItemDataPopulatorProvider
public void setItemDataPopulatorProvider(ItemDataPopulatorProvider itemDataPopulatorProvider)
-
getPermissionCRUDService
protected PermissionCRUDService getPermissionCRUDService()
-
setPermissionCRUDService
public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
-
-