Revert "ACS-2270 Read T-Engine config in alphabetical order"

Wrong branch [skip ci]

This reverts commit fa69e48e5241df4da0b677cacf0d51aeb94ab522.
This commit is contained in:
alandavis 2021-11-18 14:07:13 +00:00
parent fa69e48e52
commit 90a0d5138f
2 changed files with 5 additions and 79 deletions

View File

@ -31,19 +31,12 @@ import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
import org.alfresco.transformer.executors.TikaJavaExecutor;
import org.alfresco.transformer.executors.Transformer;
import org.alfresco.transformer.transformers.SelectingTransformer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Configuration
public class AIOCustomConfig
{
@ -95,26 +88,12 @@ public class AIOCustomConfig
public TransformServiceRegistry aioTransformRegistry() throws Exception
{
AIOTransformRegistry aioTransformRegistry = new AIOTransformRegistry();
// T-Engines are sorted by name so they are combined in the same order as in the T-Router
// and Content Repository with individual T-Engines. See TransformersConfigRegistry#retrieveRemoteConfig and
// LocalTransformServiceRegistry#getTEngineUrlsSortedByName.
for (Transformer tEngine : getTEnginesSortedByName())
{
aioTransformRegistry.registerTransformer(tEngine); // now a poor name - should be combinedTransformers
}
aioTransformRegistry.registerTransformer(new SelectingTransformer());
aioTransformRegistry.registerTransformer(new TikaJavaExecutor(notExtractBookmarksTextDefault));
aioTransformRegistry.registerTransformer(new ImageMagickCommandExecutor(imageMagickExePath, imageMagickDynPath, imageMagickRootPath, imageMagickCodersPath, imageMagickConfigPath));
aioTransformRegistry.registerTransformer(new LibreOfficeJavaExecutor(libreofficePath, libreofficeMaxTasksPerProcess, libreofficeTimeout, libreofficePortNumbers, libreofficeTemplateProfileDir, libreofficeIsEnabled));
aioTransformRegistry.registerTransformer(new PdfRendererCommandExecutor(pdfRendererPath));
aioTransformRegistry.registerCombinedTransformers();
return aioTransformRegistry;
}
List<Transformer> getTEnginesSortedByName()
{
return Stream.of(new SelectingTransformer(),
new TikaJavaExecutor(notExtractBookmarksTextDefault),
new ImageMagickCommandExecutor(imageMagickExePath, imageMagickDynPath, imageMagickRootPath, imageMagickCodersPath, imageMagickConfigPath),
new LibreOfficeJavaExecutor(libreofficePath, libreofficeMaxTasksPerProcess, libreofficeTimeout, libreofficePortNumbers, libreofficeTemplateProfileDir, libreofficeIsEnabled),
new PdfRendererCommandExecutor(pdfRendererPath))
.sorted(Comparator.comparing(Transformer::getTransformerId))
.collect(Collectors.toList());
}
}

View File

@ -1,53 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* 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
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import java.util.StringJoiner;
import static org.junit.jupiter.api.Assertions.*;
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
class AIOCustomConfigTest
{
@Autowired
AIOCustomConfig aioCustomConfig;
@Test
void testGetTEnginesSortedByName()
{
// T-Engine config must be read in a predictable order (alphabetically on T-Engine name) as they may override each other.
StringJoiner sortedTEngines = new StringJoiner(",");
aioCustomConfig.getTEnginesSortedByName().stream().forEach(tEngine -> sortedTEngines.add(tEngine.getTransformerId()));
assertEquals("imagemagick,libreoffice,misc,pdfrenderer,tika", sortedTEngines.toString());
}
}