processTask.setReport(bodyReport);
if (processTask instanceof MultiStreamReportProcessTask)
{
final MultiStreamReportProcessTask mtask = (MultiStreamReportProcessTask) processTask;
mtask.setBulkLocation(mtask.getBodyContentLocation());
mtask.setBulkNameGenerator(new DefaultNameGenerator(mtask.getBodyContentLocation(), "data"));
mtask.setUrlRewriter(new MailURLRewriter());
}
processTask.run();
if (processTask.isTaskSuccessful() == false)
{
if (processTask.isTaskAborted())
{
logger.info("EMail Task received interrupt.");
return null;
}
else
{
logger.info("EMail Task failed:", processTask.getError());
throw new ReportProcessingException("EMail Task failed", processTask.getError());
}
}
final EmailRepository repository = new EmailRepository(session);
final MimeBodyPart messageBodyPart = repository.getBodypart();
final ByteArrayDataSource dataSource = new ByteArrayDataSource(bout.toByteArray(), processTask.getReportMimeType());
messageBodyPart.setDataHandler(new DataHandler(dataSource));
final int attachmentsSize = mailDefinition.getAttachmentCount();
for (int i = 0; i < attachmentsSize; i++)
{
final MasterReport report = mailDefinition.getAttachmentReport(i);
final String type = mailDefinition.getAttachmentType(i);
final ContentLocation location = repository.getRoot();
final ContentLocation bulkLocation = location.createLocation("attachment-" + i);
final ReportProcessTask attachmentProcessTask = registry.createProcessTask(type);
attachmentProcessTask.setBodyContentLocation(bulkLocation);
attachmentProcessTask.setBodyNameGenerator(new DefaultNameGenerator(bulkLocation, "report"));
attachmentProcessTask.setReport(report);
if (attachmentProcessTask instanceof MultiStreamReportProcessTask)
{
final MultiStreamReportProcessTask mtask = (MultiStreamReportProcessTask) attachmentProcessTask;
mtask.setBulkLocation(bulkLocation);
mtask.setBulkNameGenerator(new DefaultNameGenerator(bulkLocation, "data"));
mtask.setUrlRewriter(new MailURLRewriter());
}
attachmentProcessTask.run();
if (attachmentProcessTask.isTaskSuccessful() == false)