public boolean copySitemap()

in src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java [359:382]


    public boolean copySitemap(Resource sitemapRoot, String sitemapSelector, OutputStream output) throws IOException {
        if (!isTopLevelSitemapRoot(sitemapRoot)) {
            return false;
        }
        String sitemapFilePath = rootPath + sitemapRoot.getPath() + '/' + sitemapSelector + XML_EXTENSION;
        try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(AUTH)) {
            InputStream data = Optional.ofNullable(resolver.getResource(sitemapFilePath))
                    .filter(r -> r.getName().endsWith(XML_EXTENSION))
                    .filter(r -> r.isResourceType(RT_SITEMAP_FILE))
                    .map(r -> r.getValueMap().get(JcrConstants.JCR_DATA, InputStream.class))
                    .orElse(null);

            if (data != null) {
                IOUtils.copyLarge(data, output);
                return true;
            } else {
                LOG.debug("Could not copy data from resource: {}", sitemapFilePath);
                return false;
            }
        } catch (LoginException ex) {
            LOG.warn("Could not copy sitemap to output: {}", ex.getMessage());
            return false;
        }
    }