mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
ACS-2498 Switch to using a configVersion parameter on the /transform/config endpoint (#530)
* Fixed the config returned by the AIO as it did not include the coreVersion even though the individual ones did.
This commit is contained in:
parent
df519cfd6f
commit
a89e161004
@ -44,7 +44,8 @@ import java.util.Map;
|
|||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
|
||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
|
||||||
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
|
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.INCLUDE_CORE_VERSION;
|
import static org.alfresco.transform.client.util.RequestParamMap.CONFIG_VERSION_DEFAULT;
|
||||||
|
import static org.alfresco.transformer.util.RequestParamMap.CONFIG_VERSION;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING;
|
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER;
|
import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER;
|
||||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||||
@ -92,11 +93,11 @@ public class AIOController extends AbstractTransformerController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<TransformConfig> info(
|
public ResponseEntity<TransformConfig> info(
|
||||||
@RequestParam(value = INCLUDE_CORE_VERSION, required = false) Boolean includeCoreVersion)
|
@RequestParam(value = CONFIG_VERSION, defaultValue = CONFIG_VERSION_DEFAULT) int configVersion)
|
||||||
{
|
{
|
||||||
logger.info("GET Transform Config" + (includeCoreVersion != null && includeCoreVersion ? " including coreVersion" : ""));
|
logger.info("GET Transform Config version: " + configVersion);
|
||||||
TransformConfig transformConfig = transformRegistry.getTransformConfig();
|
TransformConfig transformConfig = transformRegistry.getTransformConfig();
|
||||||
transformConfig = setOrClearCoreVersion(transformConfig, includeCoreVersion);
|
transformConfig = setOrClearCoreVersion(transformConfig, configVersion);
|
||||||
return new ResponseEntity<>(transformConfig, OK);
|
return new ResponseEntity<>(transformConfig, OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -85,6 +85,9 @@ public class AIOCustomConfig
|
|||||||
@Value("${transform.core.tika.pdfBox.notExtractBookmarksTextDefault:false}")
|
@Value("${transform.core.tika.pdfBox.notExtractBookmarksTextDefault:false}")
|
||||||
private boolean notExtractBookmarksTextDefault;
|
private boolean notExtractBookmarksTextDefault;
|
||||||
|
|
||||||
|
@Value("${transform.core.version}")
|
||||||
|
private String coreVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return Override the TransformRegistryImpl used in {@link AbstractTransformerController}
|
* @return Override the TransformRegistryImpl used in {@link AbstractTransformerController}
|
||||||
@ -94,13 +97,14 @@ public class AIOCustomConfig
|
|||||||
public TransformServiceRegistry aioTransformRegistry() throws Exception
|
public TransformServiceRegistry aioTransformRegistry() throws Exception
|
||||||
{
|
{
|
||||||
AIOTransformRegistry aioTransformRegistry = new AIOTransformRegistry();
|
AIOTransformRegistry aioTransformRegistry = new AIOTransformRegistry();
|
||||||
|
aioTransformRegistry.setCoreVersion(coreVersion);
|
||||||
|
|
||||||
// T-Engines are sorted by name so they are combined in the same order as in the T-Router
|
// T-Engines are sorted by name so they are combined in the same order as in the T-Router
|
||||||
// and Content Repository with individual T-Engines. See TransformersConfigRegistry#retrieveRemoteConfig and
|
// and Content Repository with individual T-Engines. See TransformersConfigRegistry#retrieveRemoteConfig and
|
||||||
// LocalTransformServiceRegistry#getTEngineUrlsSortedByName.
|
// LocalTransformServiceRegistry#getTEngineUrlsSortedByName.
|
||||||
for (Transformer tEngine : getTEnginesSortedByName())
|
for (Transformer tEngine : getTEnginesSortedByName())
|
||||||
{
|
{
|
||||||
aioTransformRegistry.registerTransformer(tEngine); // now a poor name - should be combinedTransformers
|
aioTransformRegistry.registerTransformer(tEngine); // now a poor name - should be combineTransformers
|
||||||
}
|
}
|
||||||
aioTransformRegistry.registerCombinedTransformers();
|
aioTransformRegistry.registerCombinedTransformers();
|
||||||
return aioTransformRegistry;
|
return aioTransformRegistry;
|
||||||
|
@ -29,15 +29,26 @@ package org.alfresco.transformer;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.alfresco.transform.client.model.TransformRequest;
|
import org.alfresco.transform.client.model.TransformRequest;
|
||||||
|
import org.alfresco.transform.client.model.config.TransformConfig;
|
||||||
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.Autowired;
|
||||||
|
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.context.annotation.Import;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.CONFIG_VERSION_DEFAULT;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.CONFIG_VERSION_LATEST;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
@WebMvcTest(AIOController.class)
|
@WebMvcTest(AIOController.class)
|
||||||
@Import(AIOCustomConfig.class)
|
@Import(AIOCustomConfig.class)
|
||||||
public class AIOControllerTest //extends AbstractTransformerControllerTest
|
public class AIOControllerTest //extends AbstractTransformerControllerTest
|
||||||
{
|
{
|
||||||
|
@Value("${transform.core.version}")
|
||||||
|
private String coreVersion;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AIOController aioController;
|
AIOController aioController;
|
||||||
|
|
||||||
@ -63,12 +74,20 @@ public class AIOControllerTest //extends AbstractTransformerControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void emptyTest()
|
public void emptyTest()
|
||||||
{
|
{
|
||||||
aioController.info(null);
|
ResponseEntity<TransformConfig> responseEntity = aioController.info(Integer.valueOf(CONFIG_VERSION_DEFAULT));
|
||||||
|
responseEntity.getBody().getTransformers().forEach(transformer -> {
|
||||||
|
assertNull(transformer.getCoreVersion(), transformer.getTransformerName() +
|
||||||
|
" should have had a null coreValue but was " + transformer.getCoreVersion());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyTestWithIncludeCoreVersion()
|
public void emptyTestWithLatestVersion()
|
||||||
{
|
{
|
||||||
aioController.info(true);
|
ResponseEntity<TransformConfig> responseEntity = aioController.info(CONFIG_VERSION_LATEST);
|
||||||
|
responseEntity.getBody().getTransformers().forEach(transformer -> {
|
||||||
|
assertNotNull(transformer.getCoreVersion(), transformer.getTransformerName() +
|
||||||
|
" should have had a coreValue but was null. Should have been " + coreVersion);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -34,6 +34,7 @@ import org.alfresco.transform.client.registry.TransformCache;
|
|||||||
import org.alfresco.transformer.executors.Transformer;
|
import org.alfresco.transformer.executors.Transformer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -43,6 +44,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setCoreVersionOnSingleStepTransformers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AIOTransformRegistry manages all of the sub transformers registered to it and provides aggregated TransformConfig.
|
* AIOTransformRegistry manages all of the sub transformers registered to it and provides aggregated TransformConfig.
|
||||||
@ -53,6 +55,8 @@ public class AIOTransformRegistry extends AbstractTransformRegistry
|
|||||||
|
|
||||||
private static final String ENGINE_CONFIG_LOCATION_POSTFIX = "_engine_config.json";
|
private static final String ENGINE_CONFIG_LOCATION_POSTFIX = "_engine_config.json";
|
||||||
|
|
||||||
|
private String coreVersion;
|
||||||
|
|
||||||
private CombinedTransformConfig combinedTransformConfig = new CombinedTransformConfig();
|
private CombinedTransformConfig combinedTransformConfig = new CombinedTransformConfig();
|
||||||
|
|
||||||
// Holds the structures used by AbstractTransformRegistry to look up what is supported.
|
// Holds the structures used by AbstractTransformRegistry to look up what is supported.
|
||||||
@ -64,20 +68,26 @@ public class AIOTransformRegistry extends AbstractTransformRegistry
|
|||||||
// Represents the mapping between a transform and a transformer, multiple mappings can point to the same transformer.
|
// Represents the mapping between a transform and a transformer, multiple mappings can point to the same transformer.
|
||||||
private Map<String, Transformer> transformerEngineMapping = new HashMap();
|
private Map<String, Transformer> transformerEngineMapping = new HashMap();
|
||||||
|
|
||||||
|
public void setCoreVersion(String coreVersion)
|
||||||
|
{
|
||||||
|
this.coreVersion = coreVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a transformer's (T-Engine) config to the configuration and creates a map of transforms to the T-Engine.
|
* Adds a transformer's (T-Engine) config to the configuration and creates a map of transforms to the T-Engine.
|
||||||
* The name of this method is now misleading as the registry of transforms takes place in
|
* The name of this method is now misleading as the registry of transforms takes place in
|
||||||
* {@link #registerCombinedTransformers()} .
|
* {@link #registerCombinedTransformers()} .
|
||||||
* @param transformer The transformer implementation, this could be a single transformer
|
* @param tEngine The transformer implementation, this could be a single transformer
|
||||||
* or a transformer managing multiple sub transformers. The transformer's configuration file will
|
* or a transformer managing multiple sub transformers. The transformer's configuration file will
|
||||||
* be read based on the {@link Transformer#getTransformerId()} value.
|
* be read based on the {@link Transformer#getTransformerId()} value.
|
||||||
*/
|
*/
|
||||||
public void registerTransformer(final Transformer transformer) throws Exception
|
public void registerTransformer(final Transformer tEngine) throws Exception
|
||||||
{
|
{
|
||||||
// Load config for the transformer
|
// Load config for the transformer
|
||||||
String location = getTransformConfigLocation(transformer);
|
String location = getTransformConfigLocation(tEngine);
|
||||||
TransformConfig transformConfig = loadTransformConfig(location);
|
TransformConfig transformConfig = loadTransformConfig(location);
|
||||||
String transformerId = transformer.getTransformerId();
|
setCoreVersionOnSingleStepTransformers(transformConfig.getTransformers(), coreVersion);
|
||||||
|
String transformerId = tEngine.getTransformerId();
|
||||||
combinedTransformConfig.addTransformConfig(transformConfig, location, transformerId, this);
|
combinedTransformConfig.addTransformConfig(transformConfig, location, transformerId, this);
|
||||||
|
|
||||||
// Map all of the transforms defined in the config to this Transformer implementation
|
// Map all of the transforms defined in the config to this Transformer implementation
|
||||||
@ -90,7 +100,7 @@ public class AIOTransformRegistry extends AbstractTransformRegistry
|
|||||||
{
|
{
|
||||||
log.debug("Overriding transform with name: '{}' originally defined in '{}'.", transformerName, originalTEngine.getTransformerId());
|
log.debug("Overriding transform with name: '{}' originally defined in '{}'.", transformerName, originalTEngine.getTransformerId());
|
||||||
}
|
}
|
||||||
transformerEngineMapping.put(transformerName, transformer);
|
transformerEngineMapping.put(transformerName, tEngine);
|
||||||
log.debug("Registered transform with name: '{}' defined in '{}'.", transformerName, transformerId);
|
log.debug("Registered transform with name: '{}' defined in '{}'.", transformerName, transformerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.alfresco.transformer.util.MimetypeMap.PREFIX_IMAGE;
|
import static org.alfresco.transformer.util.MimetypeMap.PREFIX_IMAGE;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -227,7 +228,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
expectedOptions = "-auto-orient " + "-gravity " + value + " +repage";
|
expectedOptions = "-auto-orient " + "-gravity " + value + " +repage";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -244,7 +245,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
{
|
{
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -260,7 +261,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
expectedSourceSuffix = "[2-3]";
|
expectedSourceSuffix = "[2-3]";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -298,7 +299,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
expectedSourceSuffix = "[2-3]";
|
expectedSourceSuffix = "[2-3]";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -336,7 +337,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
expectedOptions = "( horrible command / ); -auto-orient -resize 321x654";
|
expectedOptions = "( horrible command / ); -auto-orient -resize 321x654";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -365,7 +366,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
{
|
{
|
||||||
when(mockExecutionResult.getExitValue()).thenReturn(1);
|
when(mockExecutionResult.getExitValue()).thenReturn(1);
|
||||||
|
|
||||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", "xxx"))
|
mockMvc.perform(mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", "xxx"))
|
||||||
.andExpect(status().is(BAD_REQUEST.value()))
|
.andExpect(status().is(BAD_REQUEST.value()))
|
||||||
.andExpect(
|
.andExpect(
|
||||||
status().reason(containsString("Transformer exit code was not 0: \nSTDERR")));
|
status().reason(containsString("Transformer exit code was not 0: \nSTDERR")));
|
||||||
@ -399,7 +400,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
|||||||
String tr = objectMapper.writeValueAsString(transformRequest);
|
String tr = objectMapper.writeValueAsString(transformRequest);
|
||||||
String transformationReplyAsString = mockMvc
|
String transformationReplyAsString = mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/transform")
|
.post(ENDPOINT_TRANSFORM)
|
||||||
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
||||||
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||||
.content(tr))
|
.content(tr))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_MIMETYPE;
|
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_MIMETYPE;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_EXTENSION;
|
import static org.alfresco.transformer.util.RequestParamMap.TARGET_EXTENSION;
|
||||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_MIMETYPE;
|
import static org.alfresco.transformer.util.RequestParamMap.TARGET_MIMETYPE;
|
||||||
@ -200,7 +201,7 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
|||||||
|
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param(TARGET_EXTENSION, "xxx")
|
.param(TARGET_EXTENSION, "xxx")
|
||||||
.param(SOURCE_MIMETYPE,sourceMimetype)
|
.param(SOURCE_MIMETYPE,sourceMimetype)
|
||||||
@ -247,7 +248,7 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
|||||||
String tr = objectMapper.writeValueAsString(transformRequest);
|
String tr = objectMapper.writeValueAsString(transformRequest);
|
||||||
String transformationReplyAsString = mockMvc
|
String transformationReplyAsString = mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/transform")
|
.post(ENDPOINT_TRANSFORM)
|
||||||
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
||||||
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||||
.content(tr))
|
.content(tr))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -35,6 +35,7 @@ import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_WORD
|
|||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
|
||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_RFC822;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_RFC822;
|
||||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
|
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@ -490,7 +491,7 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
|
|||||||
"test_file." + sourceExtension, sourceMimetype, content);
|
"test_file." + sourceExtension, sourceMimetype, content);
|
||||||
|
|
||||||
final MockHttpServletRequestBuilder requestBuilder = super
|
final MockHttpServletRequestBuilder requestBuilder = super
|
||||||
.mockMvcRequest("/transform", sourceFile)
|
.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
.param("sourceMimetype", sourceMimetype);
|
.param("sourceMimetype", sourceMimetype);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
@ -221,7 +222,7 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
|||||||
expectedOptions = "--width=321 --height=654 --allow-enlargement --maintain-aspect-ratio --page=2";
|
expectedOptions = "--width=321 --height=654 --allow-enlargement --maintain-aspect-ratio --page=2";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -245,7 +246,7 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
|||||||
expectedOptions = "--width=321 --height=654 --page=2";
|
expectedOptions = "--width=321 --height=654 --page=2";
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.multipart("/transform")
|
.multipart(ENDPOINT_TRANSFORM)
|
||||||
.file(sourceFile)
|
.file(sourceFile)
|
||||||
.param("targetExtension", targetExtension)
|
.param("targetExtension", targetExtension)
|
||||||
.param("targetMimetype", targetMimetype)
|
.param("targetMimetype", targetMimetype)
|
||||||
@ -277,7 +278,7 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
|||||||
{
|
{
|
||||||
when(mockExecutionResult.getExitValue()).thenReturn(1);
|
when(mockExecutionResult.getExitValue()).thenReturn(1);
|
||||||
|
|
||||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", "xxx"))
|
mockMvc.perform(mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", "xxx"))
|
||||||
.andExpect(status().is(BAD_REQUEST.value()))
|
.andExpect(status().is(BAD_REQUEST.value()))
|
||||||
.andExpect(status()
|
.andExpect(status()
|
||||||
.reason(containsString("Transformer exit code was not 0: \nSTDERR")));
|
.reason(containsString("Transformer exit code was not 0: \nSTDERR")));
|
||||||
@ -311,7 +312,7 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
|||||||
String tr = objectMapper.writeValueAsString(transformRequest);
|
String tr = objectMapper.writeValueAsString(transformRequest);
|
||||||
String transformationReplyAsString = mockMvc
|
String transformationReplyAsString = mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/transform")
|
.post(ENDPOINT_TRANSFORM)
|
||||||
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
||||||
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||||
.content(tr))
|
.content(tr))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
import static java.nio.file.Files.readAllBytes;
|
import static java.nio.file.Files.readAllBytes;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.alfresco.transformer.executors.Tika.ARCHIVE;
|
import static org.alfresco.transformer.executors.Tika.ARCHIVE;
|
||||||
import static org.alfresco.transformer.executors.Tika.CSV;
|
import static org.alfresco.transformer.executors.Tika.CSV;
|
||||||
import static org.alfresco.transformer.executors.Tika.DOC;
|
import static org.alfresco.transformer.executors.Tika.DOC;
|
||||||
@ -249,9 +250,9 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
|
|||||||
|
|
||||||
System.out.println("Test " + transform + " " + sourceExtension + " to " + targetExtension);
|
System.out.println("Test " + transform + " " + sourceExtension + " to " + targetExtension);
|
||||||
MockHttpServletRequestBuilder requestBuilder = includeContents == null
|
MockHttpServletRequestBuilder requestBuilder = includeContents == null
|
||||||
? mockMvcRequest("/transform", sourceFile,
|
? mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
|
||||||
"targetExtension", this.targetExtension)
|
"targetExtension", this.targetExtension)
|
||||||
: mockMvcRequest("/transform", sourceFile,
|
: mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
|
||||||
"targetExtension", this.targetExtension, INCLUDE_CONTENTS, includeContents.toString());
|
"targetExtension", this.targetExtension, INCLUDE_CONTENTS, includeContents.toString());
|
||||||
MvcResult result = mockMvc.perform(requestBuilder)
|
MvcResult result = mockMvc.perform(requestBuilder)
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
@ -368,7 +369,7 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
|
|||||||
mockTransformCommand(PDF, TXT, MIMETYPE_PDF, true);
|
mockTransformCommand(PDF, TXT, MIMETYPE_PDF, true);
|
||||||
targetEncoding = "rubbish";
|
targetEncoding = "rubbish";
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(INTERNAL_SERVER_ERROR.value()));
|
.andExpect(status().is(INTERNAL_SERVER_ERROR.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +554,7 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
|
|||||||
"\"{http://www.alfresco.org/model/content/1.0}created\":\"created1\"}";
|
"\"{http://www.alfresco.org/model/content/1.0}created\":\"created1\"}";
|
||||||
|
|
||||||
MockHttpServletRequestBuilder requestBuilder =
|
MockHttpServletRequestBuilder requestBuilder =
|
||||||
super.mockMvcRequest("/transform", sourceFile,
|
super.mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile,
|
||||||
"targetExtension", XSLX,
|
"targetExtension", XSLX,
|
||||||
"metadata", metadata,
|
"metadata", metadata,
|
||||||
"targetMimetype", MIMETYPE_METADATA_EMBED,
|
"targetMimetype", MIMETYPE_METADATA_EMBED,
|
||||||
@ -583,7 +584,7 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
|
|||||||
{
|
{
|
||||||
mockTransformCommand(PDF, TXT, MIMETYPE_PDF, true);
|
mockTransformCommand(PDF, TXT, MIMETYPE_PDF, true);
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension).param(
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension).param(
|
||||||
NOT_EXTRACT_BOOKMARKS_TEXT, "true"))
|
NOT_EXTRACT_BOOKMARKS_TEXT, "true"))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string("Content-Disposition",
|
.andExpect(header().string("Content-Disposition",
|
||||||
@ -628,7 +629,7 @@ public class TikaControllerTest extends AbstractTransformerControllerTest
|
|||||||
String tr = objectMapper.writeValueAsString(transformRequest);
|
String tr = objectMapper.writeValueAsString(transformRequest);
|
||||||
String transformationReplyAsString = mockMvc
|
String transformationReplyAsString = mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/transform")
|
.post(ENDPOINT_TRANSFORM)
|
||||||
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
||||||
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||||
.content(tr))
|
.content(tr))
|
||||||
|
@ -64,7 +64,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
|
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
|
||||||
import static org.alfresco.transform.client.util.RequestParamMap.INCLUDE_CORE_VERSION;
|
import static org.alfresco.transform.client.util.RequestParamMap.CONFIG_VERSION;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.CONFIG_VERSION_DEFAULT;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM_CONFIG;
|
||||||
import static org.alfresco.transformer.fs.FileManager.TempFileProvider.createTempFile;
|
import static org.alfresco.transformer.fs.FileManager.TempFileProvider.createTempFile;
|
||||||
import static org.alfresco.transformer.fs.FileManager.buildFile;
|
import static org.alfresco.transformer.fs.FileManager.buildFile;
|
||||||
import static org.alfresco.transformer.fs.FileManager.createAttachment;
|
import static org.alfresco.transformer.fs.FileManager.createAttachment;
|
||||||
@ -141,17 +144,17 @@ public abstract class AbstractTransformerController implements TransformControll
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TransformerDebug transformerDebug;
|
private TransformerDebug transformerDebug;
|
||||||
|
|
||||||
@GetMapping(value = "/transform/config")
|
@GetMapping(value = ENDPOINT_TRANSFORM_CONFIG)
|
||||||
public ResponseEntity<TransformConfig> info(
|
public ResponseEntity<TransformConfig> info(
|
||||||
@RequestParam(value = INCLUDE_CORE_VERSION, required = false) Boolean includeCoreVersion)
|
@RequestParam(value = CONFIG_VERSION, defaultValue = CONFIG_VERSION_DEFAULT) int configVersion)
|
||||||
{
|
{
|
||||||
logger.info("GET Transform Config" + (includeCoreVersion != null && includeCoreVersion ? " including coreVersion" : ""));
|
logger.info("GET Transform Config version: " + configVersion);
|
||||||
TransformConfig transformConfig = ((TransformRegistryImpl) transformRegistry).getTransformConfig();
|
TransformConfig transformConfig = ((TransformRegistryImpl) transformRegistry).getTransformConfig();
|
||||||
transformConfig = setOrClearCoreVersion(transformConfig, includeCoreVersion);
|
transformConfig = setOrClearCoreVersion(transformConfig, configVersion);
|
||||||
return new ResponseEntity<>(transformConfig, OK);
|
return new ResponseEntity<>(transformConfig, OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/transform", consumes = MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = ENDPOINT_TRANSFORM, consumes = MULTIPART_FORM_DATA_VALUE)
|
||||||
public ResponseEntity<Resource> transform(HttpServletRequest request,
|
public ResponseEntity<Resource> transform(HttpServletRequest request,
|
||||||
@RequestParam(FILE) MultipartFile sourceMultipartFile,
|
@RequestParam(FILE) MultipartFile sourceMultipartFile,
|
||||||
@RequestParam(TARGET_EXTENSION) String targetExtension,
|
@RequestParam(TARGET_EXTENSION) String targetExtension,
|
||||||
@ -206,7 +209,7 @@ public abstract class AbstractTransformerController implements TransformControll
|
|||||||
* @param timeout Transformation timeout
|
* @param timeout Transformation timeout
|
||||||
* @return A transformation reply
|
* @return A transformation reply
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/transform", produces = APPLICATION_JSON_VALUE)
|
@PostMapping(value = ENDPOINT_TRANSFORM, produces = APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<TransformReply> transform(@RequestBody TransformRequest request,
|
public ResponseEntity<TransformReply> transform(@RequestBody TransformRequest request,
|
||||||
@RequestParam(value = "timeout", required = false) Long timeout)
|
@RequestParam(value = "timeout", required = false) Long timeout)
|
||||||
|
@ -38,6 +38,8 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebApplicationConfig implements WebMvcConfigurer
|
public class WebApplicationConfig implements WebMvcConfigurer
|
||||||
{
|
{
|
||||||
@ -46,7 +48,7 @@ public class WebApplicationConfig implements WebMvcConfigurer
|
|||||||
{
|
{
|
||||||
registry
|
registry
|
||||||
.addInterceptor(transformInterceptor())
|
.addInterceptor(transformInterceptor())
|
||||||
.addPathPatterns("/transform", "/live", "/ready");
|
.addPathPatterns(ENDPOINT_TRANSFORM, "/live", "/ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.springframework.http.HttpMethod.POST;
|
import static org.springframework.http.HttpMethod.POST;
|
||||||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
|
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
|
||||||
@ -125,7 +126,7 @@ public abstract class AbstractHttpRequestTest
|
|||||||
protected void sendTranformationRequest(
|
protected void sendTranformationRequest(
|
||||||
final HttpEntity<LinkedMultiValueMap<String, Object>> entity, final String errorMessage)
|
final HttpEntity<LinkedMultiValueMap<String, Object>> entity, final String errorMessage)
|
||||||
{
|
{
|
||||||
final ResponseEntity<String> response = restTemplate.exchange("/transform", POST, entity,
|
final ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_TRANSFORM, POST, entity,
|
||||||
String.class, "");
|
String.class, "");
|
||||||
assertEquals(errorMessage, getErrorMessage(response.getBody()));
|
assertEquals(errorMessage, getErrorMessage(response.getBody()));
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM_CONFIG_LATEST;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM_CONFIG;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
@ -105,7 +108,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
protected TransformServiceRegistry transformRegistry;
|
protected TransformServiceRegistry transformRegistry;
|
||||||
|
|
||||||
@Value("${transform.core.version}")
|
@Value("${transform.core.version}")
|
||||||
private String currentCoreVersion;
|
private String coreVersion;
|
||||||
|
|
||||||
protected String sourceExtension;
|
protected String sourceExtension;
|
||||||
protected String targetExtension;
|
protected String targetExtension;
|
||||||
@ -213,7 +216,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
|
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
|
||||||
String... params)
|
String... params)
|
||||||
{
|
{
|
||||||
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart("/transform").file(
|
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.multipart(ENDPOINT_TRANSFORM).file(
|
||||||
sourceFile);
|
sourceFile);
|
||||||
|
|
||||||
if (params.length % 2 != 0)
|
if (params.length % 2 != 0)
|
||||||
@ -256,7 +259,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
public void simpleTransformTest() throws Exception
|
public void simpleTransformTest() throws Exception
|
||||||
{
|
{
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||||
.andExpect(header().string("Content-Disposition",
|
.andExpect(header().string("Content-Disposition",
|
||||||
@ -267,7 +270,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
public void testDelayTest() throws Exception
|
public void testDelayTest() throws Exception
|
||||||
{
|
{
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension,
|
mockMvc.perform(mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension,
|
||||||
"testDelay", "400"))
|
"testDelay", "400"))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||||
@ -282,7 +285,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void noTargetFileTest() throws Exception
|
public void noTargetFileTest() throws Exception
|
||||||
{
|
{
|
||||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", "xxx"))
|
mockMvc.perform(mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", "xxx"))
|
||||||
.andExpect(status().is(INTERNAL_SERVER_ERROR.value()));
|
.andExpect(status().is(INTERNAL_SERVER_ERROR.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +297,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
expectedSourceFileBytes);
|
expectedSourceFileBytes);
|
||||||
|
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||||
.andExpect(header().string("Content-Disposition",
|
.andExpect(header().string("Content-Disposition",
|
||||||
@ -309,7 +312,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
expectedSourceFileBytes);
|
expectedSourceFileBytes);
|
||||||
|
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||||
.andExpect(header().string("Content-Disposition",
|
.andExpect(header().string("Content-Disposition",
|
||||||
@ -323,7 +326,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
sourceFile = new MockMultipartFile("file", "abc/", sourceMimetype, expectedSourceFileBytes);
|
sourceFile = new MockMultipartFile("file", "abc/", sourceMimetype, expectedSourceFileBytes);
|
||||||
|
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(BAD_REQUEST.value()))
|
.andExpect(status().is(BAD_REQUEST.value()))
|
||||||
.andExpect(status().reason(containsString("The source filename was not supplied")));
|
.andExpect(status().reason(containsString("The source filename was not supplied")));
|
||||||
}
|
}
|
||||||
@ -334,14 +337,14 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
sourceFile = new MockMultipartFile("file", "", sourceMimetype, expectedSourceFileBytes);
|
sourceFile = new MockMultipartFile("file", "", sourceMimetype, expectedSourceFileBytes);
|
||||||
|
|
||||||
mockMvc.perform(
|
mockMvc.perform(
|
||||||
mockMvcRequest("/transform", sourceFile, "targetExtension", targetExtension))
|
mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile, "targetExtension", targetExtension))
|
||||||
.andExpect(status().is(BAD_REQUEST.value()));
|
.andExpect(status().is(BAD_REQUEST.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noTargetExtensionTest() throws Exception
|
public void noTargetExtensionTest() throws Exception
|
||||||
{
|
{
|
||||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile))
|
mockMvc.perform(mockMvcRequest(ENDPOINT_TRANSFORM, sourceFile))
|
||||||
.andExpect(status().is(BAD_REQUEST.value()))
|
.andExpect(status().is(BAD_REQUEST.value()))
|
||||||
.andExpect(status().reason(
|
.andExpect(status().reason(
|
||||||
containsString("Request parameter 'targetExtension' is missing")));
|
containsString("Request parameter 'targetExtension' is missing")));
|
||||||
@ -386,7 +389,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
String tr = objectMapper.writeValueAsString(transformRequest);
|
String tr = objectMapper.writeValueAsString(transformRequest);
|
||||||
String transformationReplyAsString = mockMvc
|
String transformationReplyAsString = mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/transform")
|
.post(ENDPOINT_TRANSFORM)
|
||||||
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
.header(ACCEPT, APPLICATION_JSON_VALUE)
|
||||||
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||||
.content(tr))
|
.content(tr))
|
||||||
@ -415,13 +418,13 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
TransformConfig expectedTransformConfig = objectMapper
|
TransformConfig expectedTransformConfig = objectMapper
|
||||||
.readValue(getTestFile(getEngineConfigName(), true),
|
.readValue(getTestFile(getEngineConfigName(), true),
|
||||||
TransformConfig.class);
|
TransformConfig.class);
|
||||||
expectedTransformConfig.getTransformers().forEach(transformer -> transformer.setCoreVersion(currentCoreVersion));
|
expectedTransformConfig.getTransformers().forEach(transformer -> transformer.setCoreVersion(coreVersion));
|
||||||
|
|
||||||
ReflectionTestUtils.setField(transformRegistry, "engineConfig",
|
ReflectionTestUtils.setField(transformRegistry, "engineConfig",
|
||||||
new ClassPathResource(getEngineConfigName()));
|
new ClassPathResource(getEngineConfigName()));
|
||||||
|
|
||||||
String response = mockMvc
|
String response = mockMvc
|
||||||
.perform(MockMvcRequestBuilders.get("/transform/config?includeCoreVersion=true"))
|
.perform(MockMvcRequestBuilders.get(ENDPOINT_TRANSFORM_CONFIG_LATEST))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -442,7 +445,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
new ClassPathResource(getEngineConfigName()));
|
new ClassPathResource(getEngineConfigName()));
|
||||||
|
|
||||||
String response = mockMvc
|
String response = mockMvc
|
||||||
.perform(MockMvcRequestBuilders.get("/transform/config"))
|
.perform(MockMvcRequestBuilders.get(ENDPOINT_TRANSFORM_CONFIG))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -460,7 +463,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
new ClassPathResource("engine_config_with_duplicates.json"));
|
new ClassPathResource("engine_config_with_duplicates.json"));
|
||||||
|
|
||||||
String response = mockMvc
|
String response = mockMvc
|
||||||
.perform(MockMvcRequestBuilders.get("/transform/config"))
|
.perform(MockMvcRequestBuilders.get(ENDPOINT_TRANSFORM_CONFIG))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -487,7 +490,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
new ClassPathResource("engine_config_incomplete.json"));
|
new ClassPathResource("engine_config_incomplete.json"));
|
||||||
|
|
||||||
String response = mockMvc
|
String response = mockMvc
|
||||||
.perform(MockMvcRequestBuilders.get("/transform/config"))
|
.perform(MockMvcRequestBuilders.get(ENDPOINT_TRANSFORM_CONFIG))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -510,7 +513,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
new ClassPathResource("engine_config_no_transform_options.json"));
|
new ClassPathResource("engine_config_no_transform_options.json"));
|
||||||
|
|
||||||
String response = mockMvc
|
String response = mockMvc
|
||||||
.perform(MockMvcRequestBuilders.get("/transform/config"))
|
.perform(MockMvcRequestBuilders.get(ENDPOINT_TRANSFORM_CONFIG))
|
||||||
.andExpect(status().is(OK.value()))
|
.andExpect(status().is(OK.value()))
|
||||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2019 Alfresco Software, Ltd. All rights reserved.
|
* Copyright 2015-2022 Alfresco Software, Ltd. All rights reserved.
|
||||||
*
|
*
|
||||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||||
* pursuant to a written agreement and any use of this program without such an
|
* pursuant to a written agreement and any use of this program without such an
|
||||||
@ -8,6 +8,7 @@
|
|||||||
package org.alfresco.transformer;
|
package org.alfresco.transformer;
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
|
import static org.alfresco.transform.client.util.RequestParamMap.ENDPOINT_TRANSFORM;
|
||||||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
|
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -63,6 +64,6 @@ public class EngineClient
|
|||||||
|
|
||||||
final HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
|
final HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
|
||||||
|
|
||||||
return REST_TEMPLATE.postForEntity(engineUrl + "/transform", entity, Resource.class);
|
return REST_TEMPLATE.postForEntity(engineUrl + ENDPOINT_TRANSFORM, entity, Resource.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@ -21,7 +21,7 @@
|
|||||||
<dependency.pdfbox.version>2.0.25</dependency.pdfbox.version>
|
<dependency.pdfbox.version>2.0.25</dependency.pdfbox.version>
|
||||||
<dependency.alfresco-jodconverter-core.version>3.0.1.12</dependency.alfresco-jodconverter-core.version>
|
<dependency.alfresco-jodconverter-core.version>3.0.1.12</dependency.alfresco-jodconverter-core.version>
|
||||||
<env.project_version>${project.version}</env.project_version>
|
<env.project_version>${project.version}</env.project_version>
|
||||||
<dependency.alfresco-transform-model.version>1.4.9</dependency.alfresco-transform-model.version>
|
<dependency.alfresco-transform-model.version>1.4.10</dependency.alfresco-transform-model.version>
|
||||||
<dependency.activemq.version>5.16.3</dependency.activemq.version>
|
<dependency.activemq.version>5.16.3</dependency.activemq.version>
|
||||||
<dependency.jackson.version>2.13.1</dependency.jackson.version>
|
<dependency.jackson.version>2.13.1</dependency.jackson.version>
|
||||||
<dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version>
|
<dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user