mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
ATS-675:Add All-In-One transformer (#200)
* ATS-695/ATS-675 Add aio boot project
- Added the bare bones of a spring boot project to be used by aio. Currently based loosely on transform-misc.
* ATS-674/ATS-695 Add forms for each transformer.
* ATS-675/ATS-695 add empty test to pass build during dev
* ATS-695 remove maven profile to fix build
* ATS-675 Define interface and the aio transformer
* Fix formatting and rename the module as per review comments
* ATS-675/ATS-695 Add ProbeTestTransformation
Currenly uses MiscController implementation.
* ATS-675/ATS-695 Add logger method,
This will be code repeated in the local transform method and the processTransform method
* ATS-675/ATS-695 Implement local transform method
Minimum implementation for transform method.
* ATS-675/ATS-695 Implement processTransform
* ATS-675/ATS-695 Rename project to alfresco-transform-core-aio-boot
Add alfresco-transform-core-aio dependencies
* ATS-675/ATS-695 Fix build
Update project location
Update imports and variable declarations in TODOs
Add error handling.
Formatting.
* ATS-693: Update transform-misc Dockerfile with newly reserved uid
* Revert "ATS-691: Combine the win/linux pathToFile logic"
This reverts commit 61fe4820
* ATS-693: Update transform-misc Dockerfile with newly reserved uid
* "ATS-693: Add Dockerfile to aio-boot module"
* ATS-675/ATS-695 Add resource required for ProbeTestTrasform
* ATS-675/ATS-695 Remove test resources, to be added in test implementation
* ATS-693: Fix path to jar resources
* ATS-675/ATS-703 Moved Options builder to non boot jar.
* ATS-675/ATS-703 Rename OptionsBuilder to PdfRendererOptionsBuilder
This is to avoid confilct with OptionsBuilders in other T-engines.
* ATS-675/ATS-695 Added PdfRendererApadpter.java
Added dependency to pom.xml
Required transformation of String to Long, method added to Util.java
* ATS-675/ ATS-704
Implemented LibreOfficeAdapter
* ATS-675 Parity with base aio naming convention
* ATS-675/ATS-705 Implemented ImageMagickAdapter
Moved and renamed OptionsBuilder. Moved to alfresco-transform-imagemagick, renamed ImageMagickOptionsBuilder.
Added dependencies to pom.xml
* ATS-693: Implement maven docker build
* Initial tests
* Add initial tests for config aggregation
* Update AbstractTransformerControllerTest to use the new engine config names
* Fix up controller
* Fix travis tests (#205)
* Fix engine specific properties for engine config location
* Temporarily add engine configs to test resources for the boot modules. Will need to fix this properly
* Resolve some review comments
* ATS-675 - Move static strings to util class
* Refactor classes for simpler design (#210)
* ATS-702 Fix error handling
(cherry picked from commit e30cb5fda6
)
* ATS-675 Rename test class (fixes typo)
* ATS-675: Add aio transformer to static scan
This commit is contained in:
@@ -115,6 +115,7 @@ public abstract class AbstractTransformerController implements TransformControll
|
||||
@GetMapping(value = "/transform/config")
|
||||
public ResponseEntity<TransformConfig> info()
|
||||
{
|
||||
// TODO - This cast should not be here
|
||||
logger.info("GET Transform Config.");
|
||||
final TransformConfig transformConfig =
|
||||
((TransformRegistryImpl) transformRegistry).getTransformConfig();
|
||||
|
@@ -40,10 +40,12 @@ import org.alfresco.transform.client.registry.TransformCache;
|
||||
import org.alfresco.transform.exceptions.TransformException;
|
||||
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 com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
/**
|
||||
* Used by clients to work out if a transformation is supported based on the engine_config.json.
|
||||
@@ -52,11 +54,22 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TransformRegistryImpl.class);
|
||||
|
||||
private static final String ENGINE_CONFIG_JSON = "classpath:engine_config.json";
|
||||
@Autowired
|
||||
ResourceLoader resourceLoader;
|
||||
|
||||
@Value("${transform.config.location:classpath:engine_config.json}")
|
||||
private String locationFromProperty;
|
||||
|
||||
@Value(ENGINE_CONFIG_JSON)
|
||||
private Resource engineConfig;
|
||||
|
||||
@PostConstruct
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
engineConfig = resourceLoader.getResource(locationFromProperty);
|
||||
TransformConfig transformConfig = getTransformConfig();
|
||||
registerAll(transformConfig, null, locationFromProperty);
|
||||
}
|
||||
|
||||
// Holds the structures used by AbstractTransformRegistry to look up what is supported.
|
||||
// Unlike other sub classes this class does not extend Data or replace it at run time.
|
||||
private TransformCache data = new TransformCache();
|
||||
@@ -72,17 +85,10 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new TransformException(INTERNAL_SERVER_ERROR.value(),
|
||||
"Could not read " + ENGINE_CONFIG_JSON, e);
|
||||
"Could not read " + locationFromProperty, e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
TransformConfig transformConfig = getTransformConfig();
|
||||
registerAll(transformConfig, null, ENGINE_CONFIG_JSON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformCache getData()
|
||||
{
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.transformer.util;
|
||||
|
||||
public interface RequestParamMap
|
||||
{
|
||||
String SOURCE_ENCODING = "sourceEncoding";
|
||||
String SOURCE_EXTENSION = "sourceExtension";
|
||||
String SOURCE_MIMETYPE = "sourceMimetype";
|
||||
String TARGET_EXTENSION = "targetExtension";
|
||||
String TARGET_MIMETYPE = "targetMimetype";
|
||||
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";
|
||||
}
|
@@ -52,4 +52,15 @@ public class Util
|
||||
{
|
||||
return param == null ? null : Boolean.parseBoolean(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely converts a {@link String} to a {@link Long}
|
||||
*
|
||||
* @param param String to be converted
|
||||
* @return Null if param is null or converted value as {@link Boolean}
|
||||
*/
|
||||
public static Long stringToLong(final String param)
|
||||
{
|
||||
return param == null ? null : Long.parseLong(param);
|
||||
}
|
||||
}
|
||||
|
@@ -340,15 +340,24 @@ public abstract class AbstractTransformerControllerTest
|
||||
assertEquals(BAD_REQUEST.value(), transformReply.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return transformer specific engine config name
|
||||
*/
|
||||
public String getEngineConfigName()
|
||||
{
|
||||
return "engine_config.json";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTransformConfigInfo() throws Exception
|
||||
{
|
||||
TransformConfig expectedTransformConfig = objectMapper
|
||||
.readValue(new ClassPathResource("engine_config.json").getFile(),
|
||||
.readValue(new ClassPathResource(getEngineConfigName()).getFile(),
|
||||
TransformConfig.class);
|
||||
|
||||
ReflectionTestUtils.setField(transformRegistry, "engineConfig",
|
||||
new ClassPathResource("engine_config.json"));
|
||||
new ClassPathResource(getEngineConfigName()));
|
||||
|
||||
String response = mockMvc
|
||||
.perform(MockMvcRequestBuilders.get("/transform/config"))
|
||||
@@ -357,7 +366,6 @@ public abstract class AbstractTransformerControllerTest
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
|
||||
TransformConfig transformConfig = objectMapper.readValue(response, TransformConfig.class);
|
||||
|
||||
assertEquals(expectedTransformConfig, transformConfig);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user