Package org.apache.syncope.core.persistence.beans

Examples of org.apache.syncope.core.persistence.beans.Task


            }
        }

        if (id != null) {
            try {
                final Task task = taskDAO.find(id);
                return binder.getTaskTO(task, getTaskUtil(task));
            } catch (Throwable ignore) {
                LOG.debug("Unresolved reference", ignore);
                throw new UnresolvedReferenceException(ignore);
            }
View Full Code Here


     * @return the same entity, updated
     */
    @Override
    @Transactional(rollbackFor = {Throwable.class})
    public void saveAndAdd(Long taskId, TaskExec execution) throws InvalidEntityException {
        Task task = taskDAO.find(taskId);
        task.addExec(execution);
        taskDAO.save(task);
    }
View Full Code Here

    @PreAuthorize("hasRole('TASK_READ')")
    @RequestMapping(method = RequestMethod.GET, value = "/read/{taskId}")
    public TaskTO read(@PathVariable("taskId") final Long taskId) throws NotFoundException {

        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        TaskUtil taskUtil = getTaskUtil(task);

        auditManager.audit(Category.task, TaskSubCategory.read, Result.success,
                "Successfully read task: " + task.getId() + "/" + taskUtil);

        return binder.getTaskTO(task, taskUtil);
    }
View Full Code Here

    @PreAuthorize("hasRole('TASK_EXECUTE')")
    @RequestMapping(method = RequestMethod.POST, value = "/execute/{taskId}")
    public TaskExecTO execute(@PathVariable("taskId") final Long taskId,
            @RequestParam(value = "dryRun", defaultValue = "false") final boolean dryRun) throws NotFoundException {

        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        TaskUtil taskUtil = getTaskUtil(task);

        TaskExecTO result = null;
        LOG.debug("Execution started for {}", task);
        switch (taskUtil) {
            case PROPAGATION:
                final TaskExec propExec = propagationManager.execute((PropagationTask) task);
                result = binder.getTaskExecTO(propExec);
                break;

            case NOTIFICATION:
                final TaskExec notExec = notificationManager.execute((NotificationTask) task);
                result = binder.getTaskExecTO(notExec);
                break;

            case SCHED:
            case SYNC:
                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(JobInstanceLoader.getJobName(task), Scheduler.DEFAULT_GROUP,
                            map);
                } catch (Exception e) {
                    LOG.error("While executing task {}", task, e);

                    auditManager.audit(Category.task, TaskSubCategory.execute, Result.failure,
                            "Could not start execution for task: " + task.getId() + "/" + taskUtil, e);

                    SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(
                            HttpStatus.BAD_REQUEST);
                    SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
                    sce.addElement(e.getMessage());
                    scce.addException(sce);
                    throw scce;
                }

                result = new TaskExecTO();
                result.setTask(taskId);
                result.setStartDate(new Date());
                result.setStatus("JOB_FIRED");
                result.setMessage("Job fired; waiting for results...");
                break;

            default:
        }
        LOG.debug("Execution finished for {}, {}", task, result);

        auditManager.audit(Category.task, TaskSubCategory.execute, Result.success,
                "Successfully started execution for task: " + task.getId() + "/" + taskUtil);

        return result;
    }
View Full Code Here

    @PreAuthorize("hasRole('TASK_DELETE')")
    @RequestMapping(method = RequestMethod.GET, value = "/delete/{taskId}")
    public TaskTO delete(@PathVariable("taskId") final Long taskId)
            throws NotFoundException, SyncopeClientCompositeErrorException {

        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        TaskUtil taskUtil = getTaskUtil(task);
       
        TaskTO taskToDelete = binder.getTaskTO(task, taskUtil);

        if (TaskUtil.SCHED == taskUtil || TaskUtil.SYNC == taskUtil) {
            jobInstanceLoader.unregisterJob(task);
        }

        taskDAO.delete(task);

        auditManager.audit(Category.task, TaskSubCategory.delete, Result.success,
                "Successfully deleted task: " + task.getId() + "/" + taskUtil);
       
        return taskToDelete;
    }
View Full Code Here

        return classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.PUSH_ACTIONS);
    }

    @PreAuthorize("hasRole('TASK_READ')")
    public <T extends AbstractTaskTO> T read(final Long taskId) {
        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        return binder.getTaskTO(task, TaskUtil.getInstance(task));
    }
View Full Code Here

        return binder.getTaskExecTO(taskExec);
    }

    @PreAuthorize("hasRole('TASK_EXECUTE')")
    public TaskExecTO execute(final Long taskId, final boolean dryRun) {
        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        TaskUtil taskUtil = TaskUtil.getInstance(task);
View Full Code Here

        return binder.getTaskExecTO(taskExecDAO.save(exec));
    }

    @PreAuthorize("hasRole('TASK_DELETE')")
    public <T extends AbstractTaskTO> T delete(final Long taskId) {
        Task task = taskDAO.find(taskId);
        if (task == null) {
            throw new NotFoundException("Task " + taskId);
        }
        TaskUtil taskUtil = TaskUtil.getInstance(task);
View Full Code Here

            }
        }

        if (id != null) {
            try {
                final Task task = taskDAO.find(id);
                return binder.getTaskTO(task, TaskUtil.getInstance(task));
            } catch (Throwable ignore) {
                LOG.debug("Unresolved reference", ignore);
                throw new UnresolvedReferenceException(ignore);
            }
View Full Code Here

     * @throws InvalidEntityException if any bean validation fails
     */
    @Override
    @Transactional(rollbackFor = { Throwable.class })
    public void saveAndAdd(final Long taskId, final TaskExec execution) throws InvalidEntityException {
        Task task = taskDAO.find(taskId);
        task.addExec(execution);
        taskDAO.save(task);
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.