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>>
convertedItem
Thread 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 ItemModel
convertAndPopulate(java.util.Map<java.lang.String,java.lang.Object> itemMap)
Converts and populates model to saveprotected CMSItemNotFoundException
createCMSItemNotFoundException(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 TypePermissionException
createTypePermissionException(java.lang.String permissionName, java.lang.String itemType)
Creates a newTypePermissionException
with a localized error messagevoid
deleteCMSItemByUuid(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 CatalogVersionService
getCatalogVersionService()
protected CMSAdminSiteService
getCmsAdminSiteService()
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, seeUniqueItemIdentifierService
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
protected CMSItemConverter
getCmsItemConverter()
protected Converter<CMSItemSearchData,CMSItemSearchData>
getCmsItemSearchDataConverter()
protected org.springframework.validation.Validator
getCmsItemSearchDataValidator()
protected CMSItemSearchService
getCmsItemSearchService()
protected FacadeValidationService
getFacadeValidationService()
protected ItemDataPopulatorProvider
getItemDataPopulatorProvider()
protected ItemTypePopulatorProvider
getItemTypePopulatorProvider()
protected ModelService
getModelService()
protected OriginalClonedItemProvider
getOriginalClonedItemProvider()
protected PermissionCRUDService
getPermissionCRUDService()
SessionSearchRestrictionsDisabler
getSessionSearchRestrictionsDisabler()
protected org.springframework.transaction.PlatformTransactionManager
getTransactionManager()
protected TypeService
getTypeService()
protected UniqueItemIdentifierService
getUniqueItemIdentifierService()
protected ValidationErrorsProvider
getValidationErrorsProvider()
protected void
initialUpdateValidation(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 void
setCatalogInSession(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the catalogVersion in the current session.void
setCatalogVersionService(CatalogVersionService catalogVersionService)
protected void
setCloneContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the clone context in the current session.void
setCmsAdminSiteService(CMSAdminSiteService cmsAdminSiteService)
void
setCmsItemConverter(CMSItemConverter cmsItemConverter)
void
setCmsItemSearchDataConverter(Converter<CMSItemSearchData,CMSItemSearchData> cmsItemSearchDataConverter)
void
setCmsItemSearchDataValidator(org.springframework.validation.Validator cmsItemSearchDataValidator)
void
setCmsItemSearchService(CMSItemSearchService cmsItemSearchService)
void
setFacadeValidationService(FacadeValidationService facadeValidationService)
void
setItemDataPopulatorProvider(ItemDataPopulatorProvider itemDataPopulatorProvider)
void
setItemTypePopulatorProvider(ItemTypePopulatorProvider itemTypePopulatorProvider)
void
setModelService(ModelService modelService)
void
setOriginalClonedItemProvider(OriginalClonedItemProvider originalClonedItemProvider)
protected void
setOriginalItemContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the original item context in the current session.void
setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
protected void
setRestoreContext(java.util.Map<java.lang.String,java.lang.Object> source)
Sets the restore context in the current session.void
setSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler sessionSearchRestrictionsDisabler)
void
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
void
setTypeService(TypeService typeService)
void
setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
void
setValidationErrorsProvider(ValidationErrorsProvider validationErrorsProvider)
protected void
transformValidationException(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:CMSItemFacade
A paged Search for CMSItems in a given catalogversion. Optionally filter by name/uid or typeCode- Specified by:
findCMSItems
in 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 CMSItemNotFoundException
Description copied from interface:CMSItemFacade
A Search for CMSItems by their universally unique identifiers- Specified by:
findCMSItems
in 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 CMSItemNotFoundException
Get one single CMSItem by its uuid (Universal Unique Identifier) For more information about Unique Identifiers, seeUniqueItemIdentifierService
- Specified by:
getCMSItemByUuid
in 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 beNULL
when user does not have READ permission for the type of the CMS Item andthrowException
isFALSE
- 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 CMSItemNotFoundException
Create CMS Items given the attribute value map.- Specified by:
createItem
in 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 CMSItemNotFoundException
Updates a CMS Item given the attribute value map and its uuid. For more information about Unique Identifiers, seeUniqueItemIdentifierService
- Specified by:
updateItem
in 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 CMSItemNotFoundException
Checks 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 CMSItemNotFoundException
Deletes one single CMSItem by its uuid (Universal Unique Identifier)
The deleted CMS item will be versioned.- Specified by:
deleteCMSItemByUuid
in 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 CMSItemNotFoundException
Description copied from interface:CMSItemFacade
Validates a CMS Item given the attribute value map and its uuid. For more information about Unique Identifiers, seeUniqueItemIdentifierService
- Specified by:
validateItemForUpdate
in 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 CMSItemNotFoundException
Description copied from interface:CMSItemFacade
Validates CMS Items given the attribute value map.- Specified by:
validateItemForCreate
in 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 newTypePermissionException
with a localized error message- Parameters:
permissionName
- The permission name defined byPermissionsConstants
itemType
- 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 CMSItemNotFoundException
Sets 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 theRelatedPageRejectionService
should 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)
-
-