mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
ACS-2498 Add coreVersion to T-Engine config (#526)
The bulk of the changes in this PR are to do with adding a coreVersion element to the transform element in the T-Engine config. For more detail see the class header of CoreVersionDecorator. * Support the use of coreVersion so that it is possible to upgrade pods in any order * Moved the majority of the RequestParamMap static finals to alfresco-transform-model and added a new one: "includeCoreVersion" parameter.
This commit is contained in:
@@ -63,6 +63,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
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.transformer.fs.FileManager.TempFileProvider.createTempFile;
|
||||
import static org.alfresco.transformer.fs.FileManager.buildFile;
|
||||
import static org.alfresco.transformer.fs.FileManager.createAttachment;
|
||||
@@ -140,11 +142,12 @@ public abstract class AbstractTransformerController implements TransformControll
|
||||
private TransformerDebug transformerDebug;
|
||||
|
||||
@GetMapping(value = "/transform/config")
|
||||
public ResponseEntity<TransformConfig> info()
|
||||
public ResponseEntity<TransformConfig> info(
|
||||
@RequestParam(value = INCLUDE_CORE_VERSION, required = false) Boolean includeCoreVersion)
|
||||
{
|
||||
logger.info("GET Transform Config.");
|
||||
final TransformConfig transformConfig =
|
||||
((TransformRegistryImpl) transformRegistry).getTransformConfig();
|
||||
logger.info("GET Transform Config" + (includeCoreVersion != null && includeCoreVersion ? " including coreVersion" : ""));
|
||||
TransformConfig transformConfig = ((TransformRegistryImpl) transformRegistry).getTransformConfig();
|
||||
transformConfig = setOrClearCoreVersion(transformConfig, includeCoreVersion);
|
||||
return new ResponseEntity<>(transformConfig, OK);
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.transformer;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setCoreVersionOnSingleStepTransformers;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -61,6 +62,9 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
|
||||
@Value("${transform.core.config.location:classpath:engine_config.json}")
|
||||
private String locationFromProperty;
|
||||
|
||||
@Value("${transform.core.version}")
|
||||
private String coreVersion;
|
||||
|
||||
private Resource engineConfig;
|
||||
|
||||
@PostConstruct
|
||||
@@ -82,7 +86,9 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
|
||||
{
|
||||
try (Reader reader = new InputStreamReader(engineConfig.getInputStream(), UTF_8))
|
||||
{
|
||||
return jsonObjectMapper.readValue(reader, TransformConfig.class);
|
||||
TransformConfig transformConfig = jsonObjectMapper.readValue(reader, TransformConfig.class);
|
||||
setCoreVersionOnSingleStepTransformers(transformConfig.getTransformers(), coreVersion);
|
||||
return transformConfig;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
@@ -26,7 +26,11 @@
|
||||
*/
|
||||
package org.alfresco.transformer.util;
|
||||
|
||||
public interface RequestParamMap
|
||||
/**
|
||||
* Extends the list of transform options with historic request parameters or 'extra' parameters used in testing
|
||||
* or communication in the all-in-one transformer.
|
||||
*/
|
||||
public interface RequestParamMap extends org.alfresco.transform.client.util.RequestParamMap
|
||||
{
|
||||
// This property can be sent by acs repository's legacy transformers to force a transform,
|
||||
// instead of letting this T-Engine determine it based on the request parameters.
|
||||
@@ -35,41 +39,12 @@ public interface RequestParamMap
|
||||
// See ATS-731.
|
||||
@Deprecated
|
||||
String TRANSFORM_NAME_PROPERTY = "transformName";
|
||||
|
||||
String TRANSFORM_NAME_PARAMETER = "alfresco.transform-name-parameter";
|
||||
String FILE = "file";
|
||||
|
||||
String SOURCE_ENCODING = "sourceEncoding";
|
||||
String FILE = "file";
|
||||
String SOURCE_EXTENSION = "sourceExtension";
|
||||
String SOURCE_MIMETYPE = "sourceMimetype";
|
||||
String TARGET_EXTENSION = "targetExtension";
|
||||
String TARGET_MIMETYPE = "targetMimetype";
|
||||
String TARGET_ENCODING = "targetEncoding";
|
||||
String TEST_DELAY = "testDelay";
|
||||
String PAGE_REQUEST_PARAM = "page";
|
||||
String WIDTH_REQUEST_PARAM = "width";
|
||||
String HEIGHT_REQUEST_PARAM = "height";
|
||||
String ALLOW_PDF_ENLARGEMENT = "allowPdfEnlargement";
|
||||
String MAINTAIN_PDF_ASPECT_RATIO = "maintainPdfAspectRatio";
|
||||
String START_PAGE = "startPage";
|
||||
String END_PAGE = "endPage";
|
||||
String ALPHA_REMOVE = "alphaRemove";
|
||||
String AUTO_ORIENT = "autoOrient";
|
||||
String CROP_GRAVITY = "cropGravity";
|
||||
String CROP_WIDTH = "cropWidth";
|
||||
String CROP_HEIGHT = "cropHeight";
|
||||
String CROP_PERCENTAGE = "cropPercentage";
|
||||
String CROP_X_OFFSET = "cropXOffset";
|
||||
String CROP_Y_OFFSET = "cropYOffset";
|
||||
String THUMBNAIL = "thumbnail";
|
||||
String RESIZE_WIDTH = "resizeWidth";
|
||||
String RESIZE_HEIGHT = "resizeHeight";
|
||||
String RESIZE_PERCENTAGE = "resizePercentage";
|
||||
String ALLOW_ENLARGEMENT = "allowEnlargement";
|
||||
String MAINTAIN_ASPECT_RATIO = "maintainAspectRatio";
|
||||
String COMMAND_OPTIONS = "commandOptions";
|
||||
String TIMEOUT = "timeout";
|
||||
String INCLUDE_CONTENTS = "includeContents";
|
||||
String NOT_EXTRACT_BOOKMARKS_TEXT = "notExtractBookmarksText";
|
||||
String PAGE_LIMIT = "pageLimit";
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ import org.alfresco.transformer.probes.ProbeTestTransform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -103,6 +104,9 @@ public abstract class AbstractTransformerControllerTest
|
||||
@SpyBean
|
||||
protected TransformServiceRegistry transformRegistry;
|
||||
|
||||
@Value("${transform.core.version}")
|
||||
private String currentCoreVersion;
|
||||
|
||||
protected String sourceExtension;
|
||||
protected String targetExtension;
|
||||
protected String sourceMimetype;
|
||||
@@ -196,7 +200,7 @@ public abstract class AbstractTransformerControllerTest
|
||||
" does not exist in the resources directory");
|
||||
}
|
||||
// added as part of ATS-702 to allow test resources to be read from the imported jar files to prevent test resource duplication
|
||||
if(testFileUrl!=null)
|
||||
if (testFileUrl!=null)
|
||||
{
|
||||
// Each use of the tempDir should result in a unique directory being used
|
||||
testFile = new File(tempDir, testFilename);
|
||||
@@ -407,6 +411,28 @@ public abstract class AbstractTransformerControllerTest
|
||||
|
||||
@Test
|
||||
public void testGetTransformConfigInfo() throws Exception
|
||||
{
|
||||
TransformConfig expectedTransformConfig = objectMapper
|
||||
.readValue(getTestFile(getEngineConfigName(), true),
|
||||
TransformConfig.class);
|
||||
expectedTransformConfig.getTransformers().forEach(transformer -> transformer.setCoreVersion(currentCoreVersion));
|
||||
|
||||
ReflectionTestUtils.setField(transformRegistry, "engineConfig",
|
||||
new ClassPathResource(getEngineConfigName()));
|
||||
|
||||
String response = mockMvc
|
||||
.perform(MockMvcRequestBuilders.get("/transform/config?includeCoreVersion=true"))
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
|
||||
TransformConfig transformConfig = objectMapper.readValue(response, TransformConfig.class);
|
||||
assertEquals(expectedTransformConfig, transformConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Test for case when T-Router or Repository is a version that does not expect it
|
||||
public void testGetTransformConfigInfoExcludingCoreVersion() throws Exception
|
||||
{
|
||||
TransformConfig expectedTransformConfig = objectMapper
|
||||
.readValue(getTestFile(getEngineConfigName(), true),
|
||||
|
Reference in New Issue
Block a user