Search in sources :

Example 41 with TransformationOptions

use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.

the class BinaryPassThroughContentTransformerTest method testIsTransformable.

public void testIsTransformable() throws Exception {
    TransformationOptions options = new TransformationOptions();
    boolean reliability = false;
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, options);
    assertFalse("Mimetype should not be supported", reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_XML, -1, MimetypeMap.MIMETYPE_XML, options);
    assertFalse("Mimetype should not be supported", reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_WORD, options);
    assertTrue("Mimetype should be supported", reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_EXCEL, options);
    assertTrue("Mimetype should be supported", reliability);
}
Also used : TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 42 with TransformationOptions

use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.

the class ContentTransformerRegistryTest method testGetActiveTransformersEnabledDisabled.

public void testGetActiveTransformersEnabledDisabled() throws Exception {
    TransformationOptions options = new TransformationOptions();
    Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
    try {
        registry.setEnabled(false);
        Assert.assertTrue(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
    } finally {
        registry.setEnabled(true);
    }
    Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
}
Also used : TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 43 with TransformationOptions

use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.

the class TransformerConfigDynamicTransformersTest method pipelineTest.

@Test
public // Simple pipeline
void pipelineTest() {
    mockProperties(transformerProperties, "content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2|png|transformer3");
    assertEquals(0, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, transformerRegistry, transformerDebug, null, null, null).getErrorCount());
    assertEquals(4, transformerRegistry.getAllTransformers().size());
    assertEquals(1, transformerRegistry.getTransformers().size());
    // Throws an exception if it does not exist
    ContentTransformer trans = transformerRegistry.getTransformer("transformer.transformerA");
    // Check the pipeline
    ComplexContentTransformer transformer = (ComplexContentTransformer) trans;
    assertEquals(2, transformer.getIntermediateMimetypes().size());
    assertEquals("application/pdf", transformer.getIntermediateMimetypes().get(0));
    assertEquals("image/png", transformer.getIntermediateMimetypes().get(1));
    assertEquals(3, transformer.getIntermediateTransformers().size());
    assertEquals("transformer.transformer1", transformer.getIntermediateTransformers().get(0).getName());
    assertEquals("transformer.transformer2", transformer.getIntermediateTransformers().get(1).getName());
    assertEquals("transformer.transformer3", transformer.getIntermediateTransformers().get(2).getName());
    // 
    transformer.isTransformable("application/pdf", -1, "text/txt", new TransformationOptions());
}
Also used : TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions) Test(org.junit.Test)

Example 44 with TransformationOptions

use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.

the class StringExtractingContentTransformerTest method testInterTextTransform.

public void testInterTextTransform() throws Exception {
    ContentReader reader = writeContent("text/xml", "MacDingbat");
    // check transformability
    assertTrue(transformer.isTransformable(reader.getMimetype(), -1, targetWriter.getMimetype(), new TransformationOptions()));
    // transform
    transformer.transform(reader, targetWriter);
    // get a reader onto the transformed content and check
    ContentReader checkReader = targetWriter.getReader();
    String checkContent = checkReader.getContentString();
    assertEquals("Content check failed", SOME_CONTENT, checkContent);
}
Also used : FileContentReader(org.alfresco.repo.content.filestore.FileContentReader) ContentReader(org.alfresco.service.cmr.repository.ContentReader) TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Aggregations

TransformationOptions (org.alfresco.service.cmr.repository.TransformationOptions)44 ContentReader (org.alfresco.service.cmr.repository.ContentReader)10 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)8 ImageTransformationOptions (org.alfresco.repo.content.transform.magick.ImageTransformationOptions)6 SWFTransformationOptions (org.alfresco.repo.content.transform.swf.SWFTransformationOptions)6 ContentTransformer (org.alfresco.repo.content.transform.ContentTransformer)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Serializable (java.io.Serializable)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 FileContentReader (org.alfresco.repo.content.filestore.FileContentReader)3 ContentIOException (org.alfresco.service.cmr.repository.ContentIOException)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 TransformationOptionLimits (org.alfresco.service.cmr.repository.TransformationOptionLimits)3 QName (org.alfresco.service.namespace.QName)3 HashMap (java.util.HashMap)2 StringJoiner (java.util.StringJoiner)2 ExecutionException (java.util.concurrent.ExecutionException)2 FileContentWriter (org.alfresco.repo.content.filestore.FileContentWriter)2 ImageResizeOptions (org.alfresco.repo.content.transform.magick.ImageResizeOptions)2