You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/05/28 19:27:31 UTC

[sling-org-apache-sling-app-cms] 01/08: Set the context classloader to the Sling Dynamic ClassLoader to fix an issue with generating PPT thumbnails

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

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

commit 0fafcbef71fcb688e42888035f3643e58c648271
Author: Dan Klco <dk...@apache.org>
AuthorDate: Tue May 28 09:44:09 2019 -0400

    Set the context classloader to the Sling Dynamic ClassLoader to fix an
    issue with generating PPT thumbnails
---
 .../core/internal/transformation/SlideShowThumbnailProvider.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/transformation/SlideShowThumbnailProvider.java b/core/src/main/java/org/apache/sling/cms/core/internal/transformation/SlideShowThumbnailProvider.java
index 77bffde..6cf64a6 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/transformation/SlideShowThumbnailProvider.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/transformation/SlideShowThumbnailProvider.java
@@ -36,7 +36,9 @@ import org.apache.poi.xslf.usermodel.XMLSlideShow;
 import org.apache.sling.cms.File;
 import org.apache.sling.cms.transformation.OutputFileFormat;
 import org.apache.sling.cms.transformation.ThumbnailProvider;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
 
 import com.google.common.net.MediaType;
 
@@ -46,6 +48,9 @@ import com.google.common.net.MediaType;
 @Component(service = ThumbnailProvider.class)
 public class SlideShowThumbnailProvider implements ThumbnailProvider {
 
+    @Reference
+    private DynamicClassLoaderManager dclm;
+
     @Override
     public boolean applies(File file) {
         MediaType mt = MediaType.parse(file.getContentType());
@@ -54,6 +59,10 @@ public class SlideShowThumbnailProvider implements ThumbnailProvider {
 
     @Override
     public InputStream getThumbnail(File file) throws IOException {
+        if (dclm != null) {
+            Thread.currentThread().setContextClassLoader(dclm.getDynamicClassLoader());
+        }
+
         SlideShow<?, ?> ppt = null;
         MediaType mt = MediaType.parse(file.getContentType());
         try (ByteArrayOutputStream baos = new ByteArrayOutputStream();