@PreAuthorize("hasRole('REPORT_EXECUTE')")
@RequestMapping(method = RequestMethod.POST, value = "/execute/{reportId}")
public ReportExecTO execute(@PathVariable("reportId") final Long reportId) throws NotFoundException {
Report report = reportDAO.find(reportId);
if (report == null) {
throw new NotFoundException("Report " + reportId);
}
try {
jobInstanceLoader.registerJob(report);
JobDataMap map = new JobDataMap();
scheduler.getScheduler().triggerJob(JobInstanceLoader.getJobName(report), Scheduler.DEFAULT_GROUP, map);
auditManager.audit(Category.report, ReportSubCategory.execute, Result.success,
"Successfully started execution for report: " + report.getId());
} catch (Exception e) {
LOG.error("While executing report {}", report, e);
auditManager.audit(Category.report, ReportSubCategory.execute, Result.failure,
"Could not start execution for report: " + report.getId(), e);
SyncopeClientCompositeErrorException scce =
new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
sce.addElement(e.getMessage());