MNT-24883 adding source file name to transform options

Added source file name to transform options if exist in nodeService. It will be used in ATS to maintain consistency in transform for filenames.
This commit is contained in:
bsayan2 2025-06-17 14:13:41 +05:30 committed by GitHub
parent b800c86a7c
commit 81c47c2b04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 706 additions and 494 deletions

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@ -26,16 +26,16 @@
*/
package org.alfresco.transform.base.fs;
import org.alfresco.transform.base.logging.LogEntry;
import org.alfresco.transform.common.ExtensionService;
import org.alfresco.transform.exceptions.TransformException;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriUtils;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.springframework.http.HttpHeaders.CONTENT_DISPOSITION;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INSUFFICIENT_STORAGE;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.util.StringUtils.getFilename;
import static org.alfresco.transform.common.ExtensionService.getExtensionForMimetype;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -43,14 +43,19 @@ import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.util.UUID;
import jakarta.servlet.http.HttpServletRequest;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.alfresco.transform.common.ExtensionService.getExtensionForMimetype;
import static org.springframework.http.HttpHeaders.CONTENT_DISPOSITION;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INSUFFICIENT_STORAGE;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.util.StringUtils.getFilename;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriUtils;
import org.alfresco.transform.base.logging.LogEntry;
import org.alfresco.transform.common.ExtensionService;
import org.alfresco.transform.exceptions.TransformException;
public class FileManager
{
@ -58,16 +63,19 @@ public class FileManager
public static final String TARGET_FILE = "targetFile";
private FileManager()
{
}
{}
public static File createSourceFile(HttpServletRequest request, InputStream inputStream, String sourceMimetype)
public static File createSourceFile(HttpServletRequest request, InputStream inputStream, String sourceMimetype, String sourceFileName)
{
try
{
String extension = "." + getExtensionForMimetype(sourceMimetype);
File file = TempFileProvider.createTempFile("source_", extension);
File file = StringUtils.isEmpty(sourceFileName)
? TempFileProvider.createTempFile("source_", extension)
: TempFileProvider.createFileWithinUUIDTempDir(sourceFileName);
Files.copy(inputStream, file.toPath(), REPLACE_EXISTING);
if (request != null)
{
request.setAttribute(SOURCE_FILE, file);
@ -201,8 +209,7 @@ public class FileManager
public static class TempFileProvider
{
private TempFileProvider()
{
}
{}
public static File createTempFile(final String prefix, final String suffix)
{
@ -215,10 +222,21 @@ public class FileManager
{
throw new RuntimeException(
"Failed to created temp file: \n prefix: " + prefix +
"\n suffix: " + suffix + "\n directory: " + directory, e);
"\n suffix: " + suffix + "\n directory: " + directory,
e);
}
}
public static File createFileWithinUUIDTempDir(String sourceFileName)
{
File tempDir = new File(getTempDir(), UUID.randomUUID().toString());
if (!tempDir.mkdirs() && !tempDir.exists())
{
throw new TransformException(INSUFFICIENT_STORAGE, "Failed to create temp directory: " + tempDir);
}
return new File(tempDir, sourceFileName);
}
private static File getTempDir()
{
final String dirName = "Alfresco";

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2022 - 2023 Alfresco Software Limited
* Copyright (C) 2022 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@ -26,19 +26,12 @@
*/
package org.alfresco.transform.base.transform;
import org.alfresco.transform.base.CustomTransformer;
import org.alfresco.transform.base.TransformController;
import org.alfresco.transform.base.logging.LogEntry;
import org.alfresco.transform.base.probes.ProbeTransform;
import org.alfresco.transform.base.registry.CustomTransformers;
import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transform.common.TransformerDebug;
import org.alfresco.transform.registry.TransformServiceRegistry;
import org.springframework.web.multipart.MultipartFile;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import static org.alfresco.transform.common.RequestParamMap.*;
import jakarta.jms.Destination;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@ -46,30 +39,32 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import jakarta.jms.Destination;
import jakarta.servlet.http.HttpServletRequest;
import static org.alfresco.transform.common.RequestParamMap.DIRECT_ACCESS_URL;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_EXTENSION;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_MIMETYPE;
import static org.alfresco.transform.common.RequestParamMap.TARGET_EXTENSION;
import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import org.springframework.web.multipart.MultipartFile;
import org.alfresco.transform.base.CustomTransformer;
import org.alfresco.transform.base.TransformController;
import org.alfresco.transform.base.logging.LogEntry;
import org.alfresco.transform.base.probes.ProbeTransform;
import org.alfresco.transform.base.registry.CustomTransformers;
import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transform.common.TransformerDebug;
import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transform.registry.TransformServiceRegistry;
/**
* Provides the transform logic common to http (upload/download), message and probe requests. See
* {@link TransformHandler#handleHttpRequest(HttpServletRequest, MultipartFile, String, String, Map, ProbeTransform)},
* {@link TransformHandler#handleMessageRequest(TransformRequest, Long, Destination, ProbeTransform)} and
* {@link TransformHandler#handleProbeRequest(String, String, Map, File, File, ProbeTransform)}. Note the handing of transform requests
* via a message queue is the same as via the {@link TransformController#transform(TransformRequest, Long, Destination)}.
* Provides the transform logic common to http (upload/download), message and probe requests. See {@link TransformHandler#handleHttpRequest(HttpServletRequest, MultipartFile, String, String, Map, ProbeTransform)}, {@link TransformHandler#handleMessageRequest(TransformRequest, Long, Destination, ProbeTransform)} and {@link TransformHandler#handleProbeRequest(String, String, Map, File, File, ProbeTransform)}. Note the handing of transform requests via a message queue is the same as via the {@link TransformController#transform(TransformRequest, Long, Destination)}.
*/
abstract class ProcessHandler extends FragmentHandler
{
private static final List<String> NON_TRANSFORM_OPTION_REQUEST_PARAMETERS = Arrays.asList(SOURCE_EXTENSION,
TARGET_EXTENSION, TARGET_MIMETYPE, SOURCE_MIMETYPE, DIRECT_ACCESS_URL);
TARGET_EXTENSION, TARGET_MIMETYPE, SOURCE_MIMETYPE, DIRECT_ACCESS_URL, SOURCE_FILENAME);
protected final String sourceMimetype;
protected final String targetMimetype;
protected final String sourceFileName;
private final Map<String, String> transformOptions;
protected String reference;
private final TransformServiceRegistry transformRegistry;
@ -83,6 +78,7 @@ abstract class ProcessHandler extends FragmentHandler
{
this.sourceMimetype = sourceMimetype;
this.targetMimetype = targetMimetype;
this.sourceFileName = transformOptions.getOrDefault(SOURCE_FILENAME, null);
this.transformOptions = cleanTransformOptions(transformOptions);
this.reference = reference;
@ -107,7 +103,6 @@ abstract class ProcessHandler extends FragmentHandler
super.init();
}
public String getReference()
{
return reference;
@ -118,6 +113,7 @@ abstract class ProcessHandler extends FragmentHandler
LogEntry.start();
transformManager.setSourceMimetype(sourceMimetype);
transformManager.setTargetMimetype(targetMimetype);
transformManager.setSourceFileName(sourceFileName);
probeTransform.incrementTransformerCount();
try
{
@ -174,8 +170,7 @@ abstract class ProcessHandler extends FragmentHandler
}
protected void sendTransformResponse(TransformManagerImpl transformManager)
{
}
{}
protected void handleTransformException(TransformException e)
{

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@ -26,18 +26,21 @@
*/
package org.alfresco.transform.base.transform;
import org.alfresco.transform.base.TransformManager;
import org.alfresco.transform.base.fs.FileManager;
import org.alfresco.transform.base.util.OutputStreamLengthRecorder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.alfresco.transform.base.TransformManager;
import org.alfresco.transform.base.fs.FileManager;
import org.alfresco.transform.base.util.OutputStreamLengthRecorder;
/**
* Manages the input and output streams and any temporary files that have been created.
@ -60,6 +63,17 @@ public class TransformManagerImpl implements TransformManager
private boolean createTargetFileCalled;
private Boolean startedWithSourceFile;
private Boolean startedWithTargetFile;
private String sourceFileName;
public String getSourceFileName()
{
return sourceFileName;
}
public void setSourceFileName(String sourceFileName)
{
this.sourceFileName = sourceFileName;
}
public void setRequest(HttpServletRequest request)
{
@ -71,7 +85,8 @@ public class TransformManagerImpl implements TransformManager
this.processHandler = processHandler;
}
@Override public String getRequestId()
@Override
public String getRequestId()
{
return processHandler.getReference();
}
@ -149,7 +164,8 @@ public class TransformManagerImpl implements TransformManager
keepTargetFile = true;
}
@Override public File createSourceFile()
@Override
public File createSourceFile()
{
if (createSourceFileCalled)
{
@ -159,12 +175,13 @@ public class TransformManagerImpl implements TransformManager
if (sourceFile == null)
{
sourceFile = FileManager.createSourceFile(request, inputStream, sourceMimetype);
sourceFile = FileManager.createSourceFile(request, inputStream, sourceMimetype, sourceFileName);
}
return sourceFile;
}
@Override public File createTargetFile()
@Override
public File createTargetFile()
{
if (createTargetFileCalled)
{
@ -204,8 +221,19 @@ public class TransformManagerImpl implements TransformManager
{
logger.error("Failed to delete temporary source file {}", sourceFile.getPath());
}
if (sourceFile != null)
{
File parentDir = sourceFile.getParentFile();
if (parentDir != null
&& !StringUtils.equalsAny(parentDir.getName().toLowerCase(Locale.ROOT), "alfresco", "temp", "tmp")
&& !parentDir.delete())
{
logger.error("Failed to delete parent directory {}", parentDir.getPath());
}
}
outputStreamLengthRecorder = null;
sourceFile = null;
sourceFileName = null;
createSourceFileCalled = false;
startedWithSourceFile = null;
}

View File

@ -10,6 +10,7 @@
<form method="POST" enctype="multipart/form-data" th:action="${proxyPathPrefix+'/test'}">
<table>
<tr><td><div style="text-align:right">file</div></td><td><input type="file" name="file" /></td></tr>
<tr><td><div style="text-align:right">sourceFilename</div></td><td><input type="text" name="sourceFilename"/></td></tr>
<tr><td><div style="text-align:right">directAccessUrl</div></td><td><input type="text" name="directAccessUrl"/></td></tr>
<tr><td><div style="text-align:right">sourceMimetype</div></td><td><input type="text" name="sourceMimetype" value="" /></td>
<td><select name="_sourceMimetype">

View File

@ -26,25 +26,12 @@
*/
package org.alfresco.transform.base;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithAllInOne;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithOneCustomTransformer;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithTwoCustomTransformers;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Jpg;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Png;
import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.alfresco.transform.base.TransformControllerTest.assertConfig;
import static org.alfresco.transform.base.TransformControllerTest.getLogMessagesFor;
@ -64,16 +51,30 @@ import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_VERSION;
import static org.alfresco.transform.common.RequestParamMap.PAGE_REQUEST_PARAM;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_MIMETYPE;
import static org.alfresco.transform.common.RequestParamMap.TARGET_MIMETYPE;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithAllInOne;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithOneCustomTransformer;
import org.alfresco.transform.base.fakes.FakeTransformEngineWithTwoCustomTransformers;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Jpg;
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Png;
import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
/**
* Testing TransformController functionality where there are multiple TransformEngines brought together
* in a single t-engine.
* Testing TransformController functionality where there are multiple TransformEngines brought together in a single t-engine.
*
* Repeats a set of tests from {@link TransformControllerTest}, which tests the single TransformEngine case.
*/
@ -188,12 +189,12 @@ public class TransformControllerAllInOneTest
public void testConfigLatestEndpointReturnsCoreVersionAndDirectAccessUrlOption() throws Exception
{
assertConfig(ENDPOINT_TRANSFORM_CONFIG_LATEST,
"Pdf2Jpg,"+coreVersion+",directAccessUrl,imageOptions\n"
+ "Pdf2Png,"+coreVersion+",directAccessUrl,imageOptions\n"
+ "TxT2Pdf,"+coreVersion+",directAccessUrl,docOptions\n"
+ "Txt2JpgViaPdf,"+coreVersion+",directAccessUrl,imageOptions\n"
+ "Txt2PngViaPdf,"+coreVersion+",directAccessUrl,imageOptions",
"directAccessUrl,docOptions,imageOptions", mockMvc, objectMapper);
"Pdf2Jpg," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename\n"
+ "Pdf2Png," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename\n"
+ "TxT2Pdf," + coreVersion + ",directAccessUrl,docOptions,sourceFilename\n"
+ "Txt2JpgViaPdf," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename\n"
+ "Txt2PngViaPdf," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename",
"directAccessUrl,docOptions,imageOptions,sourceFilename", mockMvc, objectMapper);
}
@Test
@ -215,7 +216,8 @@ public class TransformControllerAllInOneTest
}
@Test
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception {
public void testTransformEndpointUsingTransformEngineWithOneCustomTransformer() throws Exception
{
await()
.atMost(10, TimeUnit.SECONDS)
.untilAsserted(() -> mockMvc.perform(

View File

@ -167,8 +167,7 @@ public class TransformControllerTest
{
StringJoiner logMessages = new StringJoiner("\n");
Logger logger = (Logger) LoggerFactory.getLogger(classBeingLogged);
AppenderBase<ILoggingEvent> logAppender = new AppenderBase<>()
{
AppenderBase<ILoggingEvent> logAppender = new AppenderBase<>() {
@Override
protected void append(ILoggingEvent iLoggingEvent)
{
@ -183,7 +182,6 @@ public class TransformControllerTest
return logMessages;
}
private void testPageWithOrWithoutIngresPrefix(String url, boolean behindIngres, String... expected) throws Exception
{
boolean origBehindIngres = (boolean) ReflectionTestUtils.getField(transformController, "behindIngres");
@ -247,7 +245,8 @@ public class TransformControllerTest
"<a href=\"/log\">Log</a>",
"<a href=\"/ready\">Ready</a>",
"<a href=\"/live\">Live</a>",
"<a href=\"/transform/config?configVersion=9999\">Config</a>"); }
"<a href=\"/transform/config?configVersion=9999\">Config</a>");
}
@Test
public void testErrorEndpointReturnsErrorPageWithIngres() throws Exception
@ -332,11 +331,11 @@ public class TransformControllerTest
public void testConfigLatestEndpointReturnsCoreVersionAndDirectAccessUrlOption() throws Exception
{
assertConfig(ENDPOINT_TRANSFORM_CONFIG_LATEST,
"Pdf2Png,"+coreVersion+",directAccessUrl,imageOptions\n"
+ "TxT2Pdf,"+coreVersion+",directAccessUrl,docOptions\n"
"Pdf2Png," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename\n"
+ "TxT2Pdf," + coreVersion + ",directAccessUrl,docOptions,sourceFilename\n"
+ "Txt2JpgViaPdf,null,imageOptions\n"
+ "Txt2PngViaPdf,"+coreVersion+",directAccessUrl,imageOptions",
"directAccessUrl,docOptions,imageOptions", mockMvc, objectMapper);
+ "Txt2PngViaPdf," + coreVersion + ",directAccessUrl,imageOptions,sourceFilename",
"directAccessUrl,docOptions,imageOptions,sourceFilename", mockMvc, objectMapper);
}
static void assertConfig(String url, String expectedTransformers, String expectedOptions,
@ -348,7 +347,8 @@ public class TransformControllerTest
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
.andReturn()
.getResponse()
.getContentAsString(), TransformConfig.class);
.getContentAsString(),
TransformConfig.class);
// Gets a list of transformerNames,coreVersion,optionNames
assertEquals(expectedTransformers,
@ -381,8 +381,7 @@ public class TransformControllerTest
return new FileRefResponse(new FileRefEntity(fileRef));
});
when(fakeSfsClient.retrieveFile(any())).thenAnswer((Answer) invocation ->
ResponseEntity.ok().header(CONTENT_DISPOSITION,"attachment; filename*=UTF-8''transform.tmp")
when(fakeSfsClient.retrieveFile(any())).thenAnswer((Answer) invocation -> ResponseEntity.ok().header(CONTENT_DISPOSITION, "attachment; filename*=UTF-8''transform.tmp")
.body((Resource) new UrlResource(sfsRef2File.get(invocation.getArguments()[0]).toURI())));
File sourceFile = getTestFile("original.txt", true, tempDir);
@ -462,7 +461,8 @@ public class TransformControllerTest
SOURCE_MIMETYPE, MIMETYPE_TEXT_PLAIN,
TARGET_MIMETYPE, MIMETYPE_PDF,
PAGE_REQUEST_PARAM, "1",
SOURCE_ENCODING, "UTF-8")), any());
SOURCE_ENCODING, "UTF-8")),
any());
}
finally
{

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2022 - 2022 Alfresco Software Limited
* Copyright (C) 2022 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
@ -26,9 +26,9 @@
*/
package org.alfresco.transform.base.transform;
import org.alfresco.transform.base.CustomTransformer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@ -43,14 +43,15 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.alfresco.transform.base.CustomTransformer;
/**
* Tests {@link StreamHandler}, {@link TransformManagerImpl#createSourceFile()} and
* {@link TransformManagerImpl#createTargetFile()} methods.
* Tests {@link StreamHandler}, {@link TransformManagerImpl#createSourceFile()} and {@link TransformManagerImpl#createTargetFile()} methods.
*/
@SuppressWarnings("PMD.TooManyMethods")
public class StreamHandlerTest
{
public static final String ORIGINAL = "Original";
@ -448,8 +449,7 @@ public class StreamHandlerTest
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
{
new FakeStreamHandler()
{
new FakeStreamHandler() {
@Override
protected void init() throws IOException
{
@ -480,8 +480,7 @@ public class StreamHandlerTest
File sourceFile = tempFile();
write(sourceFile, ORIGINAL);
new FakeStreamHandler()
{
new FakeStreamHandler() {
@Override
protected void init() throws IOException
{
@ -512,8 +511,7 @@ public class StreamHandlerTest
File sourceFile = tempFile();
write(sourceFile, ORIGINAL);
new FakeStreamHandler()
{
new FakeStreamHandler() {
@Override
protected InputStream getInputStream() throws IOException
{
@ -533,8 +531,7 @@ public class StreamHandlerTest
{
File targetFile = tempFile();
new FakeStreamHandler()
{
new FakeStreamHandler() {
@Override
protected InputStream getInputStream()
{
@ -560,8 +557,7 @@ public class StreamHandlerTest
{
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
{
new FakeStreamHandler()
{
new FakeStreamHandler() {
@Override
protected InputStream getInputStream()
{
@ -576,4 +572,34 @@ public class StreamHandlerTest
}.handleTransformRequest();
}
}
@Test
public void testStartWithInputStreamAndCallCreateSourceFileWithSourceFileName() throws Exception
{
try (
InputStream in = getSourceInputStreamFromBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStream rec = transformManager.setOutputStream(out))
{
String testFilename = "test.docx";
transformManager.setSourceFileName(testFilename);
transformManager.setInputStream(in);
File src = transformManager.createSourceFile();
assertTrue(src.exists());
write(rec, read(src) + CHANGE);
assertEquals(testFilename, src.getName());
transformManager.copyTargetFileToOutputStream();
transformManager.getOutputStream().close();
closeInputStreamWithoutException(in);
Long outputLength = transformManager.getOutputLength();
transformManager.deleteSourceFile();
transformManager.deleteTargetFile();
assertEquals(EXPECTED, read(out));
assertEquals(EXPECTED.length(), outputLength);
assertFalse(src.exists());
}
}
}

View File

@ -26,6 +26,7 @@ import org.alfresco.transform.config.CoreVersionDecorator;
/**
* Request parameters and transform options used in the core transformers.
*/
@SuppressWarnings("PMD.ConstantsInInterface")
public interface RequestParamMap
{
// html parameter names
@ -72,6 +73,9 @@ public interface RequestParamMap
// Html parameter names for the transform config
String HTML_COLLAPSE = "collapseHtml";
// source file name for the libre transform options
String SOURCE_FILENAME = "sourceFilename";
// Parameters interpreted by the TransformController
String DIRECT_ACCESS_URL = "directAccessUrl";

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Model
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -21,14 +21,13 @@
*/
package org.alfresco.transform.config;
import org.apache.maven.artifact.versioning.ComparableVersion;
import static org.alfresco.transform.config.CoreFunction.Constants.NO_UPPER_VERSION;
import static org.alfresco.transform.config.CoreFunction.Constants.NO_VERSION;
import org.apache.maven.artifact.versioning.ComparableVersion;
/**
* Provides a mapping between a transform {@code coreVersion} and functionality (such as the use of Direct Access URLs)
* supported in that version of the {@code alfresco-transform-base}, so that clients know if they may use it.
* Provides a mapping between a transform {@code coreVersion} and functionality (such as the use of Direct Access URLs) supported in that version of the {@code alfresco-transform-base}, so that clients know if they may use it.
*/
public enum CoreFunction
{
@ -41,7 +40,10 @@ public enum CoreFunction
/** Original way to talk to a T-Engine **/
// The toValue really should be null rather than "9999" but gives us an upper test value
HTTP(null, "99999");
HTTP(null, "99999"),
/** Additional transform option to preserve original file name **/
SOURCE_FILENAME("5.1.8", null);
private final ComparableVersion fromVersion;
private final ComparableVersion toVersion;

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Model
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -21,7 +21,12 @@
*/
package org.alfresco.transform.config;
import org.apache.maven.artifact.versioning.ComparableVersion;
import static java.util.function.Predicate.not;
import static org.alfresco.transform.common.RequestParamMap.DIRECT_ACCESS_URL;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_FILENAME;
import static org.alfresco.transform.config.CoreFunction.Constants.NO_VERSION;
import static org.alfresco.transform.config.CoreFunction.newComparableVersion;
import java.util.HashMap;
import java.util.HashSet;
@ -31,31 +36,28 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.function.Predicate.not;
import static org.alfresco.transform.config.CoreFunction.Constants.NO_VERSION;
import static org.alfresco.transform.config.CoreFunction.newComparableVersion;
import static org.alfresco.transform.common.RequestParamMap.DIRECT_ACCESS_URL;
import org.apache.maven.artifact.versioning.ComparableVersion;
/**
* <p>Class sets or clears the {@code coreVersion} property of {@link Transformer}s in a {@link TransformConfig}<p/>
* <p>
* Class sets or clears the {@code coreVersion} property of {@link Transformer}s in a {@link TransformConfig}
* <p/>
*
* <p>Since alfresco-transform-core 5.2.7, the config returned by T-Engines and T-Router via their
* {@code "/transform/config"} endpoint has been decorated with an {@code coreVersion} element, indicating what core
* functionality is provided by each transformer as a result of extending the {@code TransformController} in
* the {@code alfresco-transform-base}. This is automatically added, so need not be specified by the T-Engine developer.
* It was originally added to indicate that it was possible to use Direct Access URLs (DAU).</p>
* <p>
* Since alfresco-transform-core 5.2.7, the config returned by T-Engines and T-Router via their {@code "/transform/config"} endpoint has been decorated with an {@code coreVersion} element, indicating what core functionality is provided by each transformer as a result of extending the {@code TransformController} in the {@code alfresco-transform-base}. This is automatically added, so need not be specified by the T-Engine developer. It was originally added to indicate that it was possible to use Direct Access URLs (DAU).
* </p>
*
* <p>This class provides methods to sets or clear the field with the version number of the
* {@code alfresco-transform-base}. No value indicates 5.2.6 or earlier.</p>
* <p>
* This class provides methods to sets or clear the field with the version number of the {@code alfresco-transform-base}. No value indicates 5.2.6 or earlier.
* </p>
*
* <p>To allow older and newer version of the Repository, T-Router and T-Engines to work together, this field is only
* returned if requested by a client that also knows about the field. An optional {@code "configVersion"} parameter
* has been added to the endpoint. The config for T-Engines need only add the field to single-step-transforms. When
* configs are combined it is then possible to add this field to pipeline and failover transforms by using the lowest
* core value of any step transform.</p>
* <p>
* To allow older and newer version of the Repository, T-Router and T-Engines to work together, this field is only returned if requested by a client that also knows about the field. An optional {@code "configVersion"} parameter has been added to the endpoint. The config for T-Engines need only add the field to single-step-transforms. When configs are combined it is then possible to add this field to pipeline and failover transforms by using the lowest core value of any step transform.
* </p>
*
* <p>If the field is not requested in the T-Router or the all-in-one transformer endpoint, it may need to be stripped
* from the {@link TransformConfig} as some of the T-Engines may have supplied it.</p>
* <p>
* If the field is not requested in the T-Router or the all-in-one transformer endpoint, it may need to be stripped from the {@link TransformConfig} as some of the T-Engines may have supplied it.
* </p>
*
* @see CoreFunction
*/
@ -63,12 +65,12 @@ public class CoreVersionDecorator
{
public static final int CONFIG_VERSION_INCLUDES_CORE_VERSION = 2;
private static final Set<TransformOption> DIRECT_ACCESS_URL_TRANSFORM_OPTIONS =
Set.of(new TransformOptionValue(false, DIRECT_ACCESS_URL));
private static final Set<TransformOption> DIRECT_ACCESS_URL_TRANSFORM_OPTIONS = Set.of(new TransformOptionValue(false, DIRECT_ACCESS_URL));
private static final Set<TransformOption> SOURCE_FILENAME_TRANSFORM_OPTIONS = Set.of(new TransformOptionValue(false, SOURCE_FILENAME));
/**
* Returns a new {@link TransformConfig} that includes or excludes the {@code coreVersion} field and
* associated elements like directAccessUrl.
* Returns a new {@link TransformConfig} that includes or excludes the {@code coreVersion} field and associated elements like directAccessUrl.
*/
public static TransformConfig setOrClearCoreVersion(TransformConfig transformConfig, int configVersion)
{
@ -106,6 +108,7 @@ public class CoreVersionDecorator
.withSupportedDefaults(transformConfig.getSupportedDefaults())
.build();
addOrRemoveDirectAccessUrlOption(transformConfig.getTransformOptions(), transformConfig.getTransformers());
addOrRemoveSourceFileNameOption(transformConfig.getTransformOptions(), transformConfig.getTransformers());
return transformConfig;
}
@ -119,6 +122,7 @@ public class CoreVersionDecorator
transformer.setTransformOptions(setOrClearCoreTransformOptions(coreVersion, transformer.getTransformOptions()));
});
addOrRemoveDirectAccessUrlOption(transformConfig.getTransformOptions(), transformers);
addOrRemoveSourceFileNameOption(transformConfig.getTransformOptions(), transformers);
}
/**
@ -152,6 +156,7 @@ public class CoreVersionDecorator
transformer.getTransformOptions()));
});
addOrRemoveDirectAccessUrlOption(transformOptions, transformers);
addOrRemoveSourceFileNameOption(transformOptions, transformers);
}
private static Set<String> setOrClearCoreTransformOptions(String coreVersion, Set<String> transformerTransformOptions)
@ -168,6 +173,15 @@ public class CoreVersionDecorator
{
transformerTransformOptions.remove(DIRECT_ACCESS_URL);
}
if (CoreFunction.SOURCE_FILENAME.isSupported(coreVersion))
{
// Add SOURCE_FILENAME to a copy of this Transformer's transform options.
transformerTransformOptions.add(SOURCE_FILENAME);
}
else
{
transformerTransformOptions.remove(SOURCE_FILENAME);
}
return transformerTransformOptions;
}
@ -186,6 +200,20 @@ public class CoreVersionDecorator
}
}
private static void addOrRemoveSourceFileNameOption(Map<String, Set<TransformOption>> transformOptions,
List<Transformer> transformers)
{
if (transformers.stream()
.anyMatch(transformer -> CoreFunction.SOURCE_FILENAME.isSupported(transformer.getCoreVersion())))
{
transformOptions.put(SOURCE_FILENAME, SOURCE_FILENAME_TRANSFORM_OPTIONS);
}
else
{
transformOptions.remove(SOURCE_FILENAME);
}
}
private static boolean isSingleStep(Transformer transformer)
{
return (transformer.getTransformerFailover() == null || transformer.getTransformerFailover().isEmpty()) &&

View File

@ -2,7 +2,7 @@
* #%L
* Alfresco Transform Model
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -21,10 +21,14 @@
*/
package org.alfresco.transform.registry;
import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transform.config.TransformOption;
import org.alfresco.transform.config.TransformOptionGroup;
import org.alfresco.transform.config.TransformOptionValue;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Map.Entry;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.alfresco.transform.common.RequestParamMap.*;
import java.util.ArrayList;
import java.util.HashMap;
@ -34,19 +38,15 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Map.Entry;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_ENCODING;
import static org.alfresco.transform.common.RequestParamMap.TIMEOUT;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import org.alfresco.transform.config.TransformOption;
import org.alfresco.transform.config.TransformOptionGroup;
import org.alfresco.transform.config.TransformOptionValue;
import org.alfresco.transform.exceptions.TransformException;
class TransformRegistryHelper
{
private TransformRegistryHelper()
{
}
{}
static Set<TransformOption> lookupTransformOptions(final Set<String> transformOptionNames,
final Map<String, Set<TransformOption>> transformOptions, final String readFrom,
@ -70,9 +70,7 @@ class TransformRegistryHelper
options.add(new TransformOptionGroup(false, oneSetOfTransformOptions));
}
return options.size() == 1 ?
((TransformOptionGroup) options.iterator().next()).getTransformOptions() :
options;
return options.size() == 1 ? ((TransformOptionGroup) options.iterator().next()).getTransformOptions() : options;
}
// Returns transformers in increasing supported size order, where lower priority transformers for the same size have
@ -98,13 +96,14 @@ class TransformRegistryHelper
return cachedTransformList;
}
// The transformOptions sometimes contains sourceEncoding and timeout, even though they should not be used
// The transformOptions sometimes contains sourceEncoding / timeout / file name, even though they should not be used
// to select a transformer. Would like to change this, but cannot as we need to support all ACS repo versions.
if (actualOptions.containsKey(SOURCE_ENCODING) || actualOptions.containsKey(TIMEOUT))
if (actualOptions.containsKey(SOURCE_ENCODING) || actualOptions.containsKey(TIMEOUT) || actualOptions.containsKey(SOURCE_FILENAME))
{
actualOptions = new HashMap<>(actualOptions);
actualOptions.remove(SOURCE_ENCODING);
actualOptions.remove(TIMEOUT);
actualOptions.remove(SOURCE_FILENAME);
}
final List<SupportedTransform> builtTransformList = buildTransformList(data,
@ -269,18 +268,15 @@ class TransformRegistryHelper
}
/**
* Flatten out the transform options by adding them to the supplied possibleTransformOptions.</p>
* Flatten out the transform options by adding them to the supplied possibleTransformOptions.
* </p>
*
* If possible discards options in the supplied transformOptionGroup if the group is optional and the actualOptions
* don't provide any of the options in the group. Or to put it another way:<p/>
* If possible discards options in the supplied transformOptionGroup if the group is optional and the actualOptions don't provide any of the options in the group. Or to put it another way:
* <p/>
*
* It adds individual transform options from the transformOptionGroup to possibleTransformOptions if the group is
* required or if the actualOptions include individual options from the group. As a result it is possible that none
* of the group are added if it is optional. It is also possible to add individual transform options that are
* themselves required but not in the actualOptions. In this the optionsMatch method will return false.
* It adds individual transform options from the transformOptionGroup to possibleTransformOptions if the group is required or if the actualOptions include individual options from the group. As a result it is possible that none of the group are added if it is optional. It is also possible to add individual transform options that are themselves required but not in the actualOptions. In this the optionsMatch method will return false.
*
* @return true if any options were added. Used by nested call parents to determine if an option was added from a
* nested sub group.
* @return true if any options were added. Used by nested call parents to determine if an option was added from a nested sub group.
*/
static boolean addToPossibleTransformOptions(
final Map<String, Boolean> possibleTransformOptions,

View File

@ -21,8 +21,14 @@
*/
package org.alfresco.transform.config;
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.alfresco.transform.common.RequestParamMap.*;
import static org.alfresco.transform.config.CoreFunction.standardizeCoreVersion;
import static org.alfresco.transform.config.CoreVersionDecorator.CONFIG_VERSION_INCLUDES_CORE_VERSION;
import static org.alfresco.transform.config.CoreVersionDecorator.setCoreVersionOnMultiStepTransformers;
import static org.alfresco.transform.config.CoreVersionDecorator.setCoreVersionOnSingleStepTransformers;
import static org.alfresco.transform.config.CoreVersionDecorator.setOrClearCoreVersion;
import java.util.HashMap;
import java.util.HashSet;
@ -30,14 +36,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_DEFAULT;
import static org.alfresco.transform.common.RequestParamMap.DIRECT_ACCESS_URL;
import static org.alfresco.transform.config.CoreFunction.standardizeCoreVersion;
import static org.alfresco.transform.config.CoreVersionDecorator.CONFIG_VERSION_INCLUDES_CORE_VERSION;
import static org.alfresco.transform.config.CoreVersionDecorator.setCoreVersionOnMultiStepTransformers;
import static org.alfresco.transform.config.CoreVersionDecorator.setCoreVersionOnSingleStepTransformers;
import static org.alfresco.transform.config.CoreVersionDecorator.setOrClearCoreVersion;
import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;
class CoreVersionDecoratorTest
{
@ -47,13 +47,23 @@ class CoreVersionDecoratorTest
public static final Set<TransformOption> SOME_OPTIONS = Set.of(new TransformOptionValue(false, "someOption"));
private static final Set<TransformOption> DIRECT_ACCESS_URL_OPTION = Set.of(new TransformOptionValue(false, DIRECT_ACCESS_URL));
private static final Set<TransformOption> SOURCE_FILENAME_OPTION = Set.of(new TransformOptionValue(false, SOURCE_FILENAME));
private final Map<String, Set<TransformOption>> TRANSFORM_OPTIONS_WITHOUT_DIRECT_ACCESS_URL = new HashMap<>();
private final Map<String, Set<TransformOption>> TRANSFORM_OPTIONS_WITH_DIRECT_ACCESS_URL = new HashMap<>();
private final Map<String, Set<TransformOption>> TRANSFORM_OPTIONS_WITHOUT_SOURCE_FILENAME = new HashMap<>();
private final Map<String, Set<TransformOption>> TRANSFORM_OPTIONS_WITH_SOURCE_FILENAME = new HashMap<>();
{
TRANSFORM_OPTIONS_WITHOUT_DIRECT_ACCESS_URL.put(SOME_NAME, SOME_OPTIONS);
TRANSFORM_OPTIONS_WITH_DIRECT_ACCESS_URL.put(SOME_NAME, SOME_OPTIONS);
TRANSFORM_OPTIONS_WITH_DIRECT_ACCESS_URL.put(DIRECT_ACCESS_URL, DIRECT_ACCESS_URL_OPTION);
TRANSFORM_OPTIONS_WITHOUT_SOURCE_FILENAME.put(SOME_NAME, SOME_OPTIONS);
TRANSFORM_OPTIONS_WITHOUT_SOURCE_FILENAME.put(DIRECT_ACCESS_URL, DIRECT_ACCESS_URL_OPTION);
TRANSFORM_OPTIONS_WITH_SOURCE_FILENAME.put(SOME_NAME, SOME_OPTIONS);
TRANSFORM_OPTIONS_WITH_SOURCE_FILENAME.put(DIRECT_ACCESS_URL, DIRECT_ACCESS_URL_OPTION);
TRANSFORM_OPTIONS_WITH_SOURCE_FILENAME.put(SOURCE_FILENAME, SOURCE_FILENAME_OPTION);
}
private TransformConfig newTransformConfig(String version1, String version2, String version3, String version4, String version5,
@ -223,4 +233,106 @@ class CoreVersionDecoratorTest
assertEquals("2", standardizeCoreVersion("2"));
assertEquals("2.5.7", standardizeCoreVersion("2.5.7-A-SNAPSHOT"));
}
private TransformConfig newTransformConfigForSourceFileName(String version1, String version2, String version3, String version4, String version5,
boolean hasSourceFilename, boolean multiStepHaveSourceFilename)
{
HashSet<String> transformOptions1 = new HashSet<>();
HashSet<String> transformOptions2 = new HashSet<>(transformOptions1);
transformOptions2.add(SOME_NAME);
HashSet<String> transformOptions3 = new HashSet<>(transformOptions1);
HashSet<String> transformOptions4 = new HashSet<>(transformOptions1);
transformOptions4.addAll(transformOptions2);
HashSet<String> transformOptions5 = new HashSet<>(transformOptions1);
transformOptions5.addAll(transformOptions2);
transformOptions5.addAll(transformOptions3);
transformOptions1.add(DIRECT_ACCESS_URL);
transformOptions2.add(DIRECT_ACCESS_URL);
transformOptions3.add(DIRECT_ACCESS_URL);
transformOptions4.add(DIRECT_ACCESS_URL);
transformOptions5.add(DIRECT_ACCESS_URL);
if (hasSourceFilename)
{
transformOptions1.add(SOURCE_FILENAME);
transformOptions2.add(SOURCE_FILENAME);
transformOptions3.add(SOURCE_FILENAME);
}
if (multiStepHaveSourceFilename)
{
transformOptions4.add(SOURCE_FILENAME);
transformOptions5.add(SOURCE_FILENAME);
}
return TransformConfig.builder()
.withTransformOptions(hasSourceFilename ? TRANSFORM_OPTIONS_WITH_SOURCE_FILENAME : TRANSFORM_OPTIONS_WITHOUT_SOURCE_FILENAME)
.withTransformers(ImmutableList.of(
Transformer.builder()
.withTransformerName("transformer1")
.withCoreVersion(version1)
.withTransformOptions(transformOptions1)
.build(),
Transformer.builder()
.withTransformerName("transformer2")
.withCoreVersion(version2)
.withTransformOptions(transformOptions2)
.build(),
Transformer.builder()
.withTransformerName("transformer3")
.withCoreVersion(version3)
.withTransformOptions(transformOptions3)
.build(),
Transformer.builder()
.withTransformerName("pipeline4")
.withCoreVersion(version4)
.withTransformerPipeline(List.of(
new TransformStep("transformer1", "mimetype/c"),
new TransformStep("transformer2", null)))
.withTransformOptions(transformOptions4)
.build(),
Transformer.builder()
.withTransformerName("failover5")
.withCoreVersion(version5)
.withTransformerFailover(List.of("transformer1", "transformer2", "transformer3"))
.withTransformOptions(transformOptions5)
.build()))
.build();
}
@Test
void setCoreVersionWithSourceFileNameOptionTest()
{
String sourceFileName = SOURCE_FILENAME;
// Create transform config with no SOURCE_FILENAME option
String sourceFileNameSupport = "5.1.8";
TransformConfig transformConfig = newTransformConfigForSourceFileName(
sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport,
sourceFileNameSupport, sourceFileNameSupport,
false, false);
// Add SOURCE_FILENAME to all single step transformers
setCoreVersionOnSingleStepTransformers(transformConfig, sourceFileNameSupport);
// Check that SOURCE_FILENAME is present in all single step transformers' options
assertEquals(newTransformConfigForSourceFileName("4.0.0", "4.0.0", "4.0.0", "4.0.0", "4.0.0",
false, false),
setOrClearCoreVersion(
newTransformConfigForSourceFileName("4.0.0", "4.0.0", "4.0.0", "4.0.0", "4.0.0",
false, false),
CONFIG_VERSION_INCLUDES_CORE_VERSION));
// Supported version: SOURCE_FILENAME should be present
assertEquals(newTransformConfigForSourceFileName(sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport,
true, true),
setOrClearCoreVersion(
newTransformConfigForSourceFileName(sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport, sourceFileNameSupport, true, true),
CONFIG_VERSION_INCLUDES_CORE_VERSION));
}
}