@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); }
@Override public String buildRefDesc(final Task task) { return taskUtilsFactory.getInstance(task).getType().name() + " " + "Task " + task.getKey() + " " + (task instanceof SchedTask ? SchedTask.class.cast(task).getName() : task instanceof PropagationTask ? PropagationTask.class.cast(task).getConnObjectKey() : StringUtils.EMPTY); }
try { final Task task = taskDAO.find(key); return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), false); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore);
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_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); }
@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; }
TaskUtils taskUtil = taskUtilsFactory.getInstance(task);