use of com.adobe.acs.commons.mcp.model.ManagedProcess in project acs-aem-commons by Adobe-Consulting-Services.
the class ProcessErrorReportExcelServlet method doGet.
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
ManagedProcess report = request.getResource().adaptTo(ManagedProcess.class);
if (report != null) {
String title = report.getName();
String fileName = JcrUtil.createValidName(title) + ".xlsx";
Workbook workbook = createSpreadsheet(report);
response.setContentType("application/vnd.ms-excel");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
try (ServletOutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
} catch (Exception ex) {
LOG.error("Error generating excel export for " + request.getResource().getPath(), ex);
throw ex;
}
} else {
LOG.error("Unable to process report stored at " + request.getResource().getPath());
throw new ServletException("Unable to process report stored at " + request.getResource().getPath());
}
}
Aggregations