use of org.openlmis.stockmanagement.exception.JasperReportViewException in project openlmis-stockmanagement by OpenLMIS.
the class JasperReportService method saveAndGetUrl.
private String saveAndGetUrl(JasperReport report, String templateName) throws IOException {
File reportTempFile;
try {
reportTempFile = createTempFile(templateName, ".jasper");
} catch (IOException ex) {
throw new JasperReportViewException(ERROR_JASPER_FILE_CREATION, ex);
}
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
out.writeObject(report);
writeByteArrayToFile(reportTempFile, bos.toByteArray());
return reportTempFile.toURI().toURL().toString();
}
}
Aggregations