Search in sources :

Example 1 with InvalidCronExpressionException

use of eu.bcvsolutions.idm.core.scheduler.exception.InvalidCronExpressionException in project CzechIdMng by bcvsolutions.

the class DefaultSchedulerManager method createTriggerInternal.

private void createTriggerInternal(String taskId, CronTaskTrigger trigger, boolean dryRun) {
    CronTaskTrigger cronTaskTrigger = (CronTaskTrigger) trigger;
    CronScheduleBuilder cronBuilder;
    try {
        cronBuilder = CronScheduleBuilder.cronSchedule(cronTaskTrigger.getCron()).withMisfireHandlingInstructionDoNothing().inTimeZone(TimeZone.getDefault());
    } catch (RuntimeException ex) {
        throw new InvalidCronExpressionException(cronTaskTrigger.getCron(), ex);
    }
    // 
    try {
        scheduler.scheduleJob(TriggerBuilder.newTrigger().withIdentity(trigger.getId(), taskId).forJob(getKey(taskId)).withDescription(cronTaskTrigger.getDescription()).withSchedule(cronBuilder).usingJobData(SchedulableTaskExecutor.PARAMETER_DRY_RUN, dryRun).startNow().build());
    } catch (org.quartz.SchedulerException ex) {
        throw new SchedulerException(CoreResultCode.SCHEDULER_CREATE_TRIGGER_FAILED, ex);
    }
}
Also used : CronScheduleBuilder(org.quartz.CronScheduleBuilder) SchedulerException(eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException) InvalidCronExpressionException(eu.bcvsolutions.idm.core.scheduler.exception.InvalidCronExpressionException) CronTaskTrigger(eu.bcvsolutions.idm.core.scheduler.api.dto.CronTaskTrigger)

Aggregations

CronTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.CronTaskTrigger)1 InvalidCronExpressionException (eu.bcvsolutions.idm.core.scheduler.exception.InvalidCronExpressionException)1 SchedulerException (eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException)1 CronScheduleBuilder (org.quartz.CronScheduleBuilder)1