Package org.apache.sling.sitemap

## Class SitemapUtil

- java.lang.Object
- - org.apache.sling.sitemap.SitemapUtil

    @ProviderType
    public final class SitemapUtil
    extends Object

A utility class to give access to common functionality used for sitemaps.

### Method Summary

All Methods Static Methods Concrete Methods
`static @NotNull Iterator<org.apache.sling.api.resource.Resource>` `findSitemapRoots​(org.apache.sling.api.resource.ResourceResolver resolver, String searchPath)` Returns all sitemap root `Resource`s within the given search path, excluding the search path itself even if it is a sitemap root.
`static @NotNull String` `getSitemapSelector​(@NotNull org.apache.sling.api.resource.Resource sitemapRoot, @NotNull org.apache.sling.api.resource.Resource topLevelSitemapRoot, @NotNull String name)` Returns the selector for the given sitemap root `Resource` and the given name.
`static @NotNull org.apache.sling.api.resource.Resource` `getTopLevelSitemapRoot​(@NotNull org.apache.sling.api.resource.Resource sitemapRoot)` Returns the `Resource` marked as sitemap root that is closest to the repository root starting with the given `Resource`.
`static boolean` `isSitemapRoot​(@Nullable org.apache.sling.api.resource.Resource resource)` Returns true when the given `Resource` is a sitemap root.
`static boolean` `isTopLevelSitemapRoot​(@Nullable org.apache.sling.api.resource.Resource resource)` Returns true when the given `Resource` is a top level sitemap root.
`static @Nullable org.apache.sling.api.resource.Resource` `normalizeSitemapRoot​(@Nullable org.apache.sling.api.resource.Resource resource)` Returns the parent of the given `Resource` when the `Resource`'s name is `JcrConstants.JCR_CONTENT`.
`static @NotNull Map<org.apache.sling.api.resource.Resource,​String>` `resolveSitemapRoots​(@NotNull org.apache.sling.api.resource.Resource topLevelSitemapRoot, @NotNull String sitemapSelector)` Resolves all sitemap root `Resource`s for the given selector within the given top level sitemap root `Resource`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getTopLevelSitemapRoot

    @NotNull
    public static @NotNull org.apache.sling.api.resource.Resource getTopLevelSitemapRoot​(@NotNull
                                                                                         @NotNull org.apache.sling.api.resource.Resource sitemapRoot)

Returns the `Resource` marked as sitemap root that is closest to the repository root starting with the given `Resource`.

Parameters:
  `sitemapRoot` -
Returns:

#### normalizeSitemapRoot

    @Nullable
    public static @Nullable org.apache.sling.api.resource.Resource normalizeSitemapRoot​(@Nullable
                                                                                        @Nullable org.apache.sling.api.resource.Resource resource)

Returns the parent of the given `Resource` when the `Resource`'s name is `JcrConstants.JCR_CONTENT`.

Parameters:
  `resource` -
Returns:

#### isSitemapRoot

    public static boolean isSitemapRoot​(@Nullable
                                        @Nullable org.apache.sling.api.resource.Resource resource)

Returns true when the given `Resource` is a sitemap root.

Parameters:
  `resource` -
Returns:

#### isTopLevelSitemapRoot

    public static boolean isTopLevelSitemapRoot​(@Nullable
                                                @Nullable org.apache.sling.api.resource.Resource resource)

Returns true when the given `Resource` is a top level sitemap root.

Parameters:
  `resource` -
Returns:

#### getSitemapSelector

    @NotNull
    public static @NotNull String getSitemapSelector​(@NotNull
                                                     @NotNull org.apache.sling.api.resource.Resource sitemapRoot,
                                                     @NotNull
                                                     @NotNull org.apache.sling.api.resource.Resource topLevelSitemapRoot,
                                                     @NotNull
                                                     @NotNull String name)

Returns the selector for the given sitemap root `Resource` and the given name.

Parameters:
  `sitemapRoot` -
  `topLevelSitemapRoot` -
  `name` -
Returns:

#### resolveSitemapRoots

    @NotNull
    public static @NotNull Map<org.apache.sling.api.resource.Resource,​String> resolveSitemapRoots​(@NotNull
                                                                                                        @NotNull org.apache.sling.api.resource.Resource topLevelSitemapRoot,
                                                                                                        @NotNull
                                                                                                        @NotNull String sitemapSelector)

Resolves all sitemap root `Resource`s for the given selector within the given top level sitemap root `Resource`. This is the inversion of `getSitemapSelector(Resource, Resource, String)` with sitemap root being a top level sitemap root.

The returned `Map` only contains `Resource`s, that are sitemap roots according to `isSitemapRoot(Resource)`. Each returned `Resource` is mapped to the name which when passed to `getSitemapSelector(Resource, Resource, String)` would return the same selector, omitting the optional multi-file index part.

As this resolution may be ambiguous, the returned `Map` is sorted with the sitemap root/name combinations closest to the top level sitemap root taking precedence.

Parameters:
  `topLevelSitemapRoot` -
  `sitemapSelector` -
Returns:
  a sorted `Map`

#### findSitemapRoots

    @NotNull
    public static @NotNull Iterator<org.apache.sling.api.resource.Resource> findSitemapRoots​(org.apache.sling.api.resource.ResourceResolver resolver,
                                                                                             String searchPath)

Returns all sitemap root `Resource`s within the given search path, excluding the search path itself even if it is a sitemap root.

The `Resource`s returned are normalized using `normalizeSitemapRoot(Resource)`.

Parameters:
  `resolver` -
  `searchPath` -
Returns: