Search in sources :

Example 1 with Convertor

use of nl.nn.adapterframework.extensions.aspose.services.conv.impl.convertors.Convertor in project iaf by ibissource.

the class CisConversionServiceImpl method convertToPdf.

@Override
public CisConversionResult convertToPdf(Message message, String filename, ConversionOption conversionOption) throws IOException {
    CisConversionResult result = null;
    MediaType mediaType = getMediaType(message, filename);
    if (isPasswordProtected(mediaType)) {
        result = CisConversionResult.createPasswordFailureResult(filename, conversionOption, mediaType);
    } else {
        // Get the convertor for the given mediatype.
        Convertor convertor = convertorFactory.getConvertor(mediaType);
        if (convertor == null) {
            // Conversion not supported.
            String errorMessage = "Omzetten naar PDF mislukt! Reden: bestandstype wordt niet ondersteund (mediaType: " + mediaType + ")";
            result = createFailureResult(filename, conversionOption, mediaType, errorMessage);
        } else {
            long startTime = System.currentTimeMillis();
            // Convertor found, convert the file
            result = convertor.convertToPdf(mediaType, filename, message, conversionOption, charset);
            if (LOGGER.isDebugEnabled())
                LOGGER.debug(String.format("Convert (in %d msec): mediatype: %s, filename: %s, attachmentoptions: %s", System.currentTimeMillis() - startTime, mediaType, filename, conversionOption));
        }
    }
    return result;
}
Also used : MediaType(org.apache.tika.mime.MediaType) CisConversionResult(nl.nn.adapterframework.extensions.aspose.services.conv.CisConversionResult) Convertor(nl.nn.adapterframework.extensions.aspose.services.conv.impl.convertors.Convertor)

Aggregations

CisConversionResult (nl.nn.adapterframework.extensions.aspose.services.conv.CisConversionResult)1 Convertor (nl.nn.adapterframework.extensions.aspose.services.conv.impl.convertors.Convertor)1 MediaType (org.apache.tika.mime.MediaType)1