use of org.apache.syncope.common.lib.types.ReportExecExportFormat in project syncope by apache.
the class ReportSyncopeOperations method exportExecutionResult.
public String exportExecutionResult(final String executionKey, final String reportExecExportFormat) throws Exception {
ReportExecExportFormat format = ReportExecExportFormat.valueOf(reportExecExportFormat);
SequenceInputStream report = (SequenceInputStream) reportService.exportExecutionResult(executionKey, format).getEntity();
String fileName = "export_" + executionKey;
OutputStream os = null;
switch(format) {
case XML:
fileName += ".xml";
XMLUtils.createXMLFile(report, fileName);
break;
case CSV:
fileName += ".csv";
os = Files.newOutputStream(Paths.get(fileName));
IOUtils.copyAndCloseInput(report, os);
break;
case PDF:
fileName += ".pdf";
os = Files.newOutputStream(Paths.get(fileName));
IOUtils.copyAndCloseInput(report, os);
break;
case HTML:
fileName += ".html";
os = Files.newOutputStream(Paths.get(fileName));
IOUtils.copyAndCloseInput(report, os);
break;
case RTF:
fileName += ".rtf";
os = Files.newOutputStream(Paths.get(fileName));
IOUtils.copyAndCloseInput(report, os);
break;
default:
return format + " not supported";
}
if (os != null) {
os.close();
}
return fileName;
}
use of org.apache.syncope.common.lib.types.ReportExecExportFormat in project syncope by apache.
the class ReportServiceImpl method exportExecutionResult.
@Override
public Response exportExecutionResult(final String executionKey, final ReportExecExportFormat fmt) {
ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML : fmt;
ReportExec reportExec = logic.getReportExec(executionKey);
StreamingOutput sout = (os) -> logic.exportExecutionResult(os, reportExec, format);
return Response.ok(sout).header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + reportExec.getReport().getName() + "." + format.name().toLowerCase()).build();
}
Aggregations