Search in sources :

Example 36 with TransformationOptions

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

the class ArchiveContentTransformerTest method testRecursing.

public void testRecursing() throws Exception {
    ContentWriter writer;
    String contents;
    // Bean off, no options
    transformer.setIncludeContents("FALSE");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, false);
    // Bean on, no options
    transformer.setIncludeContents("TRUE");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, true);
    // Bean off, Transformation Options off
    TransformationOptions options = new TransformationOptions();
    transformer.setIncludeContents("FALSE");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer, options);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, false);
    // Bean on, Transformation Options off
    transformer.setIncludeContents("T");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer, options);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, true);
    // Bean off, Transformation Options on - options win
    options.setIncludeEmbedded(true);
    transformer.setIncludeContents("FALSE");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer, options);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, true);
    // Bean on, Transformation Options on
    transformer.setIncludeContents("YeS");
    writer = getTestWriter();
    transformer.transform(getTestReader(), writer, options);
    contents = writer.getReader().getContentString();
    testHasFiles(contents);
    testNested(contents, true);
}
Also used : ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) FileContentWriter(org.alfresco.repo.content.filestore.FileContentWriter) TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 37 with TransformationOptions

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

the class ComplexContentTransformerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    ContentTransformer unoTransformer = (ContentTransformer) ctx.getBean("transformer.JodConverter");
    ContentTransformer pdfBoxTransformer = (ContentTransformer) ctx.getBean("transformer.PdfBox");
    // make sure that they are working for this test
    if (unoTransformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()) == false) {
        isAvailable = false;
        return;
    } else if (pdfBoxTransformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()) == false) {
        isAvailable = false;
        return;
    } else {
        isAvailable = true;
    }
    transformer = new ComplexContentTransformer();
    transformer.setMimetypeService(mimetypeService);
    transformer.setTransformerDebug(transformerDebug);
    transformer.setTransformerConfig(transformerConfig);
    // set the transformer list
    List<ContentTransformer> transformers = new ArrayList<ContentTransformer>(2);
    transformers.add(unoTransformer);
    transformers.add(pdfBoxTransformer);
    transformer.setTransformers(transformers);
    // set the intermediate mimetypes
    List<String> intermediateMimetypes = Collections.singletonList(MimetypeMap.MIMETYPE_PDF);
    transformer.setIntermediateMimetypes(intermediateMimetypes);
}
Also used : ArrayList(java.util.ArrayList) TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 38 with TransformationOptions

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

the class ComplexContentTransformerTest method testReliability.

public void testReliability() throws Exception {
    if (!isAvailable) {
        return;
    }
    boolean reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions());
    assertEquals("Mimetype should not be supported", false, reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions());
    assertEquals("Mimetype should be supported", true, reliability);
}
Also used : TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 39 with TransformationOptions

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

the class DummyTestContentTransformer method testReliability.

public void testReliability() throws Exception {
    // The MIME types here are rather arbitrary
    boolean reliability = transformer.isTransformable(sourceMimeType, -1, targetMimeType, new TransformationOptions());
    assertEquals("Mimetype should be supported", true, reliability);
}
Also used : TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 40 with TransformationOptions

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

the class OpenOfficeContentTransformerTest method testReliability.

public void testReliability() throws Exception {
    if (!isOpenOfficeWorkerAvailable()) {
        // no connection
        System.err.println("ooWorker not available - skipping testReliability !!");
        return;
    }
    boolean reliability = transformer.isTransformable(MIMETYPE_RUBBISH, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions());
    assertEquals("Mimetype should not be supported", false, reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_RUBBISH, new TransformationOptions());
    assertEquals("Mimetype should not be supported", false, reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_XHTML, new TransformationOptions());
    assertEquals("Mimetype should not be supported", false, reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_WORD, new TransformationOptions());
    assertEquals("Mimetype should be supported", true, reliability);
    reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions());
    assertEquals("Mimetype should be supported", true, reliability);
}
Also used : 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