Save point: Simpler project structure for core t-engines

This commit is contained in:
alandavis
2022-07-03 11:41:07 +01:00
parent c44ff5016a
commit 0eb8d9e142
538 changed files with 1182 additions and 1756 deletions

View File

@@ -9,15 +9,15 @@ Contains the common transformer (T-Engine) code, plus a few implementations.
configuration files and messages sent between clients, T-Engines and T-Router. Also contains code to configuration files and messages sent between clients, T-Engines and T-Router. Also contains code to
work out which transform should be used for a combination of configuration files; see the sub-project's work out which transform should be used for a combination of configuration files; see the sub-project's
[README](https://github.com/Alfresco/alfresco-transform-core/blob/master/alfresco-transform-model/README.md) [README](https://github.com/Alfresco/alfresco-transform-core/blob/master/alfresco-transform-model/README.md)
* `alfresco-t-engine-base` - library packaged as a jar file which contains code that is common * `alfresco-base-t-engine` - library packaged as a jar file which contains code that is common
to all the transformers; see the sub-project's to all the transformers; see the sub-project's
[README](https://github.com/Alfresco/alfresco-transform-core/blob/master/alfresco-t-engine-base/README.md) [README](https://github.com/Alfresco/alfresco-transform-core/blob/master/alfresco-base-t-engine/README.md)
* `alfresco-transform-<name>` - multiple T-Engines; each one of them builds both a SpringBoot fat jar * `alfresco-transform-<name>` - multiple T-Engines; each one of them builds both a SpringBoot fat jar
and a [Docker image](https://github.com/Alfresco/alfresco-transform-core#docker) and a [Docker image](https://github.com/Alfresco/alfresco-transform-core#docker)
### Documentation ### Documentation
In addition to the subprojects (such as `alfresco-t-engine-base` README above) some additional documentation can be found in: In addition to the subprojects (such as `alfresco-base-t-engine` README above) some additional documentation can be found in:
* [this project's docs](docs) folder * [this project's docs](docs) folder
* [ACS Packaging docs](https://github.com/Alfresco/acs-packaging/tree/master/docs) folder * [ACS Packaging docs](https://github.com/Alfresco/acs-packaging/tree/master/docs) folder
@@ -49,7 +49,7 @@ The artifacts can be obtained by:
<dependency> <dependency>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId> <artifactId>alfresco-base-t-engine</artifactId>
<version>version</version> <version>version</version>
</dependency> </dependency>
``` ```

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-core-aio</artifactId>
<name>Alfresco Core All-In-One Transformer</name>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-tika</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-pdf-renderer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-libreoffice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-imagemagick</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,145 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Map;
import org.alfresco.transform.aio.AIOController;
import org.alfresco.transform.aio.AIOCustomConfig;
import org.alfresco.transform.aio.AIOTransformRegistry;
import org.alfresco.transform.imagemagick.ImageMagickControllerTest;
import org.alfresco.transform.base.executors.Transformer;
import org.alfresco.transformer.AbstractTransformerController;
import org.junit.jupiter.api.BeforeEach;
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 org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
/**
* Test the AIOController ImageMagick transforms without a server.
* Super class includes tests for the AbstractTransformerController.
*/
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
public class AIOControllerImageMagickTest extends ImageMagickControllerTest
{
// All tests contained in ImageMagickControllerTest
@Autowired AIOTransformRegistry transformRegistry;
@BeforeEach @Override
public void before() throws IOException
{
ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
//Need to wire in the mocked commandExecutor into the controller...
Map<String,Transformer> transformers = transformRegistry.getTransformerEngineMapping();
transformers.replace("imagemagick", commandExecutor);
mockTransformCommand("jpg", "png", "image/jpeg", true);
}
@Override
protected AbstractTransformerController getController()
{
return controller;
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
@Test
public void testTestValidity()
{
// just test that we are actually testing against the AIOController (instead of MiscController)
assertTrue(controller instanceof AIOController, "Wrong controller wired for test");
}
@Test
@Override
public void noTargetFileTest()
{
// Ignore the test in super class as the AIO transforms will not be selected .
// It is the mock that returns a zero length file for other transformers, when we supply an invalid targetExtension.
}
@Test
@Override
public void testGetTransformConfigInfo()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithDuplicates()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithEmptyTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithNoTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
}

View File

@@ -1,120 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import org.alfresco.transform.libreoffice.LibreOfficeControllerTest;
import org.alfresco.transform.libreoffice.transformers.LibreOfficeTransformer;
import org.alfresco.transform.base.executors.Transformer;
import org.alfresco.transformer.AbstractTransformerController;
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 org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
/**
* Test the AIOController without a server.
* Super class includes tests for the LibreOfficeController and AbstractTransformerController.
*/
public class AIOControllerLibreOfficeTest extends LibreOfficeControllerTest
{
//Tests contained in LibreOfficeControllerTest
@Test
public void testTestValidity()
{
// just test that we are actually testing against the AIOController (instead of MiscController)
assertTrue(controller instanceof AIOController,"Wrong controller wired for test");
}
@Autowired AIOTransformRegistry transformRegistry;
@Override
// Used by the super class to mock the javaExecutor, a different implementation is required here
protected void setJavaExecutor(AbstractTransformerController controller, LibreOfficeTransformer javaExecutor)
{
//Need to wire in the mocked javaExecutor into the controller...
Map<String,Transformer> transformers = transformRegistry.getTransformerEngineMapping();
transformers.replace("libreoffice", javaExecutor);
// No need to set the transform registry to the controller as it is @Autowired in
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
@Test
@Override
public void testGetTransformConfigInfo()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithDuplicates()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithEmptyTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithNoTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
}

View File

@@ -1,88 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.alfresco.transform.aio.AIOController;
import org.alfresco.transform.aio.AIOCustomConfig;
import org.alfresco.transform.misc.MiscControllerTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
public class AIOControllerMiscTest extends MiscControllerTest
{
//Tests contained in MiscControllerTest
@Test
public void testTestValidity()
{
// just test that we are actually testing against the AIOController (instead of MiscController)
assertTrue(controller instanceof AIOController, "Wrong controller wired for test");
}
@Test
@Override
public void testGetTransformConfigInfo()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithDuplicates()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithEmptyTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithNoTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
}

View File

@@ -1,119 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import org.alfresco.transform.pdfRenderer.AlfrescoPdfRendererControllerTest;
import org.alfresco.transform.base.executors.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 org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
/**
* Test the AIOController PDF Renderer transforms without a server.
* Super class includes tests for the AbstractTransformerController.
*/
public class AIOControllerPdfRendererTest extends AlfrescoPdfRendererControllerTest
{
@Autowired AIOTransformRegistry transformRegistry;
@Override
protected void setFields()
{
ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
//Need to wire in the mocked commandExecutor into the controller...
Map<String,Transformer> transformers = transformRegistry.getTransformerEngineMapping();
transformers.replace("pdfrenderer", commandExecutor);
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
@Test
public void testTestValidity()
{
// just test that we are actually testing against the AIOController (instead of MiscController)
assertTrue(controller instanceof AIOController, "Wrong controller wired for test");
}
@Test
@Override
public void testGetTransformConfigInfo()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithDuplicates()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithEmptyTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithNoTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
}

View File

@@ -1,102 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.alfresco.transform.aio.AIOController;
import org.alfresco.transform.aio.AIOCustomConfig;
import org.alfresco.transform.tika.TikaControllerTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
/**
* Test the AIOController Tika transforms without a server.
* Super class includes tests for the AbstractTransformerController.
*/
public class AIOControllerTikaTest extends TikaControllerTest
{
// All tests contained in TikaControllerTest
@Test
public void testTestValidity()
{
// just test that we are actually testing against the AIOController (instead of MiscController)
assertTrue(controller instanceof AIOController,"Wrong controller wired for test");
}
@Test
@Override
public void testGetTransformConfigInfo()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithDuplicates()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithEmptyTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void testGetInfoFromConfigWithNoTransformOptions()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test
@Override
public void xlsxEmbedTest()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// It uses the real class path rather than the test one.
}
}

View File

@@ -1,55 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import org.alfresco.transform.aio.AIOController;
import org.alfresco.transform.aio.AIOCustomConfig;
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());
}
}

View File

@@ -1,321 +0,0 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.coreaio;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.alfresco.transform.aio.AIOTransformRegistry;
import org.alfresco.transform.config.TransformConfig;
import org.alfresco.transform.base.executors.Transformer;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.alfresco.transform.common.RequestParamMap.PAGE_LIMIT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AIOTransformRegistryTest
{
private static final String SOURCE_MIMETYPE = "text/html";
private static final String TARGET_MIMETYPE = "text/plain";
String SOURCE_ENCODING = "sourceEncoding";
AIOTransformRegistry aioTransformerRegistry = new AIOTransformRegistry();
ObjectMapper objectMapper = new ObjectMapper();
@BeforeEach
public void before() throws Exception
{
// aioTransformerRegistry.registerTransformer(new SelectingTransformer());
// aioTransformerRegistry.registerTransformer(new TikaJavaExecutor());
aioTransformerRegistry.registerCombinedTransformers();
}
private void writeToFile(File file, String content, String encoding) throws Exception
{
try (OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(file), encoding))
{
ow.append(content);
}
}
private String readFromFile(File file, final String encoding) throws Exception
{
return new String(Files.readAllBytes(file.toPath()), encoding);
}
private TransformConfig loadConfig(String s) throws Exception
{
return objectMapper.readValue(new ClassPathResource(s).getFile(), TransformConfig.class);
}
@Test
public void testConfigAggregation() throws Exception
{
List<String> expectedTransformNames = Arrays.asList("html", "string", "appleIWorks", "textToPdf", "rfc822",
"Archive", "OutlookMsg", "PdfBox", "Office", "Poi", "OOXML", "TikaAuto", "TextMining");
List<String> expectedTransformOptionNames = Arrays.asList("tikaOptions", "archiveOptions", "pdfboxOptions",
"textToPdfOptions", "stringOptions", "metadataOptions");
TransformConfig miscConfig = loadConfig("misc_engine_config.json");
TransformConfig tikaConfig = loadConfig("tika_engine_config.json");
// check correct number of transformers
assertEquals(
miscConfig.getTransformers().size() + tikaConfig.getTransformers().size(),
aioTransformerRegistry.getTransformConfig().getTransformers().size(),
"Number of expected transformers");
List<String> actualTransformerNames = aioTransformerRegistry.getTransformConfig().getTransformers()
.stream().map(t -> t.getTransformerName()).collect(Collectors.toList());
// check all transformers are there
for(String transformNames : expectedTransformNames)
{
assertTrue(actualTransformerNames.contains(transformNames),"Expected transformer missing.");
}
// check correct number of options
long distinctOptionCount = Stream.concat(
miscConfig.getTransformOptions().keySet().stream(),
tikaConfig.getTransformOptions().keySet().stream()).distinct().count();
assertEquals(
distinctOptionCount,
aioTransformerRegistry.getTransformConfig().getTransformOptions().size(),
"Number of expected transformers");
Set<String> actualOptionNames = aioTransformerRegistry.getTransformConfig().getTransformOptions().keySet();
// check all options are there
for (String optionName : expectedTransformOptionNames)
{
assertTrue(actualOptionNames.contains(optionName), "Expected transform option missing:"+optionName);
}
}
@Test
public void testTransformerMapping()
{
List<String> tikaTransforms = Arrays.asList("Archive", "OutlookMsg", "PdfBox", "Office", "Poi", "OOXML", "TikaAuto", "TextMining");
List<String> miscTransforms = Arrays.asList("html", "string", "appleIWorks", "textToPdf", "rfc822");
for (String transform : tikaTransforms)
{
String actualId = aioTransformerRegistry.getByTransformName(transform).getTransformerId();
assertEquals("tika", actualId, "Wrong mapping for transform "+transform);
}
for (String transform : miscTransforms)
{
String actualId = aioTransformerRegistry.getByTransformName(transform).getTransformerId();
assertEquals("misc", actualId, "Wrong mapping for transform "+transform);
}
}
// Test copied from Misc (HtmlParserContentTransformerTest) See ATS-712 aioTransformerRegistry - html
@Test
public void testMiscHtml() throws Exception
{
final String NEWLINE = System.getProperty("line.separator");
final String TITLE = "Testing!";
final String TEXT_P1 = "This is some text in English";
final String TEXT_P2 = "This is more text in English";
final String TEXT_P3 = "C'est en Fran\u00e7ais et Espa\u00f1ol";
String partA = "<html><head><title>" + TITLE + "</title></head>" + NEWLINE;
String partB = "<body><p>" + TEXT_P1 + "</p>" + NEWLINE +
"<p>" + TEXT_P2 + "</p>" + NEWLINE +
"<p>" + TEXT_P3 + "</p>" + NEWLINE;
String partC = "</body></html>";
final String expected = TITLE + NEWLINE + TEXT_P1 + NEWLINE + TEXT_P2 + NEWLINE + TEXT_P3 + NEWLINE;
File tmpS = null;
File tmpD = null;
try
{
// Content set to ISO 8859-1
tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
writeToFile(tmpS, partA + partB + partC, "ISO-8859-1");
tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
Map<String, String> parameters = new HashMap<>();
parameters.put(SOURCE_ENCODING, "ISO-8859-1");
Transformer transformer = aioTransformerRegistry.getByTransformName("html");
transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
assertEquals(expected, readFromFile(tmpD, "UTF-8"));
tmpS.delete();
tmpD.delete();
// Content set to UTF-8
tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
writeToFile(tmpS, partA + partB + partC, "UTF-8");
tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
parameters = new HashMap<>();
parameters.put(SOURCE_ENCODING, "UTF-8");
transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
assertEquals(expected, readFromFile(tmpD, "UTF-8"));
tmpS.delete();
tmpD.delete();
// Content set to UTF-16
tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
writeToFile(tmpS, partA + partB + partC, "UTF-16");
tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
parameters = new HashMap<>();
parameters.put(SOURCE_ENCODING, "UTF-16");
transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
assertEquals(expected, readFromFile(tmpD, "UTF-8"));
tmpS.delete();
tmpD.delete();
// Note - since HTML Parser 2.0 META tags specifying the
// document encoding will ONLY be respected if the original
// content type was set to ISO-8859-1.
//
// This means there is now only one test which we can perform
// to ensure that this now-limited overriding of the encoding
// takes effect.
// Content set to ISO 8859-1, meta set to UTF-8
tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
String str = partA +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" +
partB + partC;
writeToFile(tmpS, str, "UTF-8");
tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
parameters = new HashMap<>();
parameters.put(SOURCE_ENCODING, "ISO-8859-1");
transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
assertEquals(expected, readFromFile(tmpD, "UTF-8"));
tmpS.delete();
tmpD.delete();
// Note - we can't test UTF-16 with only a meta encoding,
// because without that the parser won't know about the
// 2 byte format so won't be able to identify the meta tag
}
finally
{
if (tmpS != null && tmpS.exists()) tmpS.delete();
if (tmpD != null && tmpD.exists()) tmpD.delete();
}
}
// Test copied from Misc (TextToPdfContentTransformerTest) See ATS-712 aioTransformerRegistry - pdf
@Test
public void testMiscPdf() throws Exception
{
transformTextAndCheckPageLength(-1);
}
private void transformTextAndCheckPageLength(int pageLimit) throws Exception
{
int pageLength = 32;
int lines = (pageLength + 10) * ((pageLimit > 0) ? pageLimit : 1);
StringBuilder sb = new StringBuilder();
String checkText = null;
int cutoff = pageLimit * pageLength;
for (int i = 1; i <= lines; i++)
{
sb.append(Integer.toString(i));
sb.append(" I must not talk in class or feed my homework to my cat.\n");
if (i == cutoff)
checkText = sb.toString();
}
sb.append("\nBart\n");
String text = sb.toString();
checkText = (checkText == null) ? clean(text) : clean(checkText);
transformTextAndCheck(text, "UTF-8", checkText, String.valueOf(pageLimit));
}
private void transformTextAndCheck(String text, String encoding, String checkText,
String pageLimit) throws Exception
{
// Get a reader for the text
File sourceFile = File.createTempFile("AlfrescoTestSource_", ".txt");
writeToFile(sourceFile, text, encoding);
// And a temp writer
File targetFile = File.createTempFile("AlfrescoTestTarget_", ".pdf");
// Transform to PDF
Map<String, String> parameters = new HashMap<>();
parameters.put(PAGE_LIMIT, pageLimit);
Transformer transformer = aioTransformerRegistry.getByTransformName("textToPdf");
transformer.transformExtractOrEmbed("textToPdf", "text/plain", "application/pdf", parameters, sourceFile, targetFile);
// Read back in the PDF and check it
PDDocument doc = PDDocument.load(targetFile);
PDFTextStripper textStripper = new PDFTextStripper();
StringWriter textWriter = new StringWriter();
textStripper.writeText(doc, textWriter);
doc.close();
String roundTrip = clean(textWriter.toString());
assertEquals(
checkText, roundTrip,
"Incorrect text in PDF when starting from text in " + encoding
);
sourceFile.delete();
targetFile.delete();
}
private String clean(String text)
{
text = text.replaceAll("\\s+\\r", "");
text = text.replaceAll("\\s+\\n", "");
text = text.replaceAll("\\r", "");
text = text.replaceAll("\\n", "");
return text;
}
}

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-imagemagick</artifactId>
<name>Alfresco ImageMagick Transformer</name>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-libreoffice</artifactId>
<name>Alfresco LibreOffice Transformer</name>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-jodconverter-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,86 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-misc</artifactId>
<name>Alfresco Miscellaneous Transformer</name>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<!-- HtmlParserContentTransformer -->
<dependency>
<groupId>org.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<version>2.1</version>
</dependency>
<!-- AppleIWorksContentTransformer -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<!-- TextToPdfContentTransformer -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-tools</artifactId>
<version>2.0.25</version>
</dependency>
<!-- OOXMLThumbnailContentTransformer -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${dependency.poi.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>${dependency.ooxml-schemas.version}</version>
</dependency>
<!-- EMLTransformer -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-pdf-renderer</artifactId>
<name>Alfresco Pdf Renderer Transformer</name>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-core</artifactId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-tika</artifactId>
<name>Alfresco Tika Transformer</name>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Tika -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>${dependency.tika.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers-standard-package</artifactId>
<version>${dependency.tika.version}</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Needed for correct date/time formats -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.14</version>
</dependency>
<!-- for Apache Tika Parsers - eg. encrypted PDF -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<!-- Apache POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${dependency.poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${dependency.poi.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>${dependency.ooxml-schemas.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>${dependency.poi.version}</version>
</dependency>
<!-- Apache PDFBox -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-tools</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -49,7 +49,7 @@ src/main/java/org/alfresco/transformer/Application.java
~~~ ~~~
* *TransformerName*Controller.java - A [Spring Boot](https://projects.spring.io/spring-boot/) Controller that * *TransformerName*Controller.java - A [Spring Boot](https://projects.spring.io/spring-boot/) Controller that
extends AbstractTransformerController to handel requests. It implements a few methods including *transformImpl* extends TransformController to handel requests. It implements a few methods including *transformImpl*
which is intended to perform the actual transform. Generally the transform is done in a sub class of which is intended to perform the actual transform. Generally the transform is done in a sub class of
*JavaExecutor*, when a Java library is being used or *AbstractCommandExecutor*, when an external process is used. *JavaExecutor*, when a Java library is being used or *AbstractCommandExecutor*, when an external process is used.
Both are sub interfaces of *Transformer*. Both are sub interfaces of *Transformer*.
@@ -57,7 +57,7 @@ src/main/java/org/alfresco/transformer/Application.java
~~~ ~~~
... ...
@Controller @Controller
public class TransformerNameController extends AbstractTransformerController public class TransformerNameController extends TransformController
{ {
private static final Logger logger = LoggerFactory.getLogger(TransformerNameController.class); private static final Logger logger = LoggerFactory.getLogger(TransformerNameController.class);
@@ -149,7 +149,7 @@ public class Application
} }
~~~ ~~~
Transform requests are handled by the *AbstractTransformerController*, but are either: Transform requests are handled by the *TransformController*, but are either:
* POST requests (a direct http request from a client) where the transform options are passed as parameters, the source is supplied as a multipart file and * POST requests (a direct http request from a client) where the transform options are passed as parameters, the source is supplied as a multipart file and
the response is a file download. the response is a file download.
* POST request (a request via a message queue) where the transform options are supplied as JSON and the response is also JSON. * POST request (a request via a message queue) where the transform options are supplied as JSON and the response is also JSON.

View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transformer-base</artifactId>
<name>- Deprecated Base</name>
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
@@ -8,8 +10,6 @@
<version>2.6.1-SNAPSHOT</version> <version>2.6.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>alfresco-transformer-base</artifactId>
<properties> <properties>
<transformer.base.deploy.skip>false</transformer.base.deploy.skip> <transformer.base.deploy.skip>false</transformer.base.deploy.skip>
</properties> </properties>

View File

@@ -29,9 +29,9 @@ ARG GROUPID=1000
ARG AIOUSERNAME=transform-all-in-one ARG AIOUSERNAME=transform-all-in-one
ARG USERID=33017 ARG USERID=33017
COPY target/alfresco-transform-core-aio-boot-${env.project_version}.jar /usr/bin COPY target/${env.project_artifactId}-${env.project_version}.jar /usr/bin
RUN ln /usr/bin/alfresco-transform-core-aio-boot-${env.project_version}.jar /usr/bin/alfresco-transform-core-aio-boot.jar && \ RUN ln /usr/bin/${env.project_artifactId}-${env.project_version}.jar /usr/bin/${env.project_artifactId}.jar && \
yum install -y $IMAGEMAGICK_DEP_RPM_URL && \ yum install -y $IMAGEMAGICK_DEP_RPM_URL && \
yum install -y $IMAGEMAGICK_LIB_RPM_URL $IMAGEMAGICK_RPM_URL && \ yum install -y $IMAGEMAGICK_LIB_RPM_URL $IMAGEMAGICK_RPM_URL && \
yum install -y cairo cups-libs libSM libGLU && \ yum install -y cairo cups-libs libSM libGLU && \
@@ -62,10 +62,10 @@ COPY src/main/resources/licenses/3rd-party/ /
RUN groupadd -g ${GROUPID} ${GROUPNAME} && \ RUN groupadd -g ${GROUPID} ${GROUPNAME} && \
useradd -u ${USERID} -G ${GROUPNAME} ${AIOUSERNAME} && \ useradd -u ${USERID} -G ${GROUPNAME} ${AIOUSERNAME} && \
chgrp -R ${GROUPNAME} /usr/bin/alfresco-transform-core-aio-boot.jar chgrp -R ${GROUPNAME} /usr/bin/${env.project_artifactId}.jar
EXPOSE 8090 EXPOSE 8090
USER ${AIOUSERNAME} USER ${AIOUSERNAME}
ENTRYPOINT java $JAVA_OPTS -jar /usr/bin/alfresco-transform-core-aio-boot.jar ENTRYPOINT java $JAVA_OPTS -jar /usr/bin/${env.project_artifactId}.jar

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-core-aio-boot</artifactId> <artifactId>alfresco-transform-core-aio</artifactId>
<name>Alfresco Core All-In-One Transformer Spring Boot</name> <name>- All-In-One</name>
<parent> <parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-core</artifactId> <artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
@@ -20,57 +20,12 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId> <artifactId>alfresco-base-t-engine</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-core-aio</artifactId> <artifactId>alfresco-base-t-engine</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-tika-boot</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-imagemagick-boot</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-pdf-renderer-boot</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-misc-boot</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-libreoffice-boot</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<classifier>tests</classifier> <classifier>tests</classifier>
<type>test-jar</type> <type>test-jar</type>
@@ -95,7 +50,80 @@
<groupId>org.dom4j</groupId> <groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId> <artifactId>dom4j</artifactId>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-jodconverter-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-misc</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-tika</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-tika</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-pdf-renderer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-pdf-renderer</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-libreoffice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-libreoffice</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-imagemagick</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-imagemagick</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>

View File

@@ -33,6 +33,7 @@ import org.alfresco.transform.config.TransformConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -45,8 +46,7 @@ import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
@Component @Component
public class AIOTransformEngine implements TransformEngine public class AIOTransformEngine implements TransformEngine
{ {
@Autowired // private static String SPLIT_UP_COMMUNITY_LICENCE = Arrays.stream(COMMUNITY_LICENCE.split("\\n"));
private TransformRegistryImpl transformRegistry;
@Autowired(required = false) @Autowired(required = false)
private List<TransformEngine> transformEngines; private List<TransformEngine> transformEngines;
@@ -66,10 +66,10 @@ public class AIOTransformEngine implements TransformEngine
message = transformEngines.stream() message = transformEngines.stream()
.filter(transformEngine -> transformEngine != this) .filter(transformEngine -> transformEngine != this)
.map(transformEngine -> transformEngine.getStartupMessage()) .map(transformEngine -> transformEngine.getStartupMessage())
.collect( Collectors.joining("\\n")); .collect( Collectors.joining("\n"));
message.replace(COMMUNITY_LICENCE + "\\n", ""); message = message.replace(COMMUNITY_LICENCE, "");
} }
return COMMUNITY_LICENCE + "\\n" + message; return COMMUNITY_LICENCE + message;
} }
@Override @Override

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.base.AbstractHttpRequestTest; import org.alfresco.transform.base.AbstractHttpRequestTest;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@@ -33,7 +33,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class AIOControllerHttpRequestTest extends AbstractHttpRequestTest public class AIOControllerHttpRequestTest extends AbstractHttpRequestTest
{ {
@Override @Override
protected String getTransformerName() protected String getTransformerName()
{ {
@@ -46,5 +45,4 @@ public class AIOControllerHttpRequestTest extends AbstractHttpRequestTest
// Currently using same extension as ImageMagick tests // Currently using same extension as ImageMagick tests
return "jpg"; return "jpg";
} }
} }

View File

@@ -0,0 +1,119 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import org.alfresco.transform.base.TransformRegistryImpl;
import org.alfresco.transform.config.Transformer;
import org.alfresco.transform.imagemagick.ImageMagickControllerTest;
import org.alfresco.transform.registry.AbstractTransformRegistry;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import java.io.IOException;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test the AIOController ImageMagick transforms without a server.
* Super class includes tests for the TransformController.
*/
@WebMvcTest()
public class AIOControllerImageMagickTest extends ImageMagickControllerTest
{
@Autowired TransformRegistryImpl transformRegistry;
@BeforeEach @Override
public void before() throws IOException
{
// ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
// ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
// //Need to wire in the mocked commandExecutor into the controller...
// Map<String, Transformer> transformers = transformRegistry.getTransformerEngineMapping();
// transformers.replace("imagemagick", commandExecutor);
//
// mockTransformCommand("jpg", "png", "image/jpeg", true);
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
// @Test
// @Override
// public void noTargetFileTest()
// {
// // Ignore the test in super class as the AIO transforms will not be selected .
// // It is the mock that returns a zero length file for other transformers, when we supply an invalid targetExtension.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfo()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfoExcludingCoreVersion()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithDuplicates()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithEmptyTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithNoTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
}

View File

@@ -0,0 +1,101 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import org.alfresco.transform.libreoffice.LibreOfficeControllerTest;
//import org.alfresco.transform.libreoffice.transformers.LibreOfficeTransformer;
import org.alfresco.transform.registry.AbstractTransformRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import java.util.Map;
@WebMvcTest()
/**
* Test the AIOController without a server.
* Super class includes tests for the LibreOfficeController and TransformController.
*/
public class AIOControllerLibreOfficeTest extends LibreOfficeControllerTest
{
// @Autowired AbstractTransformRegistry transformRegistry;
//
// @Override
// // Used by the super class to mock the javaExecutor, a different implementation is required here
// protected void setJavaExecutor(TransformController controller, LibreOfficeTransformer javaExecutor)
// {
// //Need to wire in the mocked javaExecutor into the controller...
// Map<String,Transformer> transformers = transformRegistry.getTransformerEngineMapping();
// transformers.replace("libreoffice", javaExecutor);
// // No need to set the transform registry to the controller as it is @Autowired in
// }
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
// @Test
// @Override
// public void testGetTransformConfigInfo()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfoExcludingCoreVersion()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithDuplicates()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
// @Test
// @Override
// public void testGetInfoFromConfigWithEmptyTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
// @Test
// @Override
// public void testGetInfoFromConfigWithNoTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
}

View File

@@ -0,0 +1,73 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.alfresco.transform.misc.MiscControllerTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
@WebMvcTest()
public class AIOControllerMiscTest extends MiscControllerTest
{
// @Test
// @Override
// public void testGetTransformConfigInfo()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfoExcludingCoreVersion()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithDuplicates()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithEmptyTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithNoTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
}

View File

@@ -0,0 +1,103 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import org.alfresco.transform.pdfrenderer.AlfrescoPdfRendererControllerTest;
import org.alfresco.transform.registry.AbstractTransformRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import java.util.Map;
@WebMvcTest()
/**
* Test the AIOController PDF Renderer transforms without a server.
* Super class includes tests for the TransformController.
*/
public class AIOControllerPdfRendererTest extends AlfrescoPdfRendererControllerTest
{
@Autowired AbstractTransformRegistry transformRegistry;
@Override
protected void setFields()
{
// ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
// ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
// //Need to wire in the mocked commandExecutor into the controller...
// Map<String,Transformer> transformers = transformRegistry.getTransformerEngineMapping();
// transformers.replace("pdfrenderer", commandExecutor);
}
@Override
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
return builder;
}
// @Test
// @Override
// public void testGetTransformConfigInfo()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfoExcludingCoreVersion()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithDuplicates()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithEmptyTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithNoTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
}

View File

@@ -24,60 +24,44 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import java.io.IOException; import org.alfresco.transform.base.AbstractTransformControllerTest;
import org.alfresco.transform.aio.AIOController;
import org.alfresco.transform.aio.AIOCustomConfig;
import org.alfresco.transform.client.model.TransformRequest; import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transform.config.TransformConfig; import org.alfresco.transform.config.TransformConfig;
import org.alfresco.transformer.AbstractTransformerController;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import java.io.IOException;
import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_DEFAULT; import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_DEFAULT;
import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_LATEST; import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_LATEST;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@WebMvcTest(AIOController.class) @WebMvcTest()
@Import(AIOCustomConfig.class) public class AIOControllerTest extends AbstractTransformControllerTest
public class AIOControllerTest //extends AbstractTransformerControllerTest
{ {
@Value("${transform.core.version}") @Value("${transform.core.version}")
private String coreVersion; private String coreVersion;
@Autowired
AIOController aioController;
//@Override //@Override
protected void mockTransformCommand(String sourceExtension, String targetExtension, String sourceMimetype, protected void mockTransformCommand(String sourceExtension, String targetExtension, String sourceMimetype,
boolean readTargetFileBytes) throws IOException { boolean readTargetFileBytes) throws IOException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
}
//@Override
protected AbstractTransformerController getController() {
// TODO Auto-generated method stub
return null;
} }
//@Override //@Override
protected void updateTransformRequestWithSpecificOptions(TransformRequest transformRequest) { protected void updateTransformRequestWithSpecificOptions(TransformRequest transformRequest) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Test @Test
public void emptyTest() public void emptyTest()
{ {
ResponseEntity<TransformConfig> responseEntity = aioController.info(Integer.valueOf(CONFIG_VERSION_DEFAULT)); ResponseEntity<TransformConfig> responseEntity = controller.transformConfig(Integer.valueOf(CONFIG_VERSION_DEFAULT));
responseEntity.getBody().getTransformers().forEach(transformer -> { responseEntity.getBody().getTransformers().forEach(transformer -> {
assertNull(transformer.getCoreVersion(), transformer.getTransformerName() + assertNull(transformer.getCoreVersion(), transformer.getTransformerName() +
" should have had a null coreValue but was " + transformer.getCoreVersion()); " should have had a null coreValue but was " + transformer.getCoreVersion());
@@ -87,7 +71,7 @@ public class AIOControllerTest //extends AbstractTransformerControllerTest
@Test @Test
public void emptyTestWithLatestVersion() public void emptyTestWithLatestVersion()
{ {
ResponseEntity<TransformConfig> responseEntity = aioController.info(CONFIG_VERSION_LATEST); ResponseEntity<TransformConfig> responseEntity = controller.transformConfig(CONFIG_VERSION_LATEST);
responseEntity.getBody().getTransformers().forEach(transformer -> { responseEntity.getBody().getTransformers().forEach(transformer -> {
assertNotNull(transformer.getCoreVersion(), transformer.getTransformerName() + assertNotNull(transformer.getCoreVersion(), transformer.getTransformerName() +
" should have had a coreValue but was null. Should have been " + coreVersion); " should have had a coreValue but was null. Should have been " + coreVersion);

View File

@@ -0,0 +1,82 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import org.alfresco.transform.tika.TikaControllerTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
@WebMvcTest()
/**
* Test the AIOController Tika transforms without a server.
* Super class includes tests for the TransformController.
*/
public class AIOControllerTikaTest extends TikaControllerTest
{
// @Test
// @Override
// public void testGetTransformConfigInfo()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetTransformConfigInfoExcludingCoreVersion()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithDuplicates()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithEmptyTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void testGetInfoFromConfigWithNoTransformOptions()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// }
//
// @Test
// @Override
// public void xlsxEmbedTest()
// {
// // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
// // It uses the real class path rather than the test one.
// }
}

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.imagemagick.ImageMagickTransformationIT; import org.alfresco.transform.imagemagick.ImageMagickTransformationIT;

View File

@@ -24,11 +24,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.libreoffice.LibreOfficeTransformationIT; import org.alfresco.transform.libreoffice.LibreOfficeTransformationIT;
public class AIOLibreOfficeTransformationIT extends LibreOfficeTransformationIT public class AIOLibreOfficeTransformationIT extends LibreOfficeTransformationIT
{ {
// Tests are in LibreOfficeTransformationIT
} }

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.misc.MiscMetadataExtractsIT; import org.alfresco.transform.misc.MiscMetadataExtractsIT;
@@ -36,5 +36,4 @@ import org.alfresco.transform.misc.MiscMetadataExtractsIT;
*/ */
public class AIOMiscMetadataExtractsIT extends MiscMetadataExtractsIT public class AIOMiscMetadataExtractsIT extends MiscMetadataExtractsIT
{ {
//Tests are in MiscMetadataExtractsIT
} }

View File

@@ -24,11 +24,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.misc.MiscTransformsIT; import org.alfresco.transform.misc.MiscTransformsIT;
public class AIOMiscTransformsIT extends MiscTransformsIT public class AIOMiscTransformsIT extends MiscTransformsIT
{ {
// Tests are in ImageMagickTransformationIT
} }

View File

@@ -24,10 +24,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.pdfRenderer.AlfrescoPdfRendererTransformationIT; import org.alfresco.transform.pdfrenderer.AlfrescoPdfRendererTransformationIT;
public class AIOPdfRendererIT extends AlfrescoPdfRendererTransformationIT { public class AIOPdfRendererIT extends AlfrescoPdfRendererTransformationIT
// Tests are in AlfrescoPdfRendererTransformationIT {
} }

View File

@@ -24,16 +24,16 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import static org.alfresco.transform.common.Mimetype.MIMETYPE_HTML; import org.alfresco.transform.base.AbstractQueueTransformServiceIT;
import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN; import org.alfresco.transform.client.model.TransformRequest;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.UUID; import java.util.UUID;
import org.alfresco.transform.client.model.TransformRequest; import static org.alfresco.transform.common.Mimetype.MIMETYPE_HTML;
import org.alfresco.transformer.AbstractQueueTransformServiceIT; import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
import org.springframework.boot.test.context.SpringBootTest;
/** /**
* @author David Edwards * @author David Edwards

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.tika.TikaMetadataExtractsIT; import org.alfresco.transform.tika.TikaMetadataExtractsIT;
@@ -36,5 +36,4 @@ import org.alfresco.transform.tika.TikaMetadataExtractsIT;
*/ */
public class AIOTikaMetadataExtractsIT extends TikaMetadataExtractsIT public class AIOTikaMetadataExtractsIT extends TikaMetadataExtractsIT
{ {
// Tests are in TikaMetadataExtractsIT
} }

View File

@@ -24,11 +24,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.transform.coreaio; package org.alfresco.transform.aio;
import org.alfresco.transform.tika.TikaTransformationIT; import org.alfresco.transform.tika.TikaTransformationIT;
public class AIOTikaTransformationIT extends TikaTransformationIT public class AIOTikaTransformationIT extends TikaTransformationIT
{ {
// Tests are in ImageMagickTransformationIT
} }

View File

@@ -0,0 +1,312 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2022 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.transform.aio;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.alfresco.transform.config.TransformConfig;
import org.alfresco.transform.registry.AbstractTransformRegistry;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.alfresco.transform.common.RequestParamMap.PAGE_LIMIT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AIOTransformRegistryTest
{
private static final String SOURCE_MIMETYPE = "text/html";
private static final String TARGET_MIMETYPE = "text/plain";
String SOURCE_ENCODING = "sourceEncoding";
@Autowired AbstractTransformRegistry transformRegistry;
ObjectMapper objectMapper = new ObjectMapper();
private void writeToFile(File file, String content, String encoding) throws Exception
{
try (OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(file), encoding))
{
ow.append(content);
}
}
private String readFromFile(File file, final String encoding) throws Exception
{
return new String(Files.readAllBytes(file.toPath()), encoding);
}
private TransformConfig loadConfig(String s) throws Exception
{
return objectMapper.readValue(new ClassPathResource(s).getFile(), TransformConfig.class);
}
@Test
public void testConfigAggregation() throws Exception
{
// List<String> expectedTransformNames = Arrays.asList("html", "string", "appleIWorks", "textToPdf", "rfc822",
// "Archive", "OutlookMsg", "PdfBox", "Office", "Poi", "OOXML", "TikaAuto", "TextMining");
//
// List<String> expectedTransformOptionNames = Arrays.asList("tikaOptions", "archiveOptions", "pdfboxOptions",
// "textToPdfOptions", "stringOptions", "metadataOptions");
//
// TransformConfig miscConfig = loadConfig("misc_engine_config.json");
// TransformConfig tikaConfig = loadConfig("tika_engine_config.json");
//
// // check correct number of transformers
// assertEquals(
// miscConfig.getTransformers().size() + tikaConfig.getTransformers().size(),
// transformRegistry.getTransformConfig().getTransformers().size(),
// "Number of expected transformers");
//
// List<String> actualTransformerNames = transformRegistry.getTransformConfig().getTransformers()
// .stream().map(t -> t.getTransformerName()).collect(Collectors.toList());
// // check all transformers are there
// for(String transformNames : expectedTransformNames)
// {
// assertTrue(actualTransformerNames.contains(transformNames),"Expected transformer missing.");
// }
//
// // check correct number of options
// long distinctOptionCount = Stream.concat(
// miscConfig.getTransformOptions().keySet().stream(),
// tikaConfig.getTransformOptions().keySet().stream()).distinct().count();
// assertEquals(
// distinctOptionCount,
// transformRegistry.getTransformConfig().getTransformOptions().size(),
// "Number of expected transformers");
//
// Set<String> actualOptionNames = transformRegistry.getTransformConfig().getTransformOptions().keySet();
//
// // check all options are there
// for (String optionName : expectedTransformOptionNames)
// {
// assertTrue(actualOptionNames.contains(optionName), "Expected transform option missing:"+optionName);
// }
}
@Test
public void testTransformerMapping()
{
// List<String> tikaTransforms = Arrays.asList("Archive", "OutlookMsg", "PdfBox", "Office", "Poi", "OOXML", "TikaAuto", "TextMining");
// List<String> miscTransforms = Arrays.asList("html", "string", "appleIWorks", "textToPdf", "rfc822");
//
// for (String transform : tikaTransforms)
// {
// String actualId = transformRegistry.getByTransformName(transform).getTransformerId();
// assertEquals("tika", actualId, "Wrong mapping for transform "+transform);
// }
//
// for (String transform : miscTransforms)
// {
// String actualId = transformRegistry.getByTransformName(transform).getTransformerId();
// assertEquals("misc", actualId, "Wrong mapping for transform "+transform);
// }
}
// Test copied from Misc (HtmlParserContentTransformerTest) See ATS-712 aioTransformerRegistry - html
@Test
public void testMiscHtml() throws Exception
{
// final String NEWLINE = System.getProperty("line.separator");
// final String TITLE = "Testing!";
// final String TEXT_P1 = "This is some text in English";
// final String TEXT_P2 = "This is more text in English";
// final String TEXT_P3 = "C'est en Fran\u00e7ais et Espa\u00f1ol";
// String partA = "<html><head><title>" + TITLE + "</title></head>" + NEWLINE;
// String partB = "<body><p>" + TEXT_P1 + "</p>" + NEWLINE +
// "<p>" + TEXT_P2 + "</p>" + NEWLINE +
// "<p>" + TEXT_P3 + "</p>" + NEWLINE;
// String partC = "</body></html>";
// final String expected = TITLE + NEWLINE + TEXT_P1 + NEWLINE + TEXT_P2 + NEWLINE + TEXT_P3 + NEWLINE;
//
// File tmpS = null;
// File tmpD = null;
//
// try
// {
// // Content set to ISO 8859-1
// tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
// writeToFile(tmpS, partA + partB + partC, "ISO-8859-1");
//
// tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
//
// Map<String, String> parameters = new HashMap<>();
// parameters.put(SOURCE_ENCODING, "ISO-8859-1");
// Transformer transformer = transformRegistry.getByTransformName("html");
// transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
//
// assertEquals(expected, readFromFile(tmpD, "UTF-8"));
// tmpS.delete();
// tmpD.delete();
//
// // Content set to UTF-8
// tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
// writeToFile(tmpS, partA + partB + partC, "UTF-8");
//
// tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
// parameters = new HashMap<>();
// parameters.put(SOURCE_ENCODING, "UTF-8");
// transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
// assertEquals(expected, readFromFile(tmpD, "UTF-8"));
// tmpS.delete();
// tmpD.delete();
//
// // Content set to UTF-16
// tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
// writeToFile(tmpS, partA + partB + partC, "UTF-16");
//
// tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
// parameters = new HashMap<>();
// parameters.put(SOURCE_ENCODING, "UTF-16");
// transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
// assertEquals(expected, readFromFile(tmpD, "UTF-8"));
// tmpS.delete();
// tmpD.delete();
//
// // Note - since HTML Parser 2.0 META tags specifying the
// // document encoding will ONLY be respected if the original
// // content type was set to ISO-8859-1.
// //
// // This means there is now only one test which we can perform
// // to ensure that this now-limited overriding of the encoding
// // takes effect.
//
// // Content set to ISO 8859-1, meta set to UTF-8
// tmpS = File.createTempFile("AlfrescoTestSource_", ".html");
// String str = partA +
// "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" +
// partB + partC;
//
// writeToFile(tmpS, str, "UTF-8");
//
// tmpD = File.createTempFile("AlfrescoTestTarget_", ".txt");
//
// parameters = new HashMap<>();
// parameters.put(SOURCE_ENCODING, "ISO-8859-1");
// transformer.transformExtractOrEmbed("html", SOURCE_MIMETYPE, TARGET_MIMETYPE, parameters, tmpS, tmpD);
// assertEquals(expected, readFromFile(tmpD, "UTF-8"));
// tmpS.delete();
// tmpD.delete();
//
// // Note - we can't test UTF-16 with only a meta encoding,
// // because without that the parser won't know about the
// // 2 byte format so won't be able to identify the meta tag
// }
// finally
// {
// if (tmpS != null && tmpS.exists()) tmpS.delete();
// if (tmpD != null && tmpD.exists()) tmpD.delete();
// }
}
// Test copied from Misc (TextToPdfContentTransformerTest) See ATS-712 aioTransformerRegistry - pdf
@Test
public void testMiscPdf() throws Exception
{
transformTextAndCheckPageLength(-1);
}
private void transformTextAndCheckPageLength(int pageLimit) throws Exception
{
int pageLength = 32;
int lines = (pageLength + 10) * ((pageLimit > 0) ? pageLimit : 1);
StringBuilder sb = new StringBuilder();
String checkText = null;
int cutoff = pageLimit * pageLength;
for (int i = 1; i <= lines; i++)
{
sb.append(Integer.toString(i));
sb.append(" I must not talk in class or feed my homework to my cat.\n");
if (i == cutoff)
checkText = sb.toString();
}
sb.append("\nBart\n");
String text = sb.toString();
checkText = (checkText == null) ? clean(text) : clean(checkText);
transformTextAndCheck(text, "UTF-8", checkText, String.valueOf(pageLimit));
}
private void transformTextAndCheck(String text, String encoding, String checkText,
String pageLimit) throws Exception
{
// // Get a reader for the text
// File sourceFile = File.createTempFile("AlfrescoTestSource_", ".txt");
// writeToFile(sourceFile, text, encoding);
//
// // And a temp writer
// File targetFile = File.createTempFile("AlfrescoTestTarget_", ".pdf");
//
// // Transform to PDF
// Map<String, String> parameters = new HashMap<>();
// parameters.put(PAGE_LIMIT, pageLimit);
// Transformer transformer = transformRegistry.getByTransformName("textToPdf");
// transformer.transformExtractOrEmbed("textToPdf", "text/plain", "application/pdf", parameters, sourceFile, targetFile);
//
// // Read back in the PDF and check it
// PDDocument doc = PDDocument.load(targetFile);
// PDFTextStripper textStripper = new PDFTextStripper();
// StringWriter textWriter = new StringWriter();
// textStripper.writeText(doc, textWriter);
// doc.close();
//
// String roundTrip = clean(textWriter.toString());
//
// assertEquals(
// checkText, roundTrip,
// "Incorrect text in PDF when starting from text in " + encoding
// );
//
// sourceFile.delete();
// targetFile.delete();
}
private String clean(String text)
{
text = text.replaceAll("\\s+\\r", "");
text = text.replaceAll("\\s+\\n", "");
text = text.replaceAll("\\r", "");
text = text.replaceAll("\\n", "");
return text;
}
}

View File

@@ -49,7 +49,7 @@ src/main/java/org/alfresco/transformer/Application.java
~~~ ~~~
* *TransformerName*Controller.java - A [Spring Boot](https://projects.spring.io/spring-boot/) Controller that * *TransformerName*Controller.java - A [Spring Boot](https://projects.spring.io/spring-boot/) Controller that
extends AbstractTransformerController to handel requests. It implements a few methods including *transformImpl* extends TransformController to handel requests. It implements a few methods including *transformImpl*
which is intended to perform the actual transform. Generally the transform is done in a sub class of which is intended to perform the actual transform. Generally the transform is done in a sub class of
*JavaExecutor*, when a Java library is being used or *AbstractCommandExecutor*, when an external process is used. *JavaExecutor*, when a Java library is being used or *AbstractCommandExecutor*, when an external process is used.
Both are sub interfaces of *Transformer*. Both are sub interfaces of *Transformer*.
@@ -57,7 +57,7 @@ src/main/java/org/alfresco/transformer/Application.java
~~~ ~~~
... ...
@Controller @Controller
public class TransformerNameController extends AbstractTransformerController public class TransformerNameController extends TransformController
{ {
private static final Logger logger = LoggerFactory.getLogger(TransformerNameController.class); private static final Logger logger = LoggerFactory.getLogger(TransformerNameController.class);
@@ -149,7 +149,7 @@ public class Application
} }
~~~ ~~~
Transform requests are handled by the *AbstractTransformerController*, but are either: Transform requests are handled by the *TransformController*, but are either:
* POST requests (a direct http request from a client) where the transform options are passed as parameters, the source is supplied as a multipart file and * POST requests (a direct http request from a client) where the transform options are passed as parameters, the source is supplied as a multipart file and
the response is a file download. the response is a file download.
* POST request (a request via a message queue) where the transform options are supplied as JSON and the response is also JSON. * POST request (a request via a message queue) where the transform options are supplied as JSON and the response is also JSON.
@@ -210,7 +210,7 @@ The artifacts can be obtained by:
~~~ ~~~
<dependency> <dependency>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-t-engine-base</artifactId> <artifactId>alfresco-base-t-engine</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
~~~ ~~~

View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-base-t-engine</artifactId>
<name>- Base</name>
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
@@ -8,8 +10,6 @@
<version>2.6.1-SNAPSHOT</version> <version>2.6.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>alfresco-t-engine-base</artifactId>
<properties> <properties>
<transformer.base.deploy.skip>false</transformer.base.deploy.skip> <transformer.base.deploy.skip>false</transformer.base.deploy.skip>
</properties> </properties>

View File

@@ -74,6 +74,7 @@ import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -160,6 +161,12 @@ public class TransformController
.filter(transformEngine -> transformEngine.getTransformConfig() == null) .filter(transformEngine -> transformEngine.getTransformConfig() == null)
.findFirst() .findFirst()
.orElse(transformEngines.get(0)); .orElse(transformEngines.get(0));
logger.info("TransformEngine: " + transformEngine.getTransformEngineName());
transformEngines.stream()
.filter(te -> te != transformEngine)
.sorted(Comparator.comparing(TransformEngine::getTransformEngineName))
.map(transformEngine -> " "+transformEngine.getTransformEngineName()).forEach(logger::info);
} }
} }
@@ -175,8 +182,13 @@ public class TransformController
{ {
if (customTransformers != null) if (customTransformers != null)
{ {
customTransformers.forEach(customTransformer -> customTransformersByName.put(customTransformer.getTransformerName(), customTransformers.forEach(customTransformer ->
customTransformer)); customTransformersByName.put(customTransformer.getTransformerName(), customTransformer));
logger.info("Transformers:");
customTransformers.stream()
.sorted(Comparator.comparing(CustomTransformer::getTransformerName))
.map(customTransformer -> " "+customTransformer.getTransformerName()).forEach(logger::info);
} }
} }
@@ -187,9 +199,7 @@ public class TransformController
logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------"); logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------");
if (transformEngines != null) if (transformEngines != null)
{ {
transformEngines.stream() Arrays.stream(transformEngine.getStartupMessage().split("\\n")).forEach(logger::info);
.map(transformEngine -> transformEngine.getStartupMessage())
.forEach(message -> Arrays.stream(message.split("\\n")).forEach(logger::info));
} }
logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------"); logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------");

Some files were not shown because too many files have changed in this diff Show More