Class DefaultCMSItemFacade

java.lang.Object
de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCMSItemFacade
All Implemented Interfaces:
CMSItemFacade

public class DefaultCMSItemFacade extends Object implements CMSItemFacade
Default implementation of the CMSItemFacade.
  • Field Details

    • IGNORE_PART_OF_CONSTRAINT_FOR_TYPE_CODE

      public static final String IGNORE_PART_OF_CONSTRAINT_FOR_TYPE_CODE
      See Also:
    • convertedItem

      protected ThreadLocal<Map<String,Object>> convertedItem
      Thread safe temporary storage of a convertedItem just before explicitly rollbacking the transaction in dryRun mode
  • Constructor Details

    • DefaultCMSItemFacade

      public DefaultCMSItemFacade()
  • Method Details

    • findCMSItems

      public SearchResult<Map<String,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 interface CMSItemFacade
      Parameters:
      cmsItemSearchData - The catalog and filter information
      pageableData - The paging information
      Returns:
      A SearchResult containing the paging information and the results
    • findCMSItems

      public List<Map<String,Object>> findCMSItems(List<String> uuids) throws CMSItemNotFoundException
      Description copied from interface: CMSItemFacade
      A Search for CMSItems by their universally unique identifiers
      Specified by:
      findCMSItems in interface CMSItemFacade
      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
    • findCMSItems

      public List<Map<String,Object>> findCMSItems(List<String> uuids, String mode) throws CMSItemNotFoundException
      Description copied from interface: CMSItemFacade
      A Search for CMSItems by their universally unique identifiers.
      Specified by:
      findCMSItems in interface CMSItemFacade
      Parameters:
      uuids - - the list of uuids of the CMSItems to look for
      mode - - list of fields, which should be returned in response
      Returns:
      A list of the corresponding CMSItems
      Throws:
      CMSItemNotFoundException - if the item is not found
    • getCMSItemByUuid

      public Map<String,Object> getCMSItemByUuid(String uuid) throws CMSItemNotFoundException
      Get one single CMSItem by its uuid (Universal Unique Identifier) For more information about Unique Identifiers, see UniqueItemIdentifierService
      Specified by:
      getCMSItemByUuid in interface CMSItemFacade
      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 given uuid.
    • getCMSItemByUuid

      public Map<String,Object> getCMSItemByUuid(String uuid, String mode) throws CMSItemNotFoundException
      Description copied from interface: CMSItemFacade
      Get one single CMSItem by its uuid (Universal Unique Identifier) For more information about Unique Identifiers, see UniqueItemIdentifierService
      Specified by:
      getCMSItemByUuid in interface CMSItemFacade
      Parameters:
      uuid - - the universal unique identifier
      mode - - list of fields, which should be returned in response
      Returns:
      the Map<String, Object> representation of the CMS Item
      Throws:
      CMSItemNotFoundException - when a CMS Item can not be found for a given uuid.
    • getCMSItemByUuid

      protected Map<String,Object> getCMSItemByUuid(String uuid, boolean throwException)
      Get one single CMSItem by its uuid (Universal Unique Identifier)
      For more information about Unique Identifiers, see UniqueItemIdentifierService
      Parameters:
      uuid - the universal unique identifier
      throwException - 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 be NULL when user does not have READ permission for the type of the CMS Item and throwException is FALSE
      Throws:
      CMSItemNotFoundException - when a CMS Item can not be found for a given uui
      TypePermissionException - when user does not have READ permission for the type of the CMS Item.
    • createItem

      public Map<String,Object> createItem(Map<String,Object> itemMap) throws CMSItemNotFoundException
      Create CMS Items given the attribute value map.
      Specified by:
      createItem in interface CMSItemFacade
      Parameters:
      itemMap - - the Map<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 given uuid.
    • updateItem

      public Map<String,Object> updateItem(String uuid, Map<String,Object> itemMap) throws CMSItemNotFoundException
      Updates a CMS Item given the attribute value map and its uuid. For more information about Unique Identifiers, see UniqueItemIdentifierService
      Specified by:
      updateItem in interface CMSItemFacade
      Parameters:
      uuid - - the universal unique identifier
      itemMap - - the Map<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 given uuid.
    • buildCMSItemConvertAndPopulate

      protected Map<String,Object> buildCMSItemConvertAndPopulate(String uuid, boolean throwException)
    • initialUpdateValidation

      protected void initialUpdateValidation(String uuid, Map<String,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 identifier
      itemMap - the itemMap representation of the item model.
      Throws:
      CMSItemNotFoundException - when the item does not exist.
    • saveItem

      protected Map<String,Object> saveItem(Map<String,Object> itemMap, Predicate<String> typePermissionPredicate, 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 saved
      typePermissionPredicate - the predicate to evaluate the type permissions for the current user
      permissionName - the operation user wants to perform on the item; possible values can be found in PermissionsConstants
      Returns:
      the item Map representation after saving.
      Throws:
      CMSItemNotFoundException - when an item for a given uid does not exist
    • buildContextForItem

      protected Map<String,Object> buildContextForItem(Map<String,Object> itemMap)
    • transformValidationException

      protected void transformValidationException(ModelSavingException error)
      Parses the ModelSavingException and transforms it into validation error(s).
      Parameters:
      error - the ModelSavingException
    • convertAndPopulate

      protected ItemModel convertAndPopulate(Map<String,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 Map<String,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(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 interface CMSItemFacade
      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 given uuid.
    • validateItemForUpdate

      public Map<String,Object> validateItemForUpdate(String uuid, Map<String,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, see UniqueItemIdentifierService
      Specified by:
      validateItemForUpdate in interface CMSItemFacade
      Parameters:
      uuid - - the universal unique identifier
      itemMap - - the Map<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 given uuid.
    • validateItemForCreate

      public Map<String,Object> validateItemForCreate(Map<String,Object> itemMap) throws CMSItemNotFoundException
      Description copied from interface: CMSItemFacade
      Validates CMS Items given the attribute value map.
      Specified by:
      validateItemForCreate in interface CMSItemFacade
      Parameters:
      itemMap - - the Map<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 given uuid.
    • validateItem

      protected Map<String,Object> validateItem(Map<String,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(String uuid)
      Parameters:
      uuid - The string representing the UUID of the item not found.
      Returns:
      the new exception.
    • buildContextForValidItem

      protected void buildContextForValidItem(Map<String,Object> itemMap, Boolean uuidProvided, Boolean uidProvided)
    • createTypePermissionException

      protected TypePermissionException createTypePermissionException(String permissionName, String itemType)
      Creates a new TypePermissionException with a localized error message
      Parameters:
      permissionName - The permission name defined by PermissionsConstants
      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(Map<String,Object> source) throws CMSItemNotFoundException
      Sets the catalogVersion in the current session.
      Parameters:
      source -
      Throws:
      CMSItemNotFoundException
    • setCloneContext

      protected void setCloneContext(Map<String,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(Map<String,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 the RelatedPageRejectionService should not save this item part of its processing.
      Parameters:
      source -
    • getOriginalItemUuid

      protected Optional<String> getOriginalItemUuid(Map<String,Object> source)
      Method returns original uuid for an item in the payload. Important: even if the UUID exists in the payload it's not always the uuid of the original item. For example: while cloning component the payload contains FIELD_PAGE_UUID but it can not be considered as original item
      Parameters:
      source - the source object.
      Returns:
      the optional UUID of the item, empty if there is no original uuid.
    • setRestoreContext

      protected void setRestoreContext(Map<String,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)
    • getCmsItemAttributeFilterEnablerService

      public CMSItemAttributeFilterEnablerService getCmsItemAttributeFilterEnablerService()
    • setCmsItemAttributeFilterEnablerService

      public void setCmsItemAttributeFilterEnablerService(CMSItemAttributeFilterEnablerService cmsItemAttributeFilterEnablerService)