Search in sources :

Example 6 with JobTO

use of org.apache.syncope.common.lib.to.JobTO in project syncope by apache.

the class TaskLogic method getJob.

@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
@Override
public JobTO getJob(final String key) {
    Task task = taskDAO.find(key);
    if (task == null) {
        throw new NotFoundException("Task " + key);
    }
    JobTO jobTO = null;
    try {
        jobTO = getJobTO(JobNamer.getJobKey(task));
    } catch (SchedulerException e) {
        LOG.error("Problems while retrieving scheduled job {}", JobNamer.getJobKey(task), e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add(e.getMessage());
        throw sce;
    }
    if (jobTO == null) {
        throw new NotFoundException("Job for task " + key);
    }
    return jobTO;
}
Also used : NotificationTask(org.apache.syncope.core.persistence.api.entity.task.NotificationTask) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) Task(org.apache.syncope.core.persistence.api.entity.task.Task) SchedulerException(org.quartz.SchedulerException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) JobTO(org.apache.syncope.common.lib.to.JobTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 7 with JobTO

use of org.apache.syncope.common.lib.to.JobTO in project syncope by apache.

the class AbstractJobLogic method getJobTO.

protected JobTO getJobTO(final JobKey jobKey) throws SchedulerException {
    JobTO jobTO = null;
    Triple<JobType, String, String> reference = getReference(jobKey);
    if (reference != null) {
        jobTO = new JobTO();
        jobTO.setType(reference.getLeft());
        jobTO.setRefKey(reference.getMiddle());
        jobTO.setRefDesc(reference.getRight());
        List<? extends Trigger> jobTriggers = scheduler.getScheduler().getTriggersOfJob(jobKey);
        if (jobTriggers.isEmpty()) {
            jobTO.setScheduled(false);
        } else {
            jobTO.setScheduled(true);
            jobTO.setStart(jobTriggers.get(0).getStartTime());
        }
        jobTO.setRunning(jobManager.isRunning(jobKey));
        jobTO.setStatus("UNKNOWN");
        if (jobTO.isRunning()) {
            try {
                Object job = ApplicationContextProvider.getBeanFactory().getBean(jobKey.getName());
                if (job instanceof AbstractInterruptableJob && ((AbstractInterruptableJob) job).getDelegate() != null) {
                    jobTO.setStatus(((AbstractInterruptableJob) job).getDelegate().currentStatus());
                }
            } catch (NoSuchBeanDefinitionException e) {
                LOG.warn("Could not find job {} implementation", jobKey, e);
            }
        }
    }
    return jobTO;
}
Also used : JobType(org.apache.syncope.common.lib.types.JobType) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) JobTO(org.apache.syncope.common.lib.to.JobTO) AbstractInterruptableJob(org.apache.syncope.core.provisioning.java.job.AbstractInterruptableJob)

Aggregations

JobTO (org.apache.syncope.common.lib.to.JobTO)7 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ArrayList (java.util.ArrayList)2 JobActionPanel (org.apache.syncope.client.console.widgets.JobActionPanel)2 PushTaskTO (org.apache.syncope.common.lib.to.PushTaskTO)2 SchedTaskTO (org.apache.syncope.common.lib.to.SchedTaskTO)2 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)2 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 IModel (org.apache.wicket.model.IModel)2 Model (org.apache.wicket.model.Model)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 SchedulerException (org.quartz.SchedulerException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Response (javax.ws.rs.core.Response)1 Input (org.apache.syncope.client.cli.Input)1 CommandUtils (org.apache.syncope.client.cli.util.CommandUtils)1