Package org.apache.sling.sitemap
Class SitemapUtil
- java.lang.Object
-
- org.apache.sling.sitemap.SitemapUtil
-
@ProviderType public final class SitemapUtil extends java.lang.Object
A utility class to give access to common functionality used for sitemaps.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull java.util.Iterator<Resource>
findSitemapRoots(ResourceResolver resolver, java.lang.String searchPath)
Returns all sitemap rootResource
s within the given search path, excluding the search path itself even if it is a sitemap root.static @NotNull java.lang.String
getSitemapSelector(@NotNull Resource sitemapRoot, @NotNull Resource topLevelSitemapRoot, @NotNull java.lang.String name)
Returns the selector for the given sitemap rootResource
and the given name.static @NotNull Resource
getTopLevelSitemapRoot(@NotNull Resource sitemapRoot)
static boolean
isSitemapRoot(@Nullable Resource resource)
Returns true when the givenResource
is a sitemap root.static boolean
isTopLevelSitemapRoot(@Nullable Resource resource)
Returns true when the givenResource
is a top level sitemap root.static @Nullable Resource
normalizeSitemapRoot(@Nullable Resource resource)
static @NotNull java.util.Map<Resource,java.lang.String>
resolveSitemapRoots(@NotNull Resource topLevelSitemapRoot, @NotNull java.lang.String sitemapSelector)
-
-
-
Method Detail
-
getTopLevelSitemapRoot
@NotNull public static @NotNull Resource getTopLevelSitemapRoot(@NotNull @NotNull Resource sitemapRoot)
Returns theResource
marked as sitemap root that is closest to the repository root starting with the givenResource
.- Parameters:
sitemapRoot
-- Returns:
-
normalizeSitemapRoot
@Nullable public static @Nullable Resource normalizeSitemapRoot(@Nullable @Nullable Resource resource)
- Parameters:
resource
-- Returns:
-
isSitemapRoot
public static boolean isSitemapRoot(@Nullable @Nullable Resource resource)
Returns true when the givenResource
is a sitemap root.- Parameters:
resource
-- Returns:
-
isTopLevelSitemapRoot
public static boolean isTopLevelSitemapRoot(@Nullable @Nullable Resource resource)
Returns true when the givenResource
is a top level sitemap root.- Parameters:
resource
-- Returns:
-
getSitemapSelector
@NotNull public static @NotNull java.lang.String getSitemapSelector(@NotNull @NotNull Resource sitemapRoot, @NotNull @NotNull Resource topLevelSitemapRoot, @NotNull @NotNull java.lang.String name)
Returns the selector for the given sitemap rootResource
and the given name.- Parameters:
sitemapRoot
-topLevelSitemapRoot
-name
-- Returns:
-
resolveSitemapRoots
@NotNull public static @NotNull java.util.Map<Resource,java.lang.String> resolveSitemapRoots(@NotNull @NotNull Resource topLevelSitemapRoot, @NotNull @NotNull java.lang.String sitemapSelector)
Resolves all sitemap rootResource
s for the given selector within the given top level sitemap rootResource
. This is the inversion ofgetSitemapSelector(Resource, Resource, String)
with sitemap root being a top level sitemap root.The returned
Map
only containsResource
s, that are sitemap roots according toisSitemapRoot(Resource)
. Each returnedResource
is mapped to the name which when passed togetSitemapSelector(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 java.util.Iterator<Resource> findSitemapRoots(ResourceResolver resolver, java.lang.String searchPath)
Returns all sitemap rootResource
s within the given search path, excluding the search path itself even if it is a sitemap root.The
Resource
s returned are normalized usingnormalizeSitemapRoot(Resource)
.- Parameters:
resolver
-searchPath
-- Returns:
-
-