mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2026-04-23 22:30:28 +00:00
ACS-10505 fixing review comments
This commit is contained in:
@@ -14,6 +14,7 @@ The following externalized T-engines properties are available:
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| FILE_STORE_URL | T-Engine Port. | http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file |
|
||||
| TEST_ENDPOINT_ENABLED |Enable/Disable **/test** endpoint| true
|
||||
| PDFBOX_NOTEXTRACTBOOKMARKS_DEFAULT | The default behaviour for notExtractBookmarksText when this request param is omitted from a request. | false |
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for receiving async requests. | org.alfresco.transform.engine.tika.acs |
|
||||
|
||||
@@ -28,6 +29,7 @@ The following externalized T-engines properties are available:
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| FILE_STORE_URL | T-Engine Port. | http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file |
|
||||
| TEST_ENDPOINT_ENABLED |Enable/Disable **/test** endpoint| true
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for async requests. | org.alfresco.transform.engine.alfresco-pdf-renderer.acs |
|
||||
| PDFRENDERER_EXE | Path to Pdf-renderer EXE. | /usr/bin/alfresco-pdf-renderer |
|
||||
|
||||
@@ -46,22 +48,23 @@ The following externalized T-engines properties are available:
|
||||
| MISC_HTML_COLLAPSE | Html Collasping Option for HTML to TXT transformation | true |
|
||||
|
||||
## Libreoffice
|
||||
| Property | Description | Default value |
|
||||
|----------|-------------|---------------|
|
||||
| SERVER_PORT | T-Engine Port | 8090 |
|
||||
| HOSTNAME | T-Engine Name. | t-engine |
|
||||
| ACTIVEMQ_URL | ActiveMQ URL. | nio://localhost:61616 |
|
||||
| ACTIVEMQ_USER | ActiveMQ User. | admin |
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| Property | Description | Default value |
|
||||
|----------|-------------|--------------------------------------------------------------------------|
|
||||
| SERVER_PORT | T-Engine Port | 8090 |
|
||||
| HOSTNAME | T-Engine Name. | t-engine |
|
||||
| ACTIVEMQ_URL | ActiveMQ URL. | nio://localhost:61616 |
|
||||
| ACTIVEMQ_USER | ActiveMQ User. | admin |
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| FILE_STORE_URL | T-Engine Port. | http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file |
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for async requests. | org.alfresco.transform.engine.libreoffice.acs |
|
||||
| LIBREOFFICE_HOME | Path to LibreOffice_Home. | /opt/libreoffice7.2 |
|
||||
| LIBREOFFICE_MAX_TASKS_PER_PROCESS | Number of maximum tasks per process. | 200 |
|
||||
| LIBREOFFICE_TIMEOUT | Timeout value for LibreOffice `execution timeout`, `queue timeout` and `connection timeout`. | 1200000 |
|
||||
| LIBREOFFICE_PORT_NUMBERS | LibreOffice port. | 8100 |
|
||||
| LIBREOFFICE_TEMPLATE_PROFILE_DIR | Path to user profile. | |
|
||||
| LIBREOFFICE_IS_ENABLED | Enables Libreoffice executioner. | true |
|
||||
| TEST_ENDPOINT_ENABLED |Enable/Disable **/test** endpoint| true
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for async requests. | org.alfresco.transform.engine.libreoffice.acs |
|
||||
| LIBREOFFICE_HOME | Path to LibreOffice_Home. | /opt/libreoffice7.2 |
|
||||
| LIBREOFFICE_MAX_TASKS_PER_PROCESS | Number of maximum tasks per process. | 200 |
|
||||
| LIBREOFFICE_TIMEOUT | Timeout value for LibreOffice `execution timeout`, `queue timeout` and `connection timeout`. | 1200000 |
|
||||
| LIBREOFFICE_PORT_NUMBERS | LibreOffice port. | 8100 |
|
||||
| LIBREOFFICE_TEMPLATE_PROFILE_DIR | Path to user profile. | alfresco_default |
|
||||
| LIBREOFFICE_IS_ENABLED | Enables Libreoffice executioner. | true |
|
||||
|
||||
## Imagemagick
|
||||
| Property | Description | Default value |
|
||||
@@ -73,6 +76,7 @@ The following externalized T-engines properties are available:
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| FILE_STORE_URL | T-Engine Port. | http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file |
|
||||
| TEST_ENDPOINT_ENABLED |Enable/Disable **/test** endpoint| true
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for async requests. | org.alfresco.transform.engine.imagemagick.acs |
|
||||
| IMAGEMAGICK_ROOT | Path to Imagemagick Root. | /usr/lib64/ImageMagick-7.0.10 |
|
||||
| IMAGEMAGICK_DYN | Path to Imagemagick DYLD. | /usr/lib64/ImageMagick-7.0.10/lib |
|
||||
@@ -91,6 +95,7 @@ The following externalized T-engines properties are available:
|
||||
| ACTIVEMQ_PASSWORD | ActiveMQ Password. | admin |
|
||||
| ACTIVEMQ_URL_PARAMS | ActiveMQ connection options. | ?jms.watchTopicAdvisories=false |
|
||||
| FILE_STORE_URL | T-Engine Port. | http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file |
|
||||
| TEST_ENDPOINT_ENABLED |Enable/Disable **/test** endpoint| true
|
||||
| PDFBOX_NOTEXTRACTBOOKMARKS_DEFAULT | The default behaviour for notExtractBookmarksText when this request param is omitted from a request. | false |
|
||||
| TRANSFORM_ENGINE_REQUEST_QUEUE | T-Engine queue used for async requests. | org.alfresco.transform.engine.aio.acs |
|
||||
| PDFRENDERER_EXE | Path to Pdf-renderer EXE. | /usr/bin/alfresco-pdf-renderer |
|
||||
|
||||
@@ -10,7 +10,7 @@ transform:
|
||||
maxTasksPerProcess: ${LIBREOFFICE_MAX_TASKS_PER_PROCESS:200}
|
||||
timeout: ${LIBREOFFICE_TIMEOUT:1200000}
|
||||
portNumbers: ${LIBREOFFICE_PORT_NUMBERS:8100}
|
||||
templateProfileDir: ${LIBREOFFICE_TEMPLATE_PROFILE_DIR:classpath:templateProfileDir}
|
||||
templateProfileDir: ${LIBREOFFICE_TEMPLATE_PROFILE_DIR:alfresco_default}
|
||||
isEnabled: ${LIBREOFFICE_IS_ENABLED:true}
|
||||
imagemagick:
|
||||
root: ${IMAGEMAGICK_ROOT:/usr/lib64/ImageMagick-7.1.2}
|
||||
|
||||
@@ -38,7 +38,7 @@ filestore-url: ${FILE_STORE_URL:http://localhost:8099/alfresco/api/-default-/pri
|
||||
transform:
|
||||
endpoint:
|
||||
test:
|
||||
enable: true
|
||||
enable: ${TEST_ENDPOINT_ENABLED:true}
|
||||
core:
|
||||
version: @project.version@
|
||||
engine:
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.nio.file.StandardCopyOption;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -56,35 +57,40 @@ public class LibreOfficeProfileManager
|
||||
private static final String REGISTRY_FILE_NAME = "registrymodifications.xcu";
|
||||
private static final String DEFAULT_LO_TEMPLATE_PROFILE = "libreoffice_templateProfile";
|
||||
|
||||
private String classPathRegistryFile;
|
||||
private final String templateProfileDir;
|
||||
|
||||
public String getEffectiveTemplateProfileDir(String templateProfileDir)
|
||||
public LibreOfficeProfileManager(String templateProfileDir)
|
||||
{
|
||||
if (StringUtils.startsWith(templateProfileDir, "classpath:"))
|
||||
this.templateProfileDir = templateProfileDir;
|
||||
}
|
||||
|
||||
public String getEffectiveTemplateProfileDir()
|
||||
{
|
||||
if (Strings.CS.equals(templateProfileDir, "alfresco_default"))
|
||||
{
|
||||
createDefaultTemplateProfileDir(templateProfileDir);
|
||||
return createDefaultTemplateProfileDirFromResource();
|
||||
}
|
||||
else if (StringUtils.isNotBlank(templateProfileDir))
|
||||
{
|
||||
checkUserProvidedRegistry(templateProfileDir);
|
||||
return templateProfileDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("No template profile directory provided, using default settings.");
|
||||
return templateProfileDir;
|
||||
}
|
||||
|
||||
return StringUtils.isBlank(classPathRegistryFile) ? templateProfileDir : classPathRegistryFile;
|
||||
}
|
||||
|
||||
private void createDefaultTemplateProfileDir(String classpathTemplateDir)
|
||||
private String createDefaultTemplateProfileDirFromResource()
|
||||
{
|
||||
try
|
||||
{
|
||||
String baseDir = classpathTemplateDir.replace("classpath:", "");
|
||||
Resource[] resources = loadResources(classpathTemplateDir);
|
||||
String baseDir = "templateProfileDir";
|
||||
Resource[] resources = loadResources("classpath:" + baseDir);
|
||||
if (ArrayUtils.isEmpty(resources))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
Path tempDir = Files.createTempDirectory(DEFAULT_LO_TEMPLATE_PROFILE);
|
||||
@@ -103,11 +109,12 @@ public class LibreOfficeProfileManager
|
||||
}
|
||||
copyResource(resource, tempDir.resolve(relative));
|
||||
}
|
||||
this.classPathRegistryFile = tempDir.toString();
|
||||
return tempDir.toString();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warn("Error creating temporary directory for LibreOffice profile. {}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +213,7 @@ public class LibreOfficeProfileManager
|
||||
try
|
||||
{
|
||||
String content = Files.readString(registryFile.toPath(), StandardCharsets.UTF_8);
|
||||
content = content.replaceAll("\\s+", ""); // remove whitespace for easier searching
|
||||
|
||||
boolean hasBlockUntrustedProperty = content.contains("oor:path=\"/org.openoffice.Office.Common/Security/Scripting\"")
|
||||
&& content.contains("oor:name=\"BlockUntrustedRefererLinks\"");
|
||||
@@ -213,7 +221,7 @@ public class LibreOfficeProfileManager
|
||||
if (hasBlockUntrustedProperty)
|
||||
{
|
||||
boolean isEnabled = content.contains("<prop oor:name=\"BlockUntrustedRefererLinks\"")
|
||||
&& content.contains("<value>true</value>");
|
||||
&& content.contains("<prop oor:name=\"BlockUntrustedRefererLinks\" oor:op=\"fuse\"><value>falvcdesxazse</value>");
|
||||
|
||||
if (!isEnabled)
|
||||
{
|
||||
|
||||
@@ -111,8 +111,8 @@ public class LibreOfficeTransformer implements JavaExecutor, CustomTransformerFi
|
||||
throw new IllegalArgumentException("LibreOfficeTransformer LIBREOFFICE_IS_ENABLED variable must be set to true/false");
|
||||
}
|
||||
|
||||
LibreOfficeProfileManager profileManager = new LibreOfficeProfileManager();
|
||||
String effectiveTemplateProfileDir = profileManager.getEffectiveTemplateProfileDir(templateProfileDir);
|
||||
LibreOfficeProfileManager profileManager = new LibreOfficeProfileManager(templateProfileDir);
|
||||
String effectiveTemplateProfileDir = profileManager.getEffectiveTemplateProfileDir();
|
||||
|
||||
JodConverterSharedInstance sharedInstance = new JodConverterSharedInstance();
|
||||
jodconverter = sharedInstance;
|
||||
|
||||
@@ -7,5 +7,5 @@ transform:
|
||||
maxTasksPerProcess: ${LIBREOFFICE_MAX_TASKS_PER_PROCESS:200}
|
||||
timeout: ${LIBREOFFICE_TIMEOUT:1200000}
|
||||
portNumbers: ${LIBREOFFICE_PORT_NUMBERS:8100}
|
||||
templateProfileDir: ${LIBREOFFICE_TEMPLATE_PROFILE_DIR:classpath:templateProfileDir}
|
||||
templateProfileDir: ${LIBREOFFICE_TEMPLATE_PROFILE_DIR:alfresco_default}
|
||||
isEnabled: ${LIBREOFFICE_IS_ENABLED:true}
|
||||
Reference in New Issue
Block a user