Class DefaultCMSItemFacade

    • Field Detail

      • convertedItem

        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 Detail

      • DefaultCMSItemFacade

        public DefaultCMSItemFacade()
    • 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 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 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 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
      • 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, 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

        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, 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 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 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 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, 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.
      • 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 identifier
        itemMap - 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 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
      • 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 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 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, 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 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 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 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)
        Parameters:
        uuid - The string representing the UUID of the item not found.
        Returns:
        the new exception.
      • setCmsItemConverter

        public void setCmsItemConverter​(CMSItemConverter cmsItemConverter)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • 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 the RelatedPageRejectionService 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 -
      • setItemTypePopulatorProvider

        public void setItemTypePopulatorProvider​(ItemTypePopulatorProvider itemTypePopulatorProvider)
      • setCmsItemSearchService

        public void setCmsItemSearchService​(CMSItemSearchService cmsItemSearchService)
      • getCmsItemSearchDataValidator

        protected org.springframework.validation.Validator getCmsItemSearchDataValidator()
      • setCmsItemSearchDataValidator

        public void setCmsItemSearchDataValidator​(org.springframework.validation.Validator cmsItemSearchDataValidator)
      • setFacadeValidationService

        public void setFacadeValidationService​(FacadeValidationService facadeValidationService)
      • 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)
      • setCmsAdminSiteService

        public void setCmsAdminSiteService​(CMSAdminSiteService cmsAdminSiteService)
      • getTypeService

        protected TypeService getTypeService()
      • setTypeService

        public void setTypeService​(TypeService typeService)
      • setOriginalClonedItemProvider

        public void setOriginalClonedItemProvider​(OriginalClonedItemProvider originalClonedItemProvider)
      • setItemDataPopulatorProvider

        public void setItemDataPopulatorProvider​(ItemDataPopulatorProvider itemDataPopulatorProvider)
      • setPermissionCRUDService

        public void setPermissionCRUDService​(PermissionCRUDService permissionCRUDService)