Class DefaultTrashContentPageValidator

  • All Implemented Interfaces:
    Validator<ContentPageModel>

    public class DefaultTrashContentPageValidator
    extends java.lang.Object
    implements Validator<ContentPageModel>
    Validator to ensure that a content page can be moved to trash. These are the scenarios that it checks: - It's possible to delete a homepage of a non-top level catalog. - It shouldn't be possible to delete a homepage in a top level catalog. - It should be possible to swap a homepage, even in a top level catalog.
    • Constructor Detail

      • DefaultTrashContentPageValidator

        public DefaultTrashContentPageValidator()
    • Method Detail

      • isPageBeingTrashed

        protected boolean isPageBeingTrashed​(ContentPageModel contentPageModel)
        This method checks if the provided page is being moved to the trash list.
        Parameters:
        contentPageModel - The page to check.
        Returns:
        true, if the page is being moved to the trash list. False, otherwise.
      • isPageUndeletable

        protected boolean isPageUndeletable​(ContentPageModel contentPageModel)
        This method checks if the provided page can be removed. A page cannot be removed if it's a default page and is the top level homepage.
        Parameters:
        contentPageModel - The page to be checked.
        Returns:
        true, if the page cannot be removed. False, otherwise.
      • isOrWasOnlyTopLevelHomepage

        protected boolean isOrWasOnlyTopLevelHomepage​(ContentPageModel contentPageModel)
        This method checks if the provided page is the top level homepage.
        Parameters:
        contentPageModel - The page to be checked
        Returns:
        true, if the page is the top level homepage. False, otherwise.
      • catalogDoesNotHaveFallbackHomepage

        protected boolean catalogDoesNotHaveFallbackHomepage​(ContentPageModel contentPageModel)
        This method checks if the current catalog does not have a fallback page. This is the case if the catalog is a top-level catalog and it does not have a homepage or the current homepage is the page that is being removed.
        Parameters:
        contentPageModel - The page that is being removed.
        Returns:
        true if the catalog does not have a fallback page, false otherwise.
      • addValidationError

        protected void addValidationError​(java.lang.String field,
                                          java.lang.String errorCode)
        This method pushes a new validation error.
        Parameters:
        field - The field affected by the error.
        errorCode - The code identifying the type of error.
      • setValidationErrorsProvider

        public void setValidationErrorsProvider​(ValidationErrorsProvider validationErrorsProvider)
      • setCmsAdminPageService

        public void setCmsAdminPageService​(CMSAdminPageService cmsAdminPageService)
      • setCatalogLevelService

        public void setCatalogLevelService​(CatalogLevelService catalogLevelService)