mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
ACS-2270 Read T-Engine config in alphabetical order
* T-Engines config need to be combined in the same predefined order in the all-in-one transformer, T-Router and the Content Repository with individual T-Engines.
This commit is contained in:
parent
51b90202ce
commit
fa69e48e52
@ -31,12 +31,19 @@ import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
|
|||||||
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
||||||
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
|
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
|
||||||
import org.alfresco.transformer.executors.TikaJavaExecutor;
|
import org.alfresco.transformer.executors.TikaJavaExecutor;
|
||||||
|
import org.alfresco.transformer.executors.Transformer;
|
||||||
import org.alfresco.transformer.transformers.SelectingTransformer;
|
import org.alfresco.transformer.transformers.SelectingTransformer;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
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
|
@Configuration
|
||||||
public class AIOCustomConfig
|
public class AIOCustomConfig
|
||||||
{
|
{
|
||||||
@ -88,12 +95,26 @@ public class AIOCustomConfig
|
|||||||
public TransformServiceRegistry aioTransformRegistry() throws Exception
|
public TransformServiceRegistry aioTransformRegistry() throws Exception
|
||||||
{
|
{
|
||||||
AIOTransformRegistry aioTransformRegistry = new AIOTransformRegistry();
|
AIOTransformRegistry aioTransformRegistry = new AIOTransformRegistry();
|
||||||
aioTransformRegistry.registerTransformer(new SelectingTransformer());
|
|
||||||
aioTransformRegistry.registerTransformer(new TikaJavaExecutor(notExtractBookmarksTextDefault));
|
// T-Engines are sorted by name so they are combined in the same order as in the T-Router
|
||||||
aioTransformRegistry.registerTransformer(new ImageMagickCommandExecutor(imageMagickExePath, imageMagickDynPath, imageMagickRootPath, imageMagickCodersPath, imageMagickConfigPath));
|
// and Content Repository with individual T-Engines. See TransformersConfigRegistry#retrieveRemoteConfig and
|
||||||
aioTransformRegistry.registerTransformer(new LibreOfficeJavaExecutor(libreofficePath, libreofficeMaxTasksPerProcess, libreofficeTimeout, libreofficePortNumbers, libreofficeTemplateProfileDir, libreofficeIsEnabled));
|
// LocalTransformServiceRegistry#getTEngineUrlsSortedByName.
|
||||||
aioTransformRegistry.registerTransformer(new PdfRendererCommandExecutor(pdfRendererPath));
|
for (Transformer tEngine : getTEnginesSortedByName())
|
||||||
|
{
|
||||||
|
aioTransformRegistry.registerTransformer(tEngine); // now a poor name - should be combinedTransformers
|
||||||
|
}
|
||||||
aioTransformRegistry.registerCombinedTransformers();
|
aioTransformRegistry.registerCombinedTransformers();
|
||||||
return aioTransformRegistry;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* #%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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user