private DirectoryProvider directoryProvider;
public void deliverReport(ReportSchedule reportSchedule, ReportEngineOutput reportOutput) throws DeliveryException
{
Report report = reportSchedule.getReport();
ReportUser user = reportSchedule.getUser();
Date runDate = new Date();
String fileName = runDate.getTime() + "-"
+ StringUtils.deleteWhitespace(user.getName()) + "-"
+ StringUtils.deleteWhitespace(report.getName());
try
{
FileOutputStream file = new FileOutputStream(directoryProvider
.getReportGenerationDirectory()
+ fileName + reportOutput.getContentExtension());
file.write(reportOutput.getContent());
file.flush();
file.close();
}
catch(IOException ioe)
{
throw new DeliveryException(ioe);
}
DeliveredReport info = new DeliveredReport();
info.setParameters(reportSchedule.getReportParameters());
info.setReportDescription(reportSchedule.getScheduleDescription());
info.setReportName(report.getName());
info.setReportFileName(fileName + reportOutput.getContentExtension());
info.setRunDate(runDate);
info.setUserName(user.getName());
info.setDeliveryMethod("fileSystemDeliveryMethod");
try
{
FileOutputStream file = new FileOutputStream(directoryProvider.getReportGenerationDirectory() + fileName + ".xml");
XStream xStream = new XStream();
xStream.alias("reportGenerationInfo", DeliveredReport.class);
xStream.toXML(info, file);
file.flush();
file.close();
}
catch(IOException ioe)
{
throw new DeliveryException(ioe);
}
MailMessage mail = new MailMessage();
mail.setSender(user.getEmail());
mail.parseRecipients(reportSchedule.getRecipients());
mail.setText(report.getName() + ": Generated on " + new Date());
mail.setBounceAddress(reportSchedule.getDeliveryReturnAddress());
if (reportSchedule.getScheduleDescription() != null && reportSchedule.getScheduleDescription().trim().length() > 0)