use of eu.bcvsolutions.idm.core.scheduler.api.exception.DryRunNotSupportedException in project CzechIdMng by bcvsolutions.
the class DefaultSchedulerManager method createTrigger.
@Override
public AbstractTaskTrigger createTrigger(String taskId, AbstractTaskTrigger trigger, boolean dryRun) {
Assert.notNull(taskId);
Assert.notNull(trigger);
//
// task has to support dry run mode
Task task = getTask(taskId);
Assert.notNull(task);
if (dryRun && !task.isSupportsDryRun()) {
throw new DryRunNotSupportedException(task.getTaskType().getCanonicalName());
}
//
String triggerId = Key.createUniqueName(taskId);
trigger.setId(triggerId);
trigger.setTaskId(taskId);
// TODO use of visitor pattern may be good
if (trigger instanceof CronTaskTrigger) {
createTriggerInternal(taskId, (CronTaskTrigger) trigger, dryRun);
} else if (trigger instanceof SimpleTaskTrigger) {
createTriggerInternal(taskId, (SimpleTaskTrigger) trigger, dryRun);
} else if (trigger instanceof DependentTaskTrigger) {
createTriggerInternal(taskId, (DependentTaskTrigger) trigger);
} else {
throw new SchedulerException(CoreResultCode.SCHEDULER_UNSUPPORTED_TASK_TRIGGER, ImmutableMap.of("trigger", trigger.getClass()));
}
return trigger;
}
use of eu.bcvsolutions.idm.core.scheduler.api.exception.DryRunNotSupportedException in project CzechIdMng by bcvsolutions.
the class AbstractSchedulableStatefulExecutor method processCandidate.
private void processCandidate(DTO candidate, boolean dryRun) {
if (isInProcessedQueue(candidate)) {
// item was processed earlier - just drop the count by one
--count;
return;
}
Optional<OperationResult> result;
if (dryRun) {
if (!supportsDryRun()) {
throw new DryRunNotSupportedException(getName());
}
// dry run mode - operation is not executed with dry run code (no content)
result = Optional.of(new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(new DefaultResultModel(CoreResultCode.DRY_RUN)).build());
} else {
result = this.processItem(candidate);
}
//
if (result.isPresent()) {
OperationResult opResult = result.get();
this.logItemProcessed(candidate, opResult);
if (OperationState.isSuccessful(opResult.getState())) {
++counter;
this.addToProcessedQueue(candidate, opResult);
}
LOG.debug("Statefull process [{}] intermediate result: [{}], count: [{}/{}]", getClass().getSimpleName(), opResult, count, counter);
} else {
++counter;
LOG.debug("Statefull process [{}] processed item [{}] without result.", getClass().getSimpleName(), candidate);
}
}
Aggregations