diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java index b31a103e5a..40435cd1bb 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 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 @@ -291,7 +291,8 @@ public abstract class AbstractImageMagickContentTransformerWorker extends Conten " target extension: " + targetExtension); } - if (remoteTransformerClientConfigured()) + boolean tEngineConfigured = remoteTransformerClientConfigured(); + if (tEngineConfigured) { transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); } diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java index 14aa1fb71b..ac812c2de3 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2020 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 @@ -247,8 +247,8 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont } properties.put(KEY_OPTIONS, commandOptions); } - properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() + - getSourcePageRange(options, sourceMimetype, targetMimetype)); + String sourcePageRange = getSourcePageRange(options, sourceMimetype, targetMimetype); + properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() + sourcePageRange); properties.put(VAR_TARGET, targetFile.getAbsolutePath()); // execute the statement @@ -389,6 +389,9 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont } else { + // The following is a somewhat flawed workaround for the fact that the "pdf" rendition in older + // versions of ACS used a SWFTransformationOptions object rather than a ImageTransformationOptions + // object. See MNT-22409. if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype)) { startPage = "0"; @@ -644,6 +647,9 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont } } } + // The following is a somewhat flawed workaround for the fact that the "pdf" rendition in older + // versions of ACS used a SWFTransformationOptions object rather than a ImageTransformationOptions + // object. See MNT-22409. if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype)) { return "[0]"; 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 cb9af62c15..ac77a723b1 100644 --- a/repository/src/main/resources/alfresco/repository.properties +++ b/repository/src/main/resources/alfresco/repository.properties @@ -581,7 +581,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 " +