Class ItemSynchronizationValidator

  • All Implemented Interfaces:
    org.springframework.validation.Validator

    public class ItemSynchronizationValidator
    extends java.lang.Object
    implements org.springframework.validation.Validator
    Validates that the items in SynchronizationData can be synchronized.

    Rules to determine if an item can be synchronized:

    • If the CmsItem is a page then it must be approved.
    • If the CmsItem is a slot it must be a shared slot or used within a page that is approved.
    • Otherwise, the CmsItem must only be used in shared slots or within a page that is approved.

    • Constructor Detail

      • ItemSynchronizationValidator

        public ItemSynchronizationValidator()
    • Method Detail

      • supports

        public boolean supports​(java.lang.Class<?> clazz)
        Specified by:
        supports in interface org.springframework.validation.Validator
      • validate

        public void validate​(java.lang.Object objToValidate,
                             org.springframework.validation.Errors errors)
        Specified by:
        validate in interface org.springframework.validation.Validator
      • isCmsItemApproved

        protected boolean isCmsItemApproved​(ItemModel itemModel)
        This method is called to determine if the given CMSItemModel is approved to be synchronized.
        Parameters:
        itemModel - The item to check if it has been approved to be synchronized.
        Returns:
        boolean True if the item is approved to be synchronized. False, otherwise.
      • isPage

        protected boolean isPage​(CMSItemModel itemModel)
        This method is used to determine if the given CMSItemModel is a page (is an instance of AbstractPageModel or one of its subclasses).
        Parameters:
        itemModel - The item to check if it is a page
        Returns:
        boolean True if the item is a page. False, otherwise.
      • isSlot

        protected boolean isSlot​(CMSItemModel itemModel)
        This method is used to determine if the given CMSItemModel is a slot.
        Parameters:
        itemModel - The item to check if it is a slot
        Returns:
        boolean True if the item is a slot. False, otherwise.
      • isPageApproved

        protected boolean isPageApproved​(CMSItemModel itemModel)
        This method is used to determine if a given page has been approved to be synchronized.
        Parameters:
        itemModel - The page to check if it has been approved.
        Returns:
        boolean True if the page has been approved. False, otherwise.
      • isSlotApproved

        protected boolean isSlotApproved​(CMSItemModel cmsItem)
        This method is used to determine if a given slot can be synchronized. This can only happen if the slot is a shared slot or if it's related to at least one page that is approved to be synchronized.
        Parameters:
        cmsItem - The slot to check if it can be synchronized.
        Returns:
        boolean True if the slot can be synchronized. False, otherwise.
      • isAnyRelatedPageApproved

        protected boolean isAnyRelatedPageApproved​(java.util.List<CMSItemModel> items)
        This method is used to check if there is at least one page approved to be synchronized in the given list.
        Parameters:
        items - The items where to look for pages.
        Returns:
        boolean True if at least one page is approved. False, otherwise.
      • areAllRelatedSlotsApproved

        protected boolean areAllRelatedSlotsApproved​(java.util.List<CMSItemModel> items)
        This method checks if all the slots in the given list are allowed to be synchronized. A slot can be synchronized if it is a shared slot or if it's related to at least one page that is approved to be synchronized.
        Parameters:
        items - The items where to look for the slots to check.
        Returns:
        boolean True if all the slots are approved. False, otherwise.
      • hasNoRelatedPages

        protected boolean hasNoRelatedPages​(java.util.List<CMSItemModel> items)
        This method is used to ensure there are no pages in the given list.
        Parameters:
        items - The items where to look for pages.
        Returns:
        boolean True if no pages were found in the given list. False, otherwise.
      • getItem

        protected ItemModel getItem​(ItemSynchronizationData itemSynchronizationData)
        This method is used to retrieve the ItemModel referenced by the given ItemSynchronizationData.
        Parameters:
        itemSynchronizationData - The object that contains the data that identifies the itemModel to retrieve
        Returns:
        the retrieved ItemModel.
      • setUniqueItemIdentifierService

        public void setUniqueItemIdentifierService​(UniqueItemIdentifierService uniqueItemIdentifierService)
      • setRelatedItemsService

        public void setRelatedItemsService​(RelatedItemsService relatedItemsService)
      • setCmsContentSlotPredicate

        public void setCmsContentSlotPredicate​(ContentSlotPredicate cmsContentSlotPredicate)