Search in sources :

Example 6 with TaskUtils

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);
}
Also used : TaskUtils(org.apache.syncope.core.persistence.api.entity.task.TaskUtils) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SchedulerException(org.quartz.SchedulerException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)6 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)6 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)6 TaskUtils (org.apache.syncope.core.persistence.api.entity.task.TaskUtils)6 NotificationTask (org.apache.syncope.core.persistence.api.entity.task.NotificationTask)4 Task (org.apache.syncope.core.persistence.api.entity.task.Task)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 SchedulerException (org.quartz.SchedulerException)3 ExecTO (org.apache.syncope.common.lib.to.ExecTO)2 TaskExec (org.apache.syncope.core.persistence.api.entity.task.TaskExec)2 Date (java.util.Date)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 NotificationTaskTO (org.apache.syncope.common.lib.to.NotificationTaskTO)1 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)1 ProvisioningTaskTO (org.apache.syncope.common.lib.to.ProvisioningTaskTO)1 PullTaskTO (org.apache.syncope.common.lib.to.PullTaskTO)1 PushTaskTO (org.apache.syncope.common.lib.to.PushTaskTO)1 SchedTaskTO (org.apache.syncope.common.lib.to.SchedTaskTO)1 TaskTO (org.apache.syncope.common.lib.to.TaskTO)1