Search in sources :

Example 1 with TaskException

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;
    }
}
Also used : TaskException(com.evolveum.midpoint.task.api.TaskException) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) ActivityRunResult(com.evolveum.midpoint.repo.common.activity.run.ActivityRunResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)1 ActivityRunResult (com.evolveum.midpoint.repo.common.activity.run.ActivityRunResult)1 TaskException (com.evolveum.midpoint.task.api.TaskException)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 NotNull (org.jetbrains.annotations.NotNull)1