mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
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:
committed by
GitHub
parent
a0ebe96217
commit
a1b6283a4c
@@ -81,6 +81,14 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<IMAGEMAGICK_EXE>/usr/bin/convert</IMAGEMAGICK_EXE>
|
||||
<IMAGEMAGICK_DYN>/usr/lib64/ImageMagick-7.0.7/lib</IMAGEMAGICK_DYN>
|
||||
<IMAGEMAGICK_ROOT>/usr/lib64/ImageMagick-7.0.7</IMAGEMAGICK_ROOT>
|
||||
<buildDirectory>${project.build.directory}</buildDirectory>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@@ -37,6 +37,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.ImageMagickCommandExecutor;
|
||||
@@ -44,7 +45,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;
|
||||
@@ -79,7 +80,22 @@ public class ImageMagickController extends AbstractTransformerController
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImageMagickController.class);
|
||||
|
||||
private ImageMagickCommandExecutor commandExecutor = new ImageMagickCommandExecutor();
|
||||
@Value("${transform.core.imagemagick.exe}")
|
||||
private String EXE;
|
||||
|
||||
@Value("${transform.core.imagemagick.dyn}")
|
||||
private String DYN;
|
||||
|
||||
@Value("${transform.core.imagemagick.root}")
|
||||
private String ROOT;
|
||||
|
||||
ImageMagickCommandExecutor commandExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
{
|
||||
commandExecutor = new ImageMagickCommandExecutor(EXE, DYN, ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTransformerName()
|
||||
|
@@ -1,5 +1,10 @@
|
||||
queue:
|
||||
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.imagemagick.acs}
|
||||
transform:
|
||||
config:
|
||||
location: classpath:imagemagick_engine_config.json
|
||||
core:
|
||||
config:
|
||||
location: classpath:imagemagick_engine_config.json
|
||||
imagemagick:
|
||||
root: ${IMAGEMAGICK_ROOT:/usr/lib64/ImageMagick-7.0.7}
|
||||
dyn: ${IMAGEMAGICK_DYN:/usr/lib64/ImageMagick-7.0.7/lib}
|
||||
exe: ${IMAGEMAGICK_EXE:/usr/bin/convert}
|
@@ -66,6 +66,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;
|
||||
@@ -77,6 +78,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 ImageMagickController without a server.
|
||||
* Super class includes tests for the AbstractTransformerController.
|
||||
@@ -96,7 +99,22 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
@Mock
|
||||
private RuntimeExec mockCheckCommand;
|
||||
|
||||
private ImageMagickCommandExecutor commandExecutor = new ImageMagickCommandExecutor();
|
||||
@Value("${transform.core.imagemagick.exe}")
|
||||
private String EXE;
|
||||
|
||||
@Value("${transform.core.imagemagick.dyn}")
|
||||
private String DYN;
|
||||
|
||||
@Value("${transform.core.imagemagick.root}")
|
||||
private String ROOT;
|
||||
|
||||
ImageMagickCommandExecutor commandExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
{
|
||||
commandExecutor = new ImageMagickCommandExecutor(EXE, DYN, ROOT);
|
||||
}
|
||||
|
||||
@SpyBean
|
||||
private ImageMagickController controller;
|
||||
@@ -392,4 +410,13 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
assertEquals(transformRequest.getClientData(), transformReply.getClientData());
|
||||
assertEquals(transformRequest.getSchema(), transformReply.getSchema());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverridingExecutorPaths()
|
||||
{
|
||||
//System test property values can me modified in the pom.xml
|
||||
assertEquals(EXE, System.getProperty("IMAGEMAGICK_EXE"));
|
||||
assertEquals(DYN, System.getProperty("IMAGEMAGICK_DYN"));
|
||||
assertEquals(ROOT, System.getProperty("IMAGEMAGICK_ROOT"));
|
||||
}
|
||||
}
|
||||
|
@@ -35,9 +35,31 @@ import java.util.Map;
|
||||
*/
|
||||
public class ImageMagickCommandExecutor extends AbstractCommandExecutor
|
||||
{
|
||||
private static final String ROOT = "/usr/lib64/ImageMagick-7.0.7";
|
||||
private static final String DYN = ROOT + "/lib";
|
||||
private static final String EXE = "/usr/bin/convert";
|
||||
private final String ROOT;
|
||||
private final String DYN;
|
||||
private final String EXE;
|
||||
|
||||
public ImageMagickCommandExecutor(String exe, String dyn, String root)
|
||||
{
|
||||
if (exe == null || exe.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("ImageMagickCommandExecutor EXE variable cannot be null or empty");
|
||||
}
|
||||
if (dyn == null || dyn.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("ImageMagickCommandExecutor DYN variable cannot be null or empty");
|
||||
}
|
||||
if (root == null || root.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("ImageMagickCommandExecutor ROOT variable cannot be null or empty");
|
||||
}
|
||||
this.EXE = exe;
|
||||
this.DYN = dyn;
|
||||
this.ROOT = root;
|
||||
|
||||
super.transformCommand = createTransformCommand();
|
||||
super.checkCommand = createCheckCommand();
|
||||
}
|
||||
|
||||
public static final String LICENCE = "This transformer uses ImageMagick from ImageMagick Studio LLC. See the license at http://www.imagemagick.org/script/license.php or in /ImageMagick-license.txt";
|
||||
|
||||
|
Reference in New Issue
Block a user