Interface SiteRootSelectionStrategy


  • @ConsumerType
    public interface SiteRootSelectionStrategy
    Consumers may implement this interface and register the implementation as an OSGI service to provide an algorithm that defines a site root for a given page.

    A site root is the Page that is the common ancestor of all Pages that belong to a single site. In a single-country setup this is the parent of all language roots. For a multi-country setup it may be different, depending on the content structure.

    A default implementation is available called DefaultSiteRootSelectionStrategy. To override it an implementation must be registered with a service ranking greater then 0. Implementations may fall back to the DefaultSiteRootSelectionStrategy. If they are not able to return a site root for a given Page the LanguageAlternativesService cannot return any language alternatives.

    • Method Detail

      • getSiteRoot

        @Nullable
        @Nullable Page getSiteRoot​(@NotNull
                                   @NotNull Page page)
        Returns the common ancestor of all Pages with in the site the given Page.
        Parameters:
        page - a Page within a site
        Returns:
        the root Page of the site
      • getStructuralDepth

        int getStructuralDepth​(@NotNull
                               @NotNull Page page)
        Returns the depth of the content structure managed under the site root.

        This defines the number of levels the LanguageAlternativesService traverses to collect language roots.

        Examples:

        • With /content/site as site root and /content/site/en as language root the structural depth is 1
        • With /content/site as site root, an intermediate level and a language root at /content/site/us/en, the structural depth is 2
        • With /content/site as site root, multiple intermediate levels and a language root at /content/site/emea/europe/germany/de the structural depth is 4

        Parameters:
        page - a Page within a site
        Returns:
        an int greater or equal to one