@PreAuthorize("hasRole('" + StandardEntitlement.TASK_LIST + "')") @Override public List<ExecTO> listRecentExecutions(final int max) { return taskExecDAO.findRecent(max).stream(). map(taskExec -> binder.getExecTO(taskExec)).collect(Collectors.toList()); }
try { final Task task = taskDAO.find(key); return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), false); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore);
switch (taskUtil.getType()) { case PROPAGATION: PropagationTaskTO taskTO = binder.<PropagationTaskTO>getTaskTO(task, taskUtil, false); PropagationTaskInfo taskInfo = new PropagationTaskInfo(); taskInfo.setKey(taskTO.getKey()); result = binder.getExecTO(propExec); break; result = binder.getExecTO(notExec); break; result.setJobType(JobType.TASK); result.setRefKey(task.getKey()); result.setRefDesc(binder.buildRefDesc(task)); result.setStart(new Date()); result.setStatus("JOB_FIRED");
@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); }
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_UPDATE + "')") public <T extends SchedTaskTO> T updateSchedTask(final TaskType type, final SchedTaskTO taskTO) { SchedTask task = taskDAO.find(taskTO.getKey()); if (task == null) { throw new NotFoundException("Task " + taskTO.getKey()); } TaskUtils taskUtils = taskUtilsFactory.getInstance(task); if (taskUtils.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + taskUtils.getType()); throw sce; } binder.updateSchedTask(task, 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); }
@Override protected Triple<JobType, String, String> getReference(final JobKey jobKey) { String key = JobNamer.getTaskKeyFromJobName(jobKey.getName()); Task task = taskDAO.find(key); return task == null || !(task instanceof SchedTask) ? null : Triple.of(JobType.TASK, key, binder.buildRefDesc(task)); }
result.setJobType(JobType.TASK); result.setRefKey(task.getKey()); result.setRefDesc(taskDataBinder.buildRefDesc(task)); result.setStart(new Date()); result.setStatus("JOB_FIRED");
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')") @Override public Pair<Integer, List<ExecTO>> listExecutions( final String key, final int page, final int size, final List<OrderByClause> orderByClauses) { Task task = taskDAO.find(key); if (task == null) { throw new NotFoundException("Task " + key); } Integer count = taskExecDAO.count(key); List<ExecTO> result = taskExecDAO.findAll(task, page, size, orderByClauses).stream(). map(taskExec -> binder.getExecTO(taskExec)).collect(Collectors.toList()); return Pair.of(count, result); }
type, resourceDAO.find(resource), notificationDAO.find(notification), anyTypeKind, entityKey, page, size, orderByClauses).stream(). <T>map(task -> binder.getTaskTO(task, taskUtilsFactory.getInstance(type), details)). collect(Collectors.toList());
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')") @Override public ExecTO deleteExecution(final String execKey) { TaskExec taskExec = taskExecDAO.find(execKey); if (taskExec == null) { throw new NotFoundException("Task execution " + execKey); } ExecTO taskExecutionToDelete = binder.getExecTO(taskExec); taskExecDAO.delete(taskExec); return taskExecutionToDelete; }
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')") @Transactional(readOnly = true) public <T extends TaskTO> T read(final TaskType type, final String key, final boolean details) { Task task = taskDAO.find(key); if (task == null) { throw new NotFoundException("Task " + key); } TaskUtils taskUtils = taskUtilsFactory.getInstance(task); if (type != null && taskUtils.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + taskUtils.getType()); throw sce; } return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), details); }
ExecTO execTO = taskDataBinder.getExecTO(execution); notificationManager.createTasks( AuthContextUtils.getUsername(),
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')") public <T extends TaskTO> T delete(final TaskType type, final String key) { Task task = taskDAO.find(key); if (task == null) { throw new NotFoundException("Task " + key); } TaskUtils taskUtils = taskUtilsFactory.getInstance(task); if (type != null && taskUtils.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + taskUtils.getType()); throw sce; } T taskToDelete = binder.getTaskTO(task, taskUtils, true); if (TaskType.SCHEDULED == taskUtils.getType() || TaskType.PULL == taskUtils.getType() || TaskType.PUSH == taskUtils.getType()) { jobManager.unregister(task); } taskDAO.delete(task); return taskToDelete; }