REPO-4639 Content conversion failed using Tika (#108)

* REPO-4639: Split tika engine_config.json into separate transformers.

* WIP: REPO-4639 Content conversion failed using Tika

The Tika T-Engine "transform" option does not exist when called via the Transform Service or Local transforms, which resulted in no transforms taking place. However this value is really not be needed as the T-Engine should be able to read its own engine_config.xml to work out which sub transform to use. Transforms only worked via Legacy transforms, which used a T-Engine.

This code is based on tried and tested ACS repository code. It has been further simplified.

TODO:
- replace the ConfigFileFinder class just added with something that uses Spring to read the JSON. i.e. simplify it.
- replace the CombinedConfig class just added with something that does not need the InLineTransformer. i.e. simplify it.
- create tests based on the repo tests
- remove the source and target mimetype checks in Tika as a check against engine_config.xml is cleaner.
- repeat the process for the Misc T-Engine as it has similar code checking source and target mimetypes.
- remove the transform option passed by the legacy transforms.

* Removed CombindConfig and ConfigFileFnder classes.

* Extracted AbstractTransformRegistry so that it may be used in the ACS repository too.

TODO AbstractTransformRegistry and AbstractTransformRegistry need to be moved to the alfresco-transform-model pakage

* tidy up only

* REPO-4639: Add priority to duplicate transforms.

* REPO-4639: Refactor TikaTransformationIT to use the new Tika /transform specifications
Changes AbstractTransformerControllerTest as the engine_config is now loaded in TransformRegistryImpl instead of AbstractTransformerController

* Rename to TransformServiceRegistry, so we don't have to change the repo code.

* Added the baseUrl parameter to the register method and fixed the missed rename in the last commit.

* Javadoc change only

* Moved common classes (with repo) AbbstractTransformRegistry and TransformServiceRegistry to alfresco-transform-model

* Replace (simplify) all the isTransformable calls with a check against the JSON.
- Tests now only pass targetEncoding to the 'string' transformer.

* Fix failing tests.

* Revert port change

* REPO-4639 : Add priorities to misc engine_config

* REPO-4639 : Add priorities to pdf-renderer and  imagemagick engine_config

* Remove test that is @Ignored

* Pick up alfresco-transformer-model 1.0.2.7-REPO-4639-1

* REPO-4639 : Add priorities to libreoffice engine_config

* REPO-4639 : Add priorities to tika engine_config

* REPO-4639 : Remove all priorities with value equal to 50 (default) from engine_config

* Switch over to using TransformServiceRegistry in org.alfresco.transform.client.registry
Reintroduce the noExtensionSourceFilenameTest having removed @Ignore.

* New whitesource issue on commons-compress 1.18. Upgrading to 1.19.

* Removed the text/javascript -> text/plain test as this is not supported

* Modifications as a result of changes to method names in alfresco-transform-model

* Pick up alfresco-transform-model 1.0.2.7-ATS545-2

* Remove unused imports
This commit is contained in:
alandavis
2019-09-12 13:34:42 +01:00
committed by CezarLeahu
parent 614bdbe52f
commit d6777b58eb
28 changed files with 2087 additions and 1875 deletions

View File

@@ -33,7 +33,6 @@ import static org.alfresco.transformer.fs.FileManager.createSourceFile;
import static org.alfresco.transformer.fs.FileManager.createTargetFile;
import static org.alfresco.transformer.fs.FileManager.createTargetFileName;
import static org.alfresco.transformer.transformers.HtmlParserContentTransformer.SOURCE_ENCODING;
import static org.alfresco.transformer.transformers.HtmlParserContentTransformer.TARGET_ENCODING;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
@@ -90,8 +89,7 @@ public class MiscController extends AbstractTransformerController
{
Map<String, String> parameters = new HashMap<>();
parameters.put(SOURCE_ENCODING, "UTF-8");
parameters.put(TARGET_ENCODING, "UTF-8");
transformer.transform(sourceFile, targetFile, MIMETYPE_HTML, MIMETYPE_TEXT_PLAIN,
transformer.transform("html", sourceFile, targetFile, MIMETYPE_HTML, MIMETYPE_TEXT_PLAIN,
parameters);
}
};
@@ -109,8 +107,8 @@ public class MiscController extends AbstractTransformerController
" '{}', timeout {} ms", sourceFile, targetFile, transformOptions, timeout);
}
transformer.transform(sourceFile, targetFile, sourceMimetype, targetMimetype,
transformOptions);
String transform = getTransformerName(sourceFile, sourceMimetype, targetMimetype, transformOptions);
transformer.transform(transform, sourceFile, targetFile, sourceMimetype, targetMimetype, transformOptions);
}
@PostMapping(value = "/transform", consumes = MULTIPART_FORM_DATA_VALUE)
@@ -118,15 +116,18 @@ public class MiscController extends AbstractTransformerController
@RequestParam("file") MultipartFile sourceMultipartFile,
@RequestParam("targetExtension") String targetExtension,
@RequestParam("targetMimetype") String targetMimetype,
@RequestParam(value = "targetEncoding", required = false) String targetEncoding,
@RequestParam("sourceMimetype") String sourceMimetype,
@RequestParam(value = "testDelay", required = false) Long testDelay,
@RequestParam Map<String, String> parameters)
@RequestParam(value = "sourceEncoding", required = false) String sourceEncoding,
@RequestParam(value = "pageLimit", required = false) String pageLimit,
@RequestParam(value = "testDelay", required = false) Long testDelay)
{
if (logger.isDebugEnabled())
{
logger.debug(
"Processing request with: sourceMimetype '{}', targetMimetype '{}' , targetExtension '{}' " +
", parameters '{}'", sourceMimetype, targetMimetype, targetExtension, parameters);
"Processing request with: sourceMimetype '{}', sourceEncoding '{}', " +
"targetMimetype '{}', targetExtension '{}', targetEncoding '{}', pageLimit '{}'",
sourceMimetype, sourceEncoding, targetMimetype, targetExtension, targetEncoding, pageLimit);
}
final String targetFilename = createTargetFileName(
@@ -135,7 +136,13 @@ public class MiscController extends AbstractTransformerController
final File sourceFile = createSourceFile(request, sourceMultipartFile);
final File targetFile = createTargetFile(request, targetFilename);
transformer.transform(sourceFile, targetFile, sourceMimetype, targetMimetype, parameters);
Map<String, String> transformOptions = createTransformOptions(
"sourceEncoding", sourceEncoding,
"targetEncoding", targetEncoding,
"pageLimit", pageLimit);
String transform = getTransformerName(sourceFile, sourceMimetype, targetMimetype, transformOptions);
transformer.transform(transform, sourceFile, targetFile, sourceMimetype, targetMimetype, transformOptions);
final ResponseEntity<Resource> body = createAttachment(targetFilename, targetFile);
LogEntry.setTargetSize(targetFile.length());

View File

@@ -27,9 +27,6 @@
package org.alfresco.transformer.transformers;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IMAGE_JPEG;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IWORK_KEYNOTE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IWORK_NUMBERS;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IWORK_PAGES;
import java.io.BufferedInputStream;
import java.io.File;
@@ -76,15 +73,6 @@ public class AppleIWorksContentTransformer implements SelectableTransformer
// (225 x 173) preview-web.jpg
// (53 x 41) preview-micro.jpg
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
return MIMETYPE_IWORK_KEYNOTE.equals(sourceMimetype) ||
MIMETYPE_IWORK_NUMBERS.equals(sourceMimetype) ||
MIMETYPE_IWORK_PAGES.equals(sourceMimetype);
}
@Override
public void transform(final File sourceFile, final File targetFile, final String sourceMimetype,
final String targetMimetype, final Map<String, String> parameters)

View File

@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_MULTIPART_ALTERNATIVE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_RFC822;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import java.io.BufferedInputStream;
@@ -55,7 +54,6 @@ import javax.mail.Part;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
/**
* Uses javax.mail.MimeMessage to generate plain text versions of RFC822 email
* messages. Searches for all text content parts, and returns them. Any
@@ -77,21 +75,6 @@ public class EMLTransformer implements SelectableTransformer
private static final String CHARSET = "charset";
private static final String DEFAULT_ENCODING = "UTF-8";
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype, Map<String, String> parameters)
{
if (!MIMETYPE_RFC822.equals(sourceMimetype)
|| !MIMETYPE_TEXT_PLAIN.equals(targetMimetype))
{
// only support RFC822 -> TEXT
return false;
}
else
{
return true;
}
}
@Override
public void transform(final File sourceFile, final File targetFile, final String sourceMimetype,
final String targetMimetype, final Map<String, String> parameters) throws Exception

View File

@@ -26,9 +26,6 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
@@ -77,13 +74,6 @@ public class HtmlParserContentTransformer implements SelectableTransformer
private static final Logger logger = LoggerFactory.getLogger(
HtmlParserContentTransformer.class);
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
return MIMETYPE_HTML.equals(sourceMimetype) && MIMETYPE_TEXT_PLAIN.equals(targetMimetype);
}
@Override
public void transform(final File sourceFile, final File targetFile, final String sourceMimetype,
final String targetMimetype, final Map<String, String> parameters) throws Exception

View File

@@ -26,33 +26,11 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IMAGE_JPEG;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_ADDIN;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_SLIDE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_SLIDE_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_TEMPLATE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_PRESENTATION_TEMPLATE_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET_ADDIN_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET_BINARY_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_WORDPROCESSING;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_WORDPROCESSING_MACRO;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_WORD_TEMPLATE;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_OPENXML_WORD_TEMPLATE_MACRO;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
import org.apache.poi.openxml4j.opc.OPCPackage;
@@ -63,8 +41,6 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
/**
* Extracts out Thumbnail JPEGs from OOXML files for thumbnailing and previewing.
* This transformer will only work for OOXML files where thumbnailing was enabled,
@@ -82,36 +58,6 @@ public class OOXMLThumbnailContentTransformer implements SelectableTransformer
private static final Logger logger = LoggerFactory.getLogger(
OOXMLThumbnailContentTransformer.class);
private static final List<String> OOXML_MIMETYPES = ImmutableList.of(
MIMETYPE_OPENXML_WORDPROCESSING,
MIMETYPE_OPENXML_WORDPROCESSING_MACRO,
MIMETYPE_OPENXML_WORD_TEMPLATE,
MIMETYPE_OPENXML_WORD_TEMPLATE_MACRO,
MIMETYPE_OPENXML_PRESENTATION,
MIMETYPE_OPENXML_PRESENTATION_MACRO,
MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW,
MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW_MACRO,
MIMETYPE_OPENXML_PRESENTATION_TEMPLATE,
MIMETYPE_OPENXML_PRESENTATION_TEMPLATE_MACRO,
MIMETYPE_OPENXML_PRESENTATION_ADDIN,
MIMETYPE_OPENXML_PRESENTATION_SLIDE,
MIMETYPE_OPENXML_PRESENTATION_SLIDE_MACRO,
MIMETYPE_OPENXML_SPREADSHEET,
MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE,
MIMETYPE_OPENXML_SPREADSHEET_MACRO,
MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE_MACRO,
MIMETYPE_OPENXML_SPREADSHEET_ADDIN_MACRO,
MIMETYPE_OPENXML_SPREADSHEET_BINARY_MACRO);
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
// only support [OOXML] -> JPEG
return MIMETYPE_IMAGE_JPEG.equals(targetMimetype) &&
OOXML_MIMETYPES.contains(sourceMimetype);
}
@Override
public void transform(final File sourceFile, final File targetFile, final String sourceMimetype,
final String targetMimetype, final Map<String, String> parameters) throws Exception

View File

@@ -49,15 +49,4 @@ public interface SelectableTransformer
*/
void transform(File sourceFile, File targetFile, String sourceMimetype,
String targetMimetype, Map<String, String> parameters) throws Exception;
/**
* Determine whether this transformer is applicable for the given MIME types.
*
* @param sourceMimetype
* @param targetMimetype
* @param parameters
* @return
*/
boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters);
}

View File

@@ -30,7 +30,7 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import java.io.File;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
@@ -40,8 +40,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.google.common.collect.ImmutableList;
/**
* The SelectingTransformer selects a registered {@link SelectableTransformer}
* and delegates the transformation to its implementation.
@@ -53,35 +51,35 @@ public class SelectingTransformer
{
private static final Logger logger = LoggerFactory.getLogger(SelectingTransformer.class);
private final List<SelectableTransformer> transformers;
private final Map<String, SelectableTransformer> transformers;
public SelectingTransformer()
{
transformers = ImmutableList.of(
new AppleIWorksContentTransformer(),
new HtmlParserContentTransformer(),
new StringExtractingContentTransformer(),
new TextToPdfContentTransformer(),
new EMLTransformer()
// new OOXMLThumbnailContentTransformer()); // Doesn't work with java 11, transformer and test disabled
);
transformers = new HashMap<>();
transformers.put("appleIWorks", new AppleIWorksContentTransformer());
transformers.put("html", new HtmlParserContentTransformer());
transformers.put("string", new StringExtractingContentTransformer());
transformers.put("textToPdf", new TextToPdfContentTransformer());
transformers.put("rfc822", new EMLTransformer());
transformers.put("ooXmlThumbnail", new OOXMLThumbnailContentTransformer());
}
/**
* Performs a transform using a transformer selected based on the provided sourceMimetype and targetMimetype
*
*
* @param transform the name of the transformer
* @param sourceFile File to transform from
* @param targetFile File to transform to
* @param sourceMimetype Mimetype of the source file
* @throws TransformException
* @throws TransformException if there was a problem internally
*/
public void transform(File sourceFile, File targetFile, String sourceMimetype,
String targetMimetype, Map<String, String> parameters) throws TransformException
public void transform(String transform, File sourceFile, File targetFile, String sourceMimetype,
String targetMimetype, Map<String, String> parameters) throws TransformException
{
try
{
final SelectableTransformer transformer = selectTransformer(sourceMimetype,
targetMimetype, parameters);
final SelectableTransformer transformer = transformers.get(transform);
logOptions(sourceFile, targetFile, parameters);
transformer.transform(sourceFile, targetFile, sourceMimetype, targetMimetype,
parameters);
@@ -106,23 +104,6 @@ public class SelectingTransformer
}
}
private SelectableTransformer selectTransformer(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
for (SelectableTransformer transformer : transformers)
{
if (transformer.isTransformable(sourceMimetype, targetMimetype, parameters))
{
logger.debug("Using {} to transform from {} to {}",
transformer.getClass().getName(), sourceMimetype, targetMimetype);
return transformer;
}
}
throw new RuntimeException(
"Could not select a transformer for sourceMimetype=" + sourceMimetype
+ " targetMimetype=" + targetMimetype);
}
private static String getMessage(Exception e)
{
return e.getMessage() == null || e.getMessage().isEmpty() ? e.getClass().getSimpleName() : e.getMessage();

View File

@@ -26,10 +26,6 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_DITA;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_JAVASCRIPT;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -64,16 +60,6 @@ public class StringExtractingContentTransformer implements SelectableTransformer
private static final Log logger = LogFactory.getLog(StringExtractingContentTransformer.class);
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
return (sourceMimetype.startsWith("text/")
|| MIMETYPE_JAVASCRIPT.equals(sourceMimetype)
|| MIMETYPE_DITA.equals(sourceMimetype))
&& MIMETYPE_TEXT_PLAIN.equals(targetMimetype);
}
/**
* Text to text conversions are done directly using the content reader and writer string
* manipulation methods.

View File

@@ -26,12 +26,6 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_DITA;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_CSV;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_XML;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -103,17 +97,6 @@ public class TextToPdfContentTransformer implements SelectableTransformer
}
}
@Override
public boolean isTransformable(String sourceMimetype, String targetMimetype,
Map<String, String> parameters)
{
return (MIMETYPE_TEXT_PLAIN.equals(sourceMimetype) ||
MIMETYPE_TEXT_CSV.equals(sourceMimetype) ||
MIMETYPE_DITA.equals(sourceMimetype) ||
MIMETYPE_XML.equals(sourceMimetype)) &&
MIMETYPE_PDF.equals(targetMimetype);
}
@Override
public void transform(final File sourceFile, final File targetFile, final String sourceMimetype,
final String targetMimetype, final Map<String, String> parameters) throws Exception

View File

@@ -16,7 +16,7 @@
{
"transformerName": "html",
"supportedSourceAndTargetList": [
{"sourceMediaType": "text/html", "targetMediaType": "text/plain"}
{"sourceMediaType": "text/html", "targetMediaType": "text/plain"}
],
"transformOptions": [
"htmlOptions"
@@ -25,23 +25,22 @@
{
"transformerName": "string",
"supportedSourceAndTargetList": [
{"sourceMediaType": "text/plain", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/mediawiki", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/css", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/csv", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/javascript", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/xml", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/html", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/richtext", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/sgml", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/tab-separated-values", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-setext", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-java-source", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-jsp", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-markdown", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/calendar", "targetMediaType": "text/plain"},
{"sourceMediaType": "application/x-javascript", "targetMediaType": "text/plain"},
{"sourceMediaType": "application/dita+xml", "targetMediaType": "text/plain"}
{"sourceMediaType": "text/plain", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/mediawiki", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/css", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/csv", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/xml", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/html", "priority": 55, "targetMediaType": "text/plain"},
{"sourceMediaType": "text/richtext", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/sgml", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/tab-separated-values", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-setext", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-java-source", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-jsp", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/x-markdown", "targetMediaType": "text/plain"},
{"sourceMediaType": "text/calendar", "targetMediaType": "text/plain"},
{"sourceMediaType": "application/x-javascript", "targetMediaType": "text/plain"},
{"sourceMediaType": "application/dita+xml", "targetMediaType": "text/plain"}
],
"transformOptions": [
"stringOptions"
@@ -50,9 +49,9 @@
{
"transformerName": "appleIWorks",
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/vnd.apple.keynote", "targetMediaType": "image/jpeg"},
{"sourceMediaType": "application/vnd.apple.numbers", "targetMediaType": "image/jpeg"},
{"sourceMediaType": "application/vnd.apple.pages", "targetMediaType": "image/jpeg"}
{"sourceMediaType": "application/vnd.apple.keynote", "targetMediaType": "image/jpeg"},
{"sourceMediaType": "application/vnd.apple.numbers", "targetMediaType": "image/jpeg"},
{"sourceMediaType": "application/vnd.apple.pages", "targetMediaType": "image/jpeg"}
],
"transformOptions": [
]
@@ -60,10 +59,10 @@
{
"transformerName": "textToPdf",
"supportedSourceAndTargetList": [
{"sourceMediaType": "text/plain", "targetMediaType": "application/pdf"},
{"sourceMediaType": "text/csv", "targetMediaType": "application/pdf"},
{"sourceMediaType": "application/dita+xml", "targetMediaType": "application/pdf"},
{"sourceMediaType": "text/xml", "targetMediaType": "application/pdf"}
{"sourceMediaType": "text/plain", "priority": 55, "targetMediaType": "application/pdf"},
{"sourceMediaType": "text/csv", "targetMediaType": "application/pdf"},
{"sourceMediaType": "application/dita+xml", "targetMediaType": "application/pdf"},
{"sourceMediaType": "text/xml", "targetMediaType": "application/pdf"}
],
"transformOptions": [
"textToPdfOptions"
@@ -72,7 +71,7 @@
{
"transformerName": "rfc822",
"supportedSourceAndTargetList": [
{"sourceMediaType": "message/rfc822", "targetMediaType": "text/plain"}
{"sourceMediaType": "message/rfc822", "targetMediaType": "text/plain"}
],
"transformOptions": [
]

View File

@@ -109,11 +109,18 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
String... params)
{
return super.mockMvcRequest(url, sourceFile, params)
.param("targetEncoding", targetEncoding)
.param("sourceEncoding", sourceEncoding)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
.param("sourceEncoding", sourceEncoding)
.param("targetMimetype", targetMimetype)
.param("sourceMimetype", sourceMimetype);
// Only the 'string' transformer should have the targetEncoding.
if ("text/plain".equals(targetMimetype) && !"message/rfc822".equals(sourceMimetype) && !"text/html".equals(sourceMimetype))
{
builder.param("targetEncoding", targetEncoding);
}
return builder;
}
@Test
@@ -254,7 +261,7 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
MIMETYPE_HTML,
"txt",
MIMETYPE_TEXT_PLAIN,
"UTF-8",
null,
expected.getBytes());
String contentResult = new String(result.getResponse().getContentAsByteArray(),
@@ -325,7 +332,7 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
MIMETYPE_TEXT_PLAIN,
"pdf",
MIMETYPE_PDF,
"UTF-8",
null,
expected.getBytes());
// Read back in the PDF and check it

View File

@@ -139,7 +139,6 @@ public class MiscTransformsIT
SourceTarget.of("text/mediawiki", "text/plain"),
SourceTarget.of("text/css", "text/plain"),
SourceTarget.of("text/csv", "text/plain"),
SourceTarget.of("text/javascript", "text/plain"),
SourceTarget.of("text/xml", "text/plain"),
SourceTarget.of("text/html", "text/plain"),
SourceTarget.of("text/richtext", "text/plain"),