in src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java [325:357]
public Collection<SitemapStorageInfo> getSitemaps(Resource sitemapRoot, Collection<String> names) {
try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(AUTH)) {
Resource topLevelSitemapRoot = getTopLevelSitemapRoot(sitemapRoot);
Predicate<SitemapStorageInfo> filter;
if (!isTopLevelSitemapRoot(sitemapRoot) || !names.isEmpty()) {
// return only those that match at least on of the names requested
filter = info -> names.stream()
.map(name -> SitemapUtil.getSitemapSelector(sitemapRoot, topLevelSitemapRoot, name))
.anyMatch(selector -> info.getSitemapSelector().equals(selector)
|| info.getSitemapSelector().equals(selector + '-' + info.getFileIndex()));
} else {
filter = any -> true;
}
String storagePath = rootPath + topLevelSitemapRoot.getPath();
Resource storageResource = resolver.getResource(storagePath);
if (storageResource == null) {
LOG.debug("Resource at {} does not exist.", storagePath);
return Collections.emptySet();
}
return StreamSupport.stream(storageResource.getChildren().spliterator(), false)
.filter(SitemapStorage::isValidSitemapFile)
.map(SitemapStorage::newSitemapStorageInfo)
.filter(filter)
.collect(Collectors.toList());
} catch (LoginException ex) {
LOG.warn("Could not list sitemaps from storage: {}", ex.getMessage());
return Collections.emptySet();
}
}