use of com.adobe.acs.commons.mcp.model.impl.ArchivedProcessFailure in project acs-aem-commons by Adobe-Consulting-Services.
the class ProcessErrorReportExcelServletTest method addFailure.
private void addFailure(String path, String error, String stacktrace) {
ArchivedProcessFailure fail = new ArchivedProcessFailure();
fail.error = error;
fail.nodePath = path;
fail.time = new Date();
fail.stackTrace = stacktrace;
failures.add(fail);
}
use of com.adobe.acs.commons.mcp.model.impl.ArchivedProcessFailure in project acs-aem-commons by Adobe-Consulting-Services.
the class ProcessErrorReportExcelServlet method createSpreadsheet.
@SuppressWarnings("squid:S3776")
protected Workbook createSpreadsheet(ManagedProcess report) {
Workbook wb = new XSSFWorkbook();
String name = report.getName();
for (char ch : new char[] { '\\', '/', '*', '[', ']', ':', '?' }) {
name = StringUtils.remove(name, ch);
}
Sheet sheet = wb.createSheet(name);
sheet.createFreezePane(0, 1, 0, 1);
Row headerRow = sheet.createRow(0);
CellStyle headerStyle = createHeaderStyle(wb);
CellStyle dateStyle = wb.createCellStyle();
CreationHelper createHelper = wb.getCreationHelper();
dateStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyy/mm/dd h:mm:ss"));
for (String columnName : Arrays.asList("Time", "Path", "Error", "Stack trace")) {
Cell headerCell = headerRow.createCell(headerRow.getPhysicalNumberOfCells());
headerCell.setCellValue(columnName);
headerCell.setCellStyle(headerStyle);
}
Collection<ArchivedProcessFailure> rows = report.getReportedErrors();
// make rows, don't forget the header row
for (ArchivedProcessFailure error : rows) {
Row row = sheet.createRow(sheet.getPhysicalNumberOfRows());
Cell c;
c = row.createCell(0);
c.setCellValue(error.time);
c.setCellStyle(dateStyle);
c = row.createCell(1);
c.setCellValue(error.nodePath);
c = row.createCell(2);
c.setCellValue(error.error);
c = row.createCell(3);
c.setCellValue(error.stackTrace);
}
autosize(sheet, 4);
sheet.setAutoFilter(new CellRangeAddress(0, 1 + rows.size(), 0, 3));
return wb;
}
Aggregations