Search in sources :

Example 1 with InputStreamDataSource

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

the class FlattenMimeParts method doService.

@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
    try (InputStream in = msg.getInputStream()) {
        InputStreamDataSource src = new InputStreamDataSource(in);
        MimeMultipart mime = new MimeMultipart(src);
        MultiPartOutput output = new MultiPartOutput(msg.getUniqueId());
        List<BodyPart> parts = extract(mime);
        for (BodyPart p : parts) {
            output.addPart((MimeBodyPart) p, generateIfNoContentId(p));
        }
        addHeaders(src.getHeaders(), output);
        try (OutputStream out = msg.getOutputStream()) {
            output.writeTo(out);
        }
    } catch (Exception e) {
        throw ExceptionHelper.wrapServiceException(e);
    }
}
Also used : InputStreamDataSource(com.adaptris.util.text.mime.InputStreamDataSource) MimeBodyPart(javax.mail.internet.MimeBodyPart) BodyPart(javax.mail.BodyPart) MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) MimeMultipart(javax.mail.internet.MimeMultipart) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) ServiceException(com.adaptris.core.ServiceException) CoreException(com.adaptris.core.CoreException)

Aggregations

CoreException (com.adaptris.core.CoreException)1 ServiceException (com.adaptris.core.ServiceException)1 InputStreamDataSource (com.adaptris.util.text.mime.InputStreamDataSource)1 MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 BodyPart (javax.mail.BodyPart)1 MimeBodyPart (javax.mail.internet.MimeBodyPart)1 MimeMultipart (javax.mail.internet.MimeMultipart)1