use of org.apache.syncope.core.persistence.api.entity.task.TaskUtils in project syncope by apache.
the class TaskLogic method createSchedTask.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_CREATE + "')")
public <T extends SchedTaskTO> T createSchedTask(final TaskType type, final T taskTO) {
TaskUtils taskUtils = taskUtilsFactory.getInstance(taskTO);
if (taskUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
throw sce;
}
SchedTask task = binder.createSchedTask(taskTO, taskUtils);
task = taskDAO.save(task);
try {
jobManager.register(task, task.getStartAt(), confDAO.find("tasks.interruptMaxRetries", 1L));
} catch (Exception e) {
LOG.error("While registering quartz job for task " + task.getKey(), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
return binder.getTaskTO(task, taskUtils, false);
}
Aggregations