use of com.evolveum.midpoint.task.api.TaskException in project midpoint by Evolveum.
the class ActivityBasedTaskRun method run.
@NotNull
@Override
public TaskRunResult run(OperationResult result) throws TaskException {
try {
activityTree = ActivityTree.create(getRootTask(), getBeans());
localRootPath = ActivityStateUtil.getLocalRootPath(runningTask.getWorkState());
localRootActivity = activityTree.getActivity(localRootPath);
localRootActivity.setLocalRoot(true);
} catch (CommonException e) {
throw new TaskException("Couldn't initialize activity tree", FATAL_ERROR, PERMANENT_ERROR, e);
}
if (localRootActivity.isSkipped()) {
LOGGER.trace("Local root activity is skipped, exiting");
return TaskRunResult.createNotApplicableTaskRunResult();
}
logStart();
try {
if (isRootRun()) {
setupTaskArchetypeIfNeeded(result);
updateStateOnRootRunStart(result);
}
AbstractActivityRun<?, ?, ?> localRootRun = localRootActivity.createRun(this, result);
ActivityRunResult runResult = localRootRun.run(result);
if (isRootRun()) {
updateStateOnRootRunEnd(runResult, result);
}
logEnd(localRootRun, runResult);
return runResult.createTaskRunResult();
} catch (ActivityRunException e) {
// These should be only really unexpected ones. So we won't bother with e.g. updating the tree state.
logException(e);
throw e.toTaskException();
} catch (Throwable t) {
logException(t);
throw t;
}
}
Aggregations