This is an automated email from the ASF dual-hosted git repository.

diru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 7e5e68e72b40c70224657456237a7b08f03a2b21
Author: Dirk Rudolph <[email protected]>
AuthorDate: Fri Jun 4 17:25:21 2021 +0200

    fix servlet serving sitemaps from storage
    
    after changing from nt:file to nt:unstructured as node type for the
    sitemap nodes, resource.adaptTo(InputStream.class) does not work
    anymore. The jcr:data attribute needs to be accessed directly.
---
 .../src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/sitemap/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java 
b/sitemap/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
index 4fb3494..b31786e 100644
--- a/sitemap/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
+++ b/sitemap/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
@@ -266,8 +266,10 @@ public class SitemapStorage {
         }
         String sitemapFilePath = rootPath + sitemapRoot.getPath() + '/' + 
sitemapSelector + XML_EXTENSION;
         try (ResourceResolver resolver = 
resourceResolverFactory.getServiceResourceResolver(AUTH)) {
-            Resource sitemap = resolver.getResource(sitemapFilePath);
-            InputStream data = sitemap != null ? 
sitemap.adaptTo(InputStream.class) : null;
+            InputStream data = 
Optional.ofNullable(resolver.getResource(sitemapFilePath))
+                    .map(r -> r.getChild(JcrConstants.JCR_CONTENT))
+                    .map(r -> r.getValueMap().get(JcrConstants.JCR_DATA, 
InputStream.class))
+                    .orElse(null);
 
             if (data != null) {
                 IOUtils.copyLarge(data, output);

Reply via email to