From d3dcfd0b6a994b9b64744489bc1679b2a6f847fe Mon Sep 17 00:00:00 2001 From: tiagosalvado10 <9038083+tiagosalvado10@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:41:32 +0000 Subject: [PATCH] [MNT-23478] AsynchronousExtractor - Fix rendition obtaining (#2288) (#2293) * [MNT-23478] AsynchronousExtractor - Fix rendition obtaining * [MNT-23478] Only use default options if no rendition is found. PMD scan change. (cherry picked from commit 3bd3689d809dfe253908e1e65c3c044acf948d3f) --- .../metadata/AsynchronousExtractor.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/repository/src/main/java/org/alfresco/repo/content/metadata/AsynchronousExtractor.java b/repository/src/main/java/org/alfresco/repo/content/metadata/AsynchronousExtractor.java index ab45a16c761..1cbbf8ac24e 100644 --- a/repository/src/main/java/org/alfresco/repo/content/metadata/AsynchronousExtractor.java +++ b/repository/src/main/java/org/alfresco/repo/content/metadata/AsynchronousExtractor.java @@ -31,6 +31,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.action.executer.ContentMetadataExtracter; import org.alfresco.repo.content.transform.TransformerDebug; +import org.alfresco.repo.rendition2.RenditionDefinition2; import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2Impl; import org.alfresco.repo.rendition2.RenditionService2; import org.alfresco.repo.rendition2.TransformDefinition; @@ -411,12 +412,21 @@ private void transform(NodeRef nodeRef, ContentReader reader, String targetMimet // is used to cache the transform name that will be used. String transformName = targetMimetype + '/' + sourceMimetype; String renditionName = TransformDefinition.convertToRenditionName(transformName); - TransformDefinition transformDefinition = (TransformDefinition) renditionDefinitionRegistry2.getRenditionDefinition(renditionName); - if (transformDefinition == null) + + Map transformOptions = new HashMap<>(); + RenditionDefinition2 renditionDefinition2 = renditionDefinitionRegistry2.getRenditionDefinition(renditionName); + + if (renditionDefinition2 != null) { - transformDefinition = new TransformDefinition(transformName, targetMimetype, - options, null, null, null, renditionDefinitionRegistry2); + transformOptions.putAll(renditionDefinition2.getTransformOptions()); } + else + { + transformOptions.putAll(options); + } + + TransformDefinition transformDefinition = new TransformDefinition(transformName, targetMimetype, transformOptions, null, + null, null, renditionDefinitionRegistry2); if (logger.isTraceEnabled()) {