From d88f8f7bbf48ccc8c28ef46c7cde872ba5193be2 Mon Sep 17 00:00:00 2001 From: alandavis Date: Fri, 21 May 2021 07:14:57 +0100 Subject: [PATCH] MNT-22409 Legacy transformer fails to generate multi-page TIFF preview Originally fixed on 6.2.N. A couple of the Legacy classes no longer exist so changes are not on master. Changes to the renditions, default page limit and test still apply. (cherry picked from commit 9d276aed7081e0078ed3f7f01dabdec20c599bfe) (cherry picked from commit ddb299ab03307a4f7116b2fe52f61805bafca25a) --- .../renditions/0100-baseRenditions.json | 20 ++++++++++---- .../resources/alfresco/repository.properties | 2 +- .../rendition2/RenditionDefinitionTest.java | 26 ++++++++++++++++++- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/repository/src/main/resources/alfresco/renditions/0100-baseRenditions.json b/repository/src/main/resources/alfresco/renditions/0100-baseRenditions.json index f96f6fd464..5f0db8c45d 100644 --- a/repository/src/main/resources/alfresco/renditions/0100-baseRenditions.json +++ b/repository/src/main/resources/alfresco/renditions/0100-baseRenditions.json @@ -9,7 +9,9 @@ {"name": "allowEnlargement", "value": true}, {"name": "maintainAspectRatio", "value": true}, {"name": "autoOrient", "value": true}, - {"name": "thumbnail", "value": true} + {"name": "thumbnail", "value": true}, + {"name": "startPage", "value": "0"}, + {"name": "endPage", "value": "0"} ] }, { @@ -21,7 +23,9 @@ {"name": "allowEnlargement", "value": false}, {"name": "maintainAspectRatio", "value": true}, {"name": "autoOrient", "value": true}, - {"name": "thumbnail", "value": true} + {"name": "thumbnail", "value": true}, + {"name": "startPage", "value": "0"}, + {"name": "endPage", "value": "0"} ] }, { @@ -33,7 +37,9 @@ {"name": "allowEnlargement", "value": false}, {"name": "maintainAspectRatio", "value": true}, {"name": "autoOrient", "value": true}, - {"name": "thumbnail", "value": true} + {"name": "thumbnail", "value": true}, + {"name": "startPage", "value": "0"}, + {"name": "endPage", "value": "0"} ] }, { @@ -45,7 +51,9 @@ {"name": "allowEnlargement", "value": false}, {"name": "maintainAspectRatio", "value": true}, {"name": "autoOrient", "value": true}, - {"name": "thumbnail", "value": true} + {"name": "thumbnail", "value": true}, + {"name": "startPage", "value": "0"}, + {"name": "endPage", "value": "0"} ] }, { @@ -57,7 +65,9 @@ {"name": "allowEnlargement", "value": false}, {"name": "maintainAspectRatio", "value": true}, {"name": "autoOrient", "value": true}, - {"name": "thumbnail", "value": true} + {"name": "thumbnail", "value": true}, + {"name": "startPage", "value": "0"}, + {"name": "endPage", "value": "0"} ] }, { diff --git a/repository/src/main/resources/alfresco/repository.properties b/repository/src/main/resources/alfresco/repository.properties index 45289872f0..71d10c8057 100644 --- a/repository/src/main/resources/alfresco/repository.properties +++ b/repository/src/main/resources/alfresco/repository.properties @@ -482,7 +482,7 @@ system.thumbnail.definition.default.timeoutMs=-1 system.thumbnail.definition.default.readLimitTimeMs=-1 system.thumbnail.definition.default.maxSourceSizeKBytes=-1 system.thumbnail.definition.default.readLimitKBytes=-1 -system.thumbnail.definition.default.pageLimit=1 +system.thumbnail.definition.default.pageLimit=-1 system.thumbnail.definition.default.maxPages=-1 # Max mimetype sizes to create thumbnail icons diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionDefinitionTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionDefinitionTest.java index 24516e00e0..693feccf5e 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionDefinitionTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionDefinitionTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2019 Alfresco Software Limited + * Copyright (C) 2005 - 2021 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -32,10 +32,13 @@ import org.alfresco.repo.thumbnail.ThumbnailDefinition; import org.alfresco.repo.thumbnail.ThumbnailRenditionConvertor; import org.alfresco.service.cmr.rendition.RenditionDefinition; import org.alfresco.service.cmr.rendition.RenditionService; +import org.alfresco.service.cmr.repository.PagedSourceOptions; import org.alfresco.service.cmr.repository.TransformationOptions; +import org.alfresco.service.cmr.repository.TransformationSourceOptions; import org.alfresco.util.BaseSpringTest; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; @@ -126,6 +129,27 @@ public class RenditionDefinitionTest extends BaseSpringTest // than checking transformationOptions is equal to transformationOptions2. if (!renditionName.equals("pdf") && !renditionName.equals("webpreview")) { + // MNT-22409: We no longer have system.thumbnail.definition.default.pageLimit=1 as a default. + // It is -1 (unlimited), but to compensate for that the new OOTB renditions defined in + // 0100-baseRenditions now have startPage and endPage transform options. The following code modifies + // the transformationOptions so that they will be the same if there are no bugs. + Collection sourceOptionsList = transformationOptions2.getSourceOptionsList(); + if (sourceOptionsList != null && sourceOptionsList.size() == 1) + { + TransformationSourceOptions sourceOptions = sourceOptionsList.iterator().next(); + if (sourceOptions instanceof PagedSourceOptions) + { + PagedSourceOptions pagedSourceOptions = (PagedSourceOptions)sourceOptions; + if (pagedSourceOptions.getStartPageNumber() == 1 && pagedSourceOptions.getEndPageNumber() == 1) + { + if (transformationOptions.getSourceOptionsList() == null) + { + transformationOptions.setSourceOptionsList(sourceOptionsList); + } + } + } + } + assertEquals("The TransformationOptions used in transforms for " + renditionName + " should be the same", transformationOptions.toStringAll(), transformationOptions2.toStringAll()); assertEquals("The transformationOptionsConverter back to the newer format was not the same for " +