if (task == null) {
throw new NotFoundException("Task " + taskId);
}
TaskUtil taskUtil = TaskUtil.getInstance(task);
TaskExecTO result = null;
switch (taskUtil.getType()) {
case PROPAGATION:
final TaskExec propExec = taskExecutor.execute((PropagationTask) task);
result = binder.getTaskExecTO(propExec);
break;
case NOTIFICATION:
final TaskExec notExec = notificationJob.executeSingle((NotificationTask) task);
result = binder.getTaskExecTO(notExec);
break;
case SCHEDULED:
case SYNCHRONIZATION:
case PUSH:
try {
jobInstanceLoader.registerJob(task,
((SchedTask) task).getJobClassName(),
((SchedTask) task).getCronExpression());
JobDataMap map = new JobDataMap();
map.put(AbstractTaskJob.DRY_RUN_JOBDETAIL_KEY, dryRun);
scheduler.getScheduler().triggerJob(
new JobKey(JobInstanceLoader.getJobName(task), Scheduler.DEFAULT_GROUP), map);
} catch (Exception e) {
LOG.error("While executing task {}", task, e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
result = new TaskExecTO();
result.setTask(taskId);
result.setStartDate(new Date());
result.setStatus("JOB_FIRED");
result.setMessage("Job fired; waiting for results...");
break;
default:
}