Search in sources :

Example 1 with ImplementationDAO

use of org.apache.syncope.core.persistence.api.dao.ImplementationDAO in project syncope by apache.

the class TaskJob method execute.

@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
    try {
        AuthContextUtils.execWithAuthContext(context.getMergedJobDataMap().getString(JobManager.DOMAIN_KEY), () -> {
            try {
                ImplementationDAO implementationDAO = ApplicationContextProvider.getApplicationContext().getBean(ImplementationDAO.class);
                Implementation implementation = implementationDAO.find(context.getMergedJobDataMap().getString(DELEGATE_IMPLEMENTATION));
                if (implementation == null) {
                    LOG.error("Could not find Implementation '{}', aborting", context.getMergedJobDataMap().getString(DELEGATE_IMPLEMENTATION));
                } else {
                    delegate = ImplementationManager.<SchedTaskJobDelegate>build(implementation);
                    delegate.execute(taskKey, context.getMergedJobDataMap().getBoolean(DRY_RUN_JOBDETAIL_KEY), context);
                }
            } catch (Exception e) {
                LOG.error("While executing task {}", taskKey, e);
                throw new RuntimeException(e);
            }
            return null;
        });
    } catch (RuntimeException e) {
        LOG.error("While executing task {}", taskKey, e);
        throw new JobExecutionException("While executing task " + taskKey, e);
    }
}
Also used : JobExecutionException(org.quartz.JobExecutionException) ImplementationDAO(org.apache.syncope.core.persistence.api.dao.ImplementationDAO) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

ImplementationDAO (org.apache.syncope.core.persistence.api.dao.ImplementationDAO)1 Implementation (org.apache.syncope.core.persistence.api.entity.Implementation)1 JobExecutionException (org.quartz.JobExecutionException)1