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);
}
}
Aggregations