Search in sources :

Example 21 with MultiPartOutput

use of com.adaptris.util.text.mime.MultiPartOutput in project interlok by adaptris.

the class IgnoreOriginalMimeAggregator method createInitialPart.

@Override
protected MultiPartOutput createInitialPart(AdaptrisMessage original) throws MessagingException, IOException {
    MultiPartOutput output = new MultiPartOutput(original.getUniqueId(), mimeContentSubType(original));
    MetadataCollection metadata = mimeHeaderFilter().filter(original);
    metadata.forEach((e) -> {
        output.setHeader(e.getKey(), e.getValue());
    });
    return output;
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) MetadataCollection(com.adaptris.core.MetadataCollection)

Example 22 with MultiPartOutput

use of com.adaptris.util.text.mime.MultiPartOutput in project interlok by adaptris.

the class MimeAggregator method aggregate.

@Override
public void aggregate(AdaptrisMessage original, Iterable<AdaptrisMessage> msgs) throws CoreException {
    try {
        MultiPartOutput output = createInitialPart(original);
        for (AdaptrisMessage m : msgs) {
            if (filter(m)) {
                output.addPart(createBodyPart(m), contentId(m));
                overwriteMetadata(m, original);
            }
        }
        try (OutputStream out = original.getOutputStream()) {
            output.writeTo(out);
        }
        original.addMetadata(CoreConstants.MSG_MIME_ENCODED, Boolean.TRUE.toString());
    } catch (Exception e) {
        throw ExceptionHelper.wrapCoreException(e);
    }
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException) CoreException(com.adaptris.core.CoreException)

Example 23 with MultiPartOutput

use of com.adaptris.util.text.mime.MultiPartOutput in project interlok by adaptris.

the class MimeAggregator method createInitialPart.

protected MultiPartOutput createInitialPart(AdaptrisMessage original) throws MessagingException, IOException {
    MultiPartOutput output = new MultiPartOutput(original.getUniqueId(), mimeContentSubType(original));
    MetadataCollection metadata = mimeHeaderFilter().filter(original);
    metadata.forEach((e) -> {
        output.setHeader(e.getKey(), e.getValue());
    });
    output.addPart(createBodyPart(original), contentId(original));
    return output;
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) MetadataCollection(com.adaptris.core.MetadataCollection)

Aggregations

MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)23 ByteArrayIterator (com.adaptris.util.text.mime.ByteArrayIterator)8 Test (org.junit.Test)8 OutputStream (java.io.OutputStream)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 CoreException (com.adaptris.core.CoreException)3 MetadataCollection (com.adaptris.core.MetadataCollection)3 GuidGenerator (com.adaptris.util.GuidGenerator)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 MimeBodyPart (javax.mail.internet.MimeBodyPart)3 ServiceException (com.adaptris.core.ServiceException)2 Properties (java.util.Properties)2 MessagingException (javax.mail.MessagingException)2 MimeMultipart (javax.mail.internet.MimeMultipart)2 InputStreamDataSource (com.adaptris.util.text.mime.InputStreamDataSource)1 File (java.io.File)1 InputStream (java.io.InputStream)1 BodyPart (javax.mail.BodyPart)1