use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class PageAttorneySelection method getAttorneySelectionQuery.
private ObjectQuery getAttorneySelectionQuery() {
ModelInteractionService service = getModelInteractionService();
Task task = createSimpleTask(OPERATION_GET_DONOR_FILTER);
try {
ObjectQuery query = PageAttorneySelection.this.getPrismContext().queryFactory().createQuery();
// todo target authorization action
ObjectFilter filter = service.getDonorFilter(UserType.class, null, null, task, task.getResult());
query.addFilter(filter);
return query;
} catch (CommonException ex) {
LOGGER.error("Couldn't get donor filter, reason: {}", ex.getMessage());
LOGGER.debug("Couldn't get donor filter", ex);
PageError error = new PageError(ex);
throw new RestartResponseException(error);
}
}
use of com.evolveum.midpoint.util.exception.CommonException 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;
}
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class ActivityTreePurger method purge.
/**
* Purges state (including task-level stats) from current task and its subtasks. Deletes subtasks if possible.
*
* * Pre: task is an execution root
* * Post: task is refreshed
*/
public void purge(OperationResult result) throws ActivityRunException {
try {
boolean canDeleteRoot = purgeInTasksRecursively(ActivityPath.empty(), taskRun.getRunningTask(), result);
if (canDeleteRoot) {
taskRun.getRunningTask().restartCollectingStatisticsFromZero();
taskRun.getRunningTask().updateAndStoreStatisticsIntoRepository(true, result);
}
} catch (CommonException e) {
throw new ActivityRunException("Couldn't purge activity tree state", FATAL_ERROR, PERMANENT_ERROR, e);
}
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class AbstractActivityRun method updateAndCloseActivityState.
/**
* Updates the activity state with the result of the run.
* Stores also the live values of progress/statistics into the current task.
*/
private void updateAndCloseActivityState(ActivityRunResult runResult, OperationResult result) throws ActivityRunException {
activityState.updateProgressAndStatisticsNoCommit();
completeRunResult(runResult);
OperationResultStatus currentResultStatus = runResult.getOperationResultStatus();
if (runResult.isFinished()) {
// Note the asymmetry: "in progress" (IN_PROGRESS_LOCAL, IN_PROGRESS_DISTRIBUTED, IN_PROGRESS_DELEGATED)
// states, along with the timestamp, are written in subclasses. The "complete" state, along with the timestamp,
// is written here.
activityState.markComplete(currentResultStatus, endTimestamp);
} else if (currentResultStatus != null && currentResultStatus != activityState.getResultStatus()) {
activityState.setResultStatus(currentResultStatus);
}
try {
getRunningTask().updateAndStoreStatisticsIntoRepository(true, // Contains implicit task flush
result);
} catch (CommonException e) {
throw new ActivityRunException("Couldn't update task when updating and closing activity state", FATAL_ERROR, PERMANENT_ERROR, e);
}
activityState.close();
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class TaskActivityManager method deleteState.
private void deleteState(TaskType task, ActivityPath activityPath, OperationResult result) {
try {
TaskActivityStateType taskActivityState = task.getActivityState();
ItemPath stateItemPath = ActivityStateUtil.getStateItemPath(taskActivityState, activityPath);
List<ItemDelta<?, ?>> itemDeltas;
if (activityPath.equals(ActivityStateUtil.getLocalRootPath(taskActivityState))) {
// This is the [local] root activity. Delete everything!
itemDeltas = PrismContext.get().deltaFor(TaskType.class).item(TaskType.F_ACTIVITY_STATE).replace().asItemDeltas();
} else {
Long id = ItemPath.toId(stateItemPath.last());
assert id != null;
itemDeltas = PrismContext.get().deltaFor(TaskType.class).item(stateItemPath.allExceptLast()).delete(new ActivityStateType().id(id)).asItemDeltas();
}
plainRepositoryService.modifyObject(TaskType.class, task.getOid(), itemDeltas, result);
LOGGER.info("Deleted activity state for '{}' in {}", activityPath, task);
} catch (CommonException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete state for activity path '{}' in {}", e, activityPath, task);
}
}
Aggregations