Split source code between Spring and skinny

This commit is contained in:
Erik Knizat
2020-03-23 12:25:40 +00:00
parent 5691c29de7
commit 6ec1911554
13 changed files with 201 additions and 28 deletions

View File

@@ -32,6 +32,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>

View File

@@ -2,15 +2,103 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-misc</artifactId>
<name>Alfresco Miscellaneous Transformers</name>
<packaging>jar</packaging>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.1.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-misc</artifactId>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transformer-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transformer-base</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- needed? -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<!-- HtmlParserContentTransformer -->
<dependency>
<groupId>org.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<version>2.1</version>
</dependency>
<!-- AppleIWorksContentTransformer -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<!-- TextToPdfContentTransformer -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-tools</artifactId>
<version>2.0.19</version>
</dependency>
<!-- OOXMLThumbnailContentTransformer -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${dependency.poi.version}</version>
</dependency>
<!-- EMLTransformer -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -47,7 +47,6 @@ import com.google.common.collect.ImmutableMap;
*
* @author eknizat
*/
@Component
public class SelectingTransformer
{
private static final Logger logger = LoggerFactory.getLogger(SelectingTransformer.class);

View File

@@ -0,0 +1,80 @@
{
"transformOptions": {
"textToPdfOptions": [
{"value": {"name": "pageLimit"}},
{"value": {"name": "sourceEncoding"}}
],
"stringOptions": [
{"value": {"name": "sourceEncoding"}},
{"value": {"name": "targetEncoding"}}
],
"htmlOptions": [
{"value": {"name": "sourceEncoding"}}
]
},
"transformers": [
{
"transformerName": "html",
"supportedSourceAndTargetList": [
{"sourceMediaType": "text/html", "targetMediaType": "text/plain"}
],
"transformOptions": [
"htmlOptions"
]
},
{
"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/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"
]
},
{
"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"}
],
"transformOptions": [
]
},
{
"transformerName": "textToPdf",
"supportedSourceAndTargetList": [
{"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"
]
},
{
"transformerName": "rfc822",
"supportedSourceAndTargetList": [
{"sourceMediaType": "message/rfc822", "targetMediaType": "text/plain"}
],
"transformOptions": [
]
}
]
}

View File

@@ -26,8 +26,11 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transformer.transformers.StringExtractingContentTransformer.SOURCE_ENCODING;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
//import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
import java.io.FileOutputStream;
@@ -36,21 +39,18 @@ import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import static org.alfresco.transformer.transformers.StringExtractingContentTransformer.SOURCE_ENCODING;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@Import(HtmlParserContentTransformer.class)
//@RunWith(SpringRunner.class)
//@Import(HtmlParserContentTransformer.class)
public class HtmlParserContentTransformerTest
{
private static final String SOURCE_MIMETYPE = "text/html";
private static final String TARGET_MIMETYPE = "text/plain";
@Autowired
HtmlParserContentTransformer transformer;
// @Autowired
HtmlParserContentTransformer transformer = new HtmlParserContentTransformer();
/**
* Checks that we correctly handle text in different encodings,

View File

@@ -26,8 +26,14 @@
*/
package org.alfresco.transformer.transformers;
import static org.alfresco.transformer.transformers.TextToPdfContentTransformer.PAGE_LIMIT;
import static org.junit.Assert.assertEquals;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import java.io.File;
import java.io.FileOutputStream;
@@ -36,21 +42,15 @@ import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import static org.alfresco.transformer.transformers.TextToPdfContentTransformer.PAGE_LIMIT;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@Import(TextToPdfContentTransformer.class)
//@RunWith(SpringRunner.class)
//@Import(TextToPdfContentTransformer.class)
public class TextToPdfContentTransformerTest
{
@Autowired
TextToPdfContentTransformer transformer;
// @Autowired
TextToPdfContentTransformer transformer = new TextToPdfContentTransformer();
@Before
public void setUp()