ReportingResourcesSupplier supplier = new ReportingResourcesSupplier();
String template;
try {
template = supplier.getReportResources(null, templateName);
} catch (ReportingException e) {
throw new ReportingException("Failed get template " + templateName, e);
}
JasperPrintProvider jasperPrintProvider = new JasperPrintProvider();
ReportDataSourceManager reportDataSourceManager = new ReportDataSourceManager();
Connection connection;
if (template != null) {
connection = reportDataSourceManager.getJDBCConnection(dataSourceName);
} else {
throw new ReportingException("empty report template found :" + templateName);
}
JasperPrint jasperPrint;
if (connection != null) {
try {
jasperPrint = jasperPrintProvider.createJasperPrint(connection, template, reportParamMap);
} catch (JRException e) {
throw new JRException("Can't create JasperPrint Object from " + templateName, e);
}
} else {
throw new ReportingException("valid data source not found " + dataSourceName);
}
ReportStream reportStream = new ReportStream();
if (reportType != null) {
byteArrayOutputStream = reportStream.getReportStream(jasperPrint, reportType);
} else {
throw new ReportingException("valid report type not found : " + reportType);
}
if (byteArrayOutputStream != null) {
reportBytes = byteArrayOutputStream.toByteArray();
}