Search in sources :

Example 1 with JobType

use of org.apache.syncope.common.lib.types.JobType 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)1 JobType (org.apache.syncope.common.lib.types.JobType)1 AbstractInterruptableJob (org.apache.syncope.core.provisioning.java.job.AbstractInterruptableJob)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1