Class DefaultCMSContentPageService

All Implemented Interfaces:
CMSContentPageService, Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

public class DefaultCMSContentPageService extends AbstractCMSPageService implements CMSContentPageService
Default implementation of the CMSContentPageService
See Also:
  • Field Details

  • Constructor Details

    • DefaultCMSContentPageService

      public DefaultCMSContentPageService()
  • Method Details

    • getDefaultPageForLabel

      public ContentPageModel getDefaultPageForLabel(String label, CatalogVersionModel version) throws CMSItemNotFoundException
      Description copied from interface: CMSContentPageService
      Gets the default page by label and catalog version.
      Specified by:
      getDefaultPageForLabel in interface CMSContentPageService
      Parameters:
      label - the label
      version - the version
      Returns:
      the default page by label
      Throws:
      CMSItemNotFoundException - thrown when item was not found
    • getHomepage

      public ContentPageModel getHomepage()
      Description copied from interface: CMSContentPageService
      Gets the homepage
      Specified by:
      getHomepage in interface CMSContentPageService
      Returns:
      the homepage model
    • getHomepageInternal

      protected ContentPageModel getHomepageInternal()
      Gets the homepage by finding all content pages having ContentPageModel#isHomepage() equals TRUE, in all the catalog versions saved in the session.
      In the multi-country scenario, the list of catalog versions contains the catalog versions hierarchy for the active site.

      CMS restrictions will be evaluated on the homepage to ensure that the proper primary or variation page is returned.

      Returns:
      the homepage model
    • getHomepage

      public ContentPageModel getHomepage(PagePreviewCriteriaData pagePreviewCriteria)
      Description copied from interface: CMSContentPageService
      Returns homepage for PagePreviewCriteriaData.
      Specified by:
      getHomepage in interface CMSContentPageService
      Parameters:
      pagePreviewCriteria - the PagePreviewCriteriaData object.
      Returns:
      the homepage model
    • getPageForLabelAndPreview

      public ContentPageModel getPageForLabelAndPreview(String label, PagePreviewCriteriaData pagePreviewCriteria) throws CMSItemNotFoundException
      Description copied from interface: CMSContentPageService
      Gets the page for label and PagePreviewCriteriaData.
      Specified by:
      getPageForLabelAndPreview in interface CMSContentPageService
      Parameters:
      label - the label
      pagePreviewCriteria - the PagePreviewCriteriaData object.
      Returns:
      the page for label
      Throws:
      CMSItemNotFoundException - thrown when item is not found
    • getPageForLabelAndStatuses

      public ContentPageModel getPageForLabelAndStatuses(String label, List<CmsPageStatus> pageStatuses) throws CMSItemNotFoundException
      Description copied from interface: CMSContentPageService
      Gets the page for label by page status.
      Specified by:
      getPageForLabelAndStatuses in interface CMSContentPageService
      Parameters:
      label - the label
      pageStatuses - the page statuses. i.e. (deleted, active)
      Returns:
      the page for label
      Throws:
      CMSItemNotFoundException - thrown when item was not found
    • getPageForLabel

      protected ContentPageModel getPageForLabel(String label, List<CmsPageStatus> pageStatuses, boolean exactLabelMatch) throws CMSItemNotFoundException
      Gets the page for label by page status and label match type. When exactLabelMatch is TRUE, the page is found by matching exactly the provided labelOrId. Otherwise, the page containing a label that closely matches the provided labelOrId is returned instead.
      Parameters:
      label - the label
      pageStatuses - the page statuses. i.e. (deleted, active)
      exactLabelMatch - determines if the label of the result page should exactly match the provided labelOrId or not.
      Returns:
      the page for label
      Throws:
      CMSItemNotFoundException - thrown when item was not found
    • getSingleContentPage

      protected ContentPageModel getSingleContentPage(List<String> labels)
    • getSessionContentCatalogVersions

      protected Collection<CatalogVersionModel> getSessionContentCatalogVersions()
      Finds all catalog versions related to a content catalog that are saved in the session.
      Returns:
      a list of catalog versions related to a content catalog
    • getContentCatalogVersions

      protected Collection<CatalogVersionModel> getContentCatalogVersions()
      Finds all content catalog versions. If there is a preview content catalog version, it should return the intersection of preview Hierarchy and session.
      Returns:
      a list of catalog versions related to a content catalog
    • getContentCatalogVersionsOfHomepage

      protected Collection<CatalogVersionModel> getContentCatalogVersionsOfHomepage()
      For multiple content catalog, when content catalogVersions are not relatives, that's mean this request is come from storefront and may have multiple homepage in those content catalogs. If it set the default content catalog, it should use homepage of the default content catalog as the site homepage.
      Returns:
      a list of catalog versions
    • findPagesForBestLabelMatch

      public List<AbstractPageModel> findPagesForBestLabelMatch(Collection<AbstractPageModel> pages, List<String> labels)
      Description copied from interface: CMSContentPageService
      Finds all pages that matches one of the provided labels. Best page match is chosen by sorting the pages by their label (longest label first). When multiple pages have the same label size, then the first created page is chosen.
      Specified by:
      findPagesForBestLabelMatch in interface CMSContentPageService
      Parameters:
      pages - the list of pages to filter to find best matches
      labels - the list of labels used for filtering for best page matches
      Returns:
      pages exactly or best match the provided labels
    • findLabelVariations

      public List<String> findLabelVariations(String label, boolean exactLabelMatch)
      Description copied from interface: CMSContentPageService
      Find possible variations of the provided label by splitting the sections using the slash as delimiter. The result list is sorted by the length of the label, starting with the longest label variation first. The result list also includes the provided label.
      Specified by:
      findLabelVariations in interface CMSContentPageService
      Parameters:
      label - the label from which the variations are generated
      exactLabelMatch - determines if the label of the result page should exactly match the provided label or not.
      Returns:
      list of label variations, including the provided label
    • findBestMatchLabelVariations

      protected List<String> findBestMatchLabelVariations(String label, List<String> labels)
      Find possible variations of the provided label by splitting the sections using the slash as delimiter. The result list is sorted by the length of the label, starting with the longest label variation first. The result list also includes the provided label.
      Parameters:
      label - the label from which the variations are generated
      labels - the list of label variations
      Returns:
      list of label variations, including the provided label
    • getPageForLabelOrIdAndMatchType

      public ContentPageModel getPageForLabelOrIdAndMatchType(String labelOrId, boolean exactLabelMatch) throws CMSItemNotFoundException
      Description copied from interface: CMSContentPageService
      Gets the page for label or id. When exactLabelMatch is TRUE, the page is found by matching exactly the provided labelOrId. Otherwise, the page containing a label that closely matches the provided labelOrId is returned instead.
      Specified by:
      getPageForLabelOrIdAndMatchType in interface CMSContentPageService
      Parameters:
      labelOrId - the label or id
      exactLabelMatch - determines if the label of the result page should exactly match the provided labelOrId or not.
      Returns:
      the page for label or id
      Throws:
      CMSItemNotFoundException - thrown when page was not found
    • getPageForLabelOrIdAndMatchType

      public ContentPageModel getPageForLabelOrIdAndMatchType(String labelOrId, PagePreviewCriteriaData pagePreviewCriteria, boolean exactLabelMatch) throws CMSItemNotFoundException
      Description copied from interface: CMSContentPageService
      Gets the page matching the provided for label or id filtered by the PagePreviewCriteriaData information. When exactLabelMatch is TRUE, the page is found by matching exactly the provided labelOrId. Otherwise, the page containing a label that closely matches the provided labelOrId is returned instead.
      Specified by:
      getPageForLabelOrIdAndMatchType in interface CMSContentPageService
      Parameters:
      labelOrId - the label or id
      pagePreviewCriteria - the PagePreviewCriteriaData object.
      exactLabelMatch - determines if the label of the result page should exactly match the provided labelOrId or not.
      Returns:
      the page matching the search criteria
      Throws:
      CMSItemNotFoundException - thrown when no page is found
    • getCmsItemCatalogLevelComparator

      protected Comparator<AbstractPageModel> getCmsItemCatalogLevelComparator()
      Overrides:
      getCmsItemCatalogLevelComparator in class AbstractCMSPageService
    • setCmsItemCatalogLevelComparator

      public void setCmsItemCatalogLevelComparator(Comparator<AbstractPageModel> cmsItemCatalogLevelComparator)
      Overrides:
      setCmsItemCatalogLevelComparator in class AbstractCMSPageService
    • setCmsSiteService

      public void setCmsSiteService(CMSSiteService cmsSiteService)
    • getCmsSiteService

      protected CMSSiteService getCmsSiteService()
    • getCmsCatalogVersionService

      protected CMSCatalogVersionService getCmsCatalogVersionService()
    • setCmsCatalogVersionService

      public void setCmsCatalogVersionService(CMSCatalogVersionService cmsCatalogVersionService)
    • getCmsPreviewService

      public CMSPreviewService getCmsPreviewService()
    • setCmsPreviewService

      public void setCmsPreviewService(CMSPreviewService cmsPreviewService)