ATS-669: Parameterize T-Engines transformer execution locations (#203)

* ATS-669: Implement cmd line arguments for ImageMagick, PdfRenderer and LibreOffice

* ATS-669: Remove unnecessary test ImageMagick line

* ATS-669: Implement Spring boot properties via application.yaml

* ATS-669: Implement Spring config binds and utilize new functionality in pdfRender

* ATS-669: Wire externalProps for ImageMagick

* ATS-669: Wire externalProps for LibreOffice

* ATS-669: Fix failing tests

* ATS-669: Implement parameterized execution for All-In-One transform module

* ATS-669: Use string values instead of GlobalProperties class

* ATS-669: Change pdfrenderer property format

* ATS-669: Add validation to executor constructors

* ATS-669: Fix failing LibreOffice tests

* ATS-669: Add missing license

* ATS-669: Update LibreOffice version

* ATS-669: Remove unnecessary annotation

* ATS-669: Standardise properties

* ATS-669: Change field variable names

* ATS-669: Change field variable values

* ATS-669: Add unit tests for passing system properties

* ATS-669: Standardise yaml properties

* ATS-669: Remove unnecessary super() calls

* ATS-669: Change CRLF to LF

* ATS-669: Change LF to CRLF

* ATS-669: Fix yaml indentation

* ATS-669: Update tika and misc yaml file with new sub-property

* ATS-669: Remove unused import

* ATS-669: Update TransformRegistryImpl property location
This commit is contained in:
Kristian Dimitrov
2020-04-16 16:32:01 +01:00
committed by GitHub
parent a0ebe96217
commit a1b6283a4c
26 changed files with 239 additions and 41 deletions

View File

@@ -80,6 +80,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<PDF_RENDERER_EXE>/usr/bin/alfresco-pdf-renderer</PDF_RENDERER_EXE>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@@ -36,6 +36,7 @@ import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
import java.io.File;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
@@ -43,7 +44,7 @@ import org.alfresco.transformer.logging.LogEntry;
import org.alfresco.transformer.probes.ProbeTestTransform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
@@ -77,7 +78,16 @@ public class AlfrescoPdfRendererController extends AbstractTransformerController
private static final Logger logger = LoggerFactory.getLogger(
AlfrescoPdfRendererController.class);
private PdfRendererCommandExecutor commandExecutor = new PdfRendererCommandExecutor();
@Value("${transform.core.pdfrenderer.exe}")
private String execPath;
PdfRendererCommandExecutor commandExecutor;
@PostConstruct
private void init()
{
commandExecutor = new PdfRendererCommandExecutor(execPath);
}
@Override
public String getTransformerName()

View File

@@ -1,5 +1,8 @@
queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.alfresco-pdf-renderer.acs}
transform:
config:
location: classpath:pdfrenderer_engine_config.json
core:
config:
location: classpath:pdfrenderer_engine_config.json
pdfrenderer:
exe: ${PDFRENDERER_EXE:/usr/bin/alfresco-pdf-renderer}

View File

@@ -67,6 +67,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.core.io.FileSystemResource;
@@ -78,6 +79,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import javax.annotation.PostConstruct;
/**
* Test the AlfrescoPdfRendererController without a server.
* Super class includes tests for the AbstractTransformerController.
@@ -97,8 +100,17 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
@Mock
private RuntimeExec mockCheckCommand;
private PdfRendererCommandExecutor commandExecutor = new PdfRendererCommandExecutor();
@Value("${transform.core.pdfrenderer.exe}")
private String execPath;
PdfRendererCommandExecutor commandExecutor;
@PostConstruct
private void init()
{
commandExecutor = new PdfRendererCommandExecutor(execPath);
}
@SpyBean
private AlfrescoPdfRendererController controller;
@@ -315,4 +327,11 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
assertEquals(transformRequest.getClientData(), transformReply.getClientData());
assertEquals(transformRequest.getSchema(), transformReply.getSchema());
}
@Test
public void testOverridingExecutorPaths()
{
//System test property value can me modified in the pom.xml
assertEquals(execPath, System.getProperty("PDF_RENDERER_EXE"));
}
}

View File

@@ -37,7 +37,18 @@ public class PdfRendererCommandExecutor extends AbstractCommandExecutor
{
public static final String LICENCE = "This transformer uses alfresco-pdf-renderer which uses the PDFium library from Google Inc. See the license at https://pdfium.googlesource.com/pdfium/+/master/LICENSE or in /pdfium.txt";
private static final String EXE = "/usr/bin/alfresco-pdf-renderer";
private final String EXE;
public PdfRendererCommandExecutor(String exe)
{
if (exe == null || exe.isEmpty())
{
throw new IllegalArgumentException("PdfRendererCommandExecutor EXE variable cannot be null or empty");
}
this.EXE = exe;
super.transformCommand = createTransformCommand();
super.checkCommand = createCheckCommand();
}
@Override
protected RuntimeExec createTransformCommand()