private void convertAttachments() throws IOException {
if (attachments != null) {
Map newAttachments = createAttachmentsMap();
for (Iterator it = attachments.keySet().iterator(); it.hasNext();) {
String name = (String) it.next();
DataSource ds = (DataSource) attachments.get(name);
if (ds instanceof ByteArrayDataSource) {
newAttachments.put(name, ds);
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtil.copyInputStream(ds.getInputStream(), baos);
ByteArrayDataSource bads = new ByteArrayDataSource(baos.toByteArray(), ds.getContentType());
bads.setName(ds.getName());
newAttachments.put(name, bads);
}
}
attachments = newAttachments;
}