in src/main/java/org/apache/servicemix/jbi/helper/MessageUtil.java [173:202]
public NormalizedMessageImpl(NormalizedMessage message) throws MessagingException {
try {
String str = new SourceTransformer().contentToString(message);
if (str != null) {
this.content = new StringSource(str);
}
for (Iterator it = message.getPropertyNames().iterator(); it.hasNext();) {
String name = (String) it.next();
this.properties.put(name, message.getProperty(name));
}
for (Iterator it = message.getAttachmentNames().iterator(); it.hasNext();) {
String name = (String) it.next();
DataHandler dh = message.getAttachment(name);
DataSource ds = dh.getDataSource();
if (!(ds instanceof ByteArrayDataSource)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtil.copyInputStream(ds.getInputStream(), baos);
ByteArrayDataSource bads = new ByteArrayDataSource(baos.toByteArray(), ds.getContentType());
bads.setName(ds.getName());
dh = new DataHandler(bads);
}
this.attachments.put(name, dh);
}
this.subject = message.getSecuritySubject();
} catch (MessagingException e) {
throw e;
} catch (Exception e) {
throw new MessagingException(e);
}
}