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
@@ -91,6 +91,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<LIBREOFFICE_HOME>/opt/libreoffice6.3</LIBREOFFICE_HOME>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@@ -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.LibreOfficeJavaExecutor;
|
||||
@@ -44,6 +45,7 @@ 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 +79,16 @@ public class LibreOfficeController extends AbstractTransformerController
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeController.class);
|
||||
|
||||
private LibreOfficeJavaExecutor javaExecutor = new LibreOfficeJavaExecutor();
|
||||
@Value("${transform.core.libreoffice.home}")
|
||||
private String execPath;
|
||||
|
||||
LibreOfficeJavaExecutor javaExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
{
|
||||
javaExecutor = new LibreOfficeJavaExecutor(execPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTransformerName()
|
||||
|
@@ -1,5 +1,8 @@
|
||||
queue:
|
||||
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.libreoffice.acs}
|
||||
transform:
|
||||
config:
|
||||
location: classpath:libreoffice_engine_config.json
|
||||
core:
|
||||
config:
|
||||
location: classpath:libreoffice_engine_config.json
|
||||
libreoffice:
|
||||
home: ${LIBREOFFICE_HOME:/opt/libreoffice6.3}
|
@@ -62,6 +62,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
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;
|
||||
@@ -73,6 +75,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 LibreOfficeController without a server.
|
||||
* Super class includes tests for the AbstractTransformerController.
|
||||
@@ -87,8 +91,16 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
@Mock
|
||||
private ExecutionResult mockExecutionResult;
|
||||
|
||||
@SpyBean
|
||||
private LibreOfficeJavaExecutor javaExecutor;
|
||||
@Value("${transform.core.libreoffice.home}")
|
||||
private String execPath;
|
||||
|
||||
LibreOfficeJavaExecutor javaExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
{
|
||||
javaExecutor = Mockito.spy(new LibreOfficeJavaExecutor(execPath));
|
||||
}
|
||||
|
||||
@SpyBean
|
||||
private LibreOfficeController controller;
|
||||
@@ -235,4 +247,11 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
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("LIBREOFFICE_HOME"));
|
||||
}
|
||||
}
|
||||
|
@@ -53,14 +53,20 @@ public class LibreOfficeJavaExecutor implements JavaExecutor
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeJavaExecutor.class);
|
||||
|
||||
private static final int JODCONVERTER_TRANSFORMATION_ERROR_CODE = 3088;
|
||||
private static final String OFFICE_HOME = "/opt/libreoffice6.3";
|
||||
|
||||
private static String LIBREOFFICE_HOME;
|
||||
|
||||
public static final String LICENCE = "This transformer uses LibreOffice from The Document Foundation. See the license at https://www.libreoffice.org/download/license/ or in /libreoffice.txt";
|
||||
|
||||
private JodConverter jodconverter;
|
||||
|
||||
public LibreOfficeJavaExecutor()
|
||||
public LibreOfficeJavaExecutor(String path)
|
||||
{
|
||||
if (path == null || path.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("LibreOfficeJavaExecutor OFFICE_HOME variable cannot be null or empty");
|
||||
}
|
||||
LIBREOFFICE_HOME = path;
|
||||
jodconverter = createJodConverter();
|
||||
}
|
||||
|
||||
@@ -70,7 +76,7 @@ public class LibreOfficeJavaExecutor implements JavaExecutor
|
||||
|
||||
final JodConverterSharedInstance jodconverter = new JodConverterSharedInstance();
|
||||
|
||||
jodconverter.setOfficeHome(OFFICE_HOME); // jodconverter.officeHome
|
||||
jodconverter.setOfficeHome(LIBREOFFICE_HOME); // jodconverter.officeHome
|
||||
jodconverter.setMaxTasksPerProcess("200"); // jodconverter.maxTasksPerProcess
|
||||
jodconverter.setTaskExecutionTimeout(timeout); // jodconverter.maxTaskExecutionTimeout
|
||||
jodconverter.setTaskQueueTimeout(timeout); // jodconverter.taskQueueTimeout
|
||||
|
Reference in New Issue
Block a user