use of com.qcadoo.report.api.ReportException in project qcadoo by qcadoo.
the class ReportController method generateReportForEntity.
@RequestMapping(value = "generateReportForEntity/{templatePlugin}/{templateName}", method = RequestMethod.GET)
public void generateReportForEntity(@PathVariable("templatePlugin") final String templatePlugin, @PathVariable("templateName") final String templateName, @RequestParam("id") final List<Long> entityIds, @RequestParam("additionalArgs") final String requestAdditionalArgs, final HttpServletRequest request, final HttpServletResponse response, final Locale locale) throws ReportException {
ReportService.ReportType reportType = getReportType(request);
Map<String, String> additionalArgs = convertJsonStringToMap(requestAdditionalArgs);
response.setContentType(reportType.getMimeType());
try {
int bytes = copy(new ByteArrayInputStream(reportService.generateReportForEntity(templatePlugin, templateName, reportType, entityIds, additionalArgs, locale)), response.getOutputStream());
response.setContentLength(bytes);
} catch (IOException e) {
throw new ReportException(ReportException.Type.ERROR_WHILE_COPYING_REPORT_TO_RESPONSE, e);
}
disableCache(response);
}
Aggregations