Do the wiring

This commit is contained in:
Erik Knizat
2020-04-03 17:15:36 +01:00
parent 4a96e3aabd
commit fc96f9aa5f
13 changed files with 80 additions and 10 deletions

View File

@@ -50,6 +50,7 @@ import org.alfresco.transformer.probes.ProbeTestTransform;
import org.alfresco.transformer.transformers.AllInOneTransformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
@@ -74,7 +75,8 @@ public class AIOController extends AbstractTransformerController
TEST_DELAY
};
private AllInOneTransformer transformer = new AllInOneTransformer();
@Autowired
private AllInOneTransformer transformer;
@Override
public String getTransformerName()

View File

@@ -0,0 +1,47 @@
package org.alfresco.transformer;
import jdk.jfr.Name;
import org.alfresco.transform.client.model.config.TransformConfig;
import org.alfresco.transform.client.registry.TransformServiceRegistry;
import org.alfresco.transformer.transformers.AllInOneTransformer;
import org.alfresco.transformer.transformers.Transformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@Configuration
public class AIOCustomConfig
{
@Bean("AllInOneTransformer")
public Transformer aioTransformer()
{
return new AllInOneTransformer();
}
/**
*
* @return Override the TransformRegistryImpl used in {@link AbstractTransformerController}
*/
@Bean
@Primary
public TransformServiceRegistry transformRegistryOverride()
{
return new TransformRegistryImpl()
{
@Autowired
@Qualifier("AllInOneTransformer")
Transformer transformer;
@Override
TransformConfig getTransformConfig()
{
return transformer.getTransformConfig();
}
};
}
}

View File

@@ -32,14 +32,20 @@ import java.io.IOException;
import org.alfresco.transform.client.model.TransformRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@WebMvcTest(AIOController.class)
@Import(AIOCustomConfig.class)
public class AIOControllerTest //extends AbstractTransformerControllerTest
{
@Autowired
AIOController aioController;
//@Override
protected void mockTransformCommand(String sourceExtension, String targetExtension, String sourceMimetype,
boolean readTargetFileBytes) throws IOException {
@@ -62,6 +68,6 @@ public class AIOControllerTest //extends AbstractTransformerControllerTest
@Test
public void emptyTest()
{
aioController.info();
}
}

View File

@@ -62,6 +62,9 @@ public class AllInOneTransformer implements Transformer
{
this.registerTransformer(new MiscAdapter());
this.registerTransformer(new TikaAdapter());
this.registerTransformer(new ImageMagickAdapter());
this.registerTransformer(new LibreOfficeAdapter());
this.registerTransformer(new PdfRendererAdapter());
}
catch (Exception e)
{

View File

@@ -37,7 +37,7 @@ import org.alfresco.transformer.PdfRendererOptionsBuilder;
public class PdfRendererAdapter extends AbstractTransformer
{
private static String CONFIG_PREFIX = "pdf-renderer";
private static String CONFIG_PREFIX = "pdfrenderer";
private PdfRendererCommandExecutor pdfExecutor;
//TODO move key strings to a central class