Search in sources :

Example 1 with GenericReport

use of com.adobe.acs.commons.mcp.model.GenericReport in project acs-aem-commons by Adobe-Consulting-Services.

the class PageRelocator method storeReport.

@Override
public void storeReport(ProcessInstance instance, ResourceResolver rr) throws RepositoryException, PersistenceException {
    GenericReport report = new GenericReport();
    report.setRows(reportData, "Source", Report.class);
    report.persist(rr, instance.getPath() + "/jcr:content/report");
}
Also used : GenericReport(com.adobe.acs.commons.mcp.model.GenericReport)

Example 2 with GenericReport

use of com.adobe.acs.commons.mcp.model.GenericReport in project acs-aem-commons by Adobe-Consulting-Services.

the class GenericReportExcelServlet method doGet.

@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
    GenericReport report = request.getResource().adaptTo(GenericReport.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());
    }
}
Also used : ServletException(javax.servlet.ServletException) GenericReport(com.adobe.acs.commons.mcp.model.GenericReport) ServletOutputStream(javax.servlet.ServletOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 3 with GenericReport

use of com.adobe.acs.commons.mcp.model.GenericReport in project acs-aem-commons by Adobe-Consulting-Services.

the class BrokenLinksReport method storeReport.

@Override
public void storeReport(ProcessInstance instance, ResourceResolver rr) throws RepositoryException, PersistenceException {
    GenericReport genericReport = new GenericReport();
    genericReport.setRows(reportData, "Source", Report.class);
    genericReport.persist(rr, instance.getPath() + "/jcr:content/report");
}
Also used : GenericReport(com.adobe.acs.commons.mcp.model.GenericReport)

Aggregations

GenericReport (com.adobe.acs.commons.mcp.model.GenericReport)3 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1