use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException 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.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.
the class ActivityItemProcessingStatistics method updateStatisticsForSimpleClients.
/**
* Very ugly hack. We create our own operation result (!!).
*/
@Experimental
private void updateStatisticsForSimpleClients() {
try {
activityState.updateProgressAndStatisticsNoCommit();
if (System.currentTimeMillis() > lastStatisticsUpdatedForSimpleClients + STATISTICS_UPDATE_INTERVAL) {
lastStatisticsUpdatedForSimpleClients = System.currentTimeMillis();
activityState.flushPendingTaskModificationsChecked(new OperationResult(OP_UPDATE_STATISTICS_FOR_SIMPLE_CLIENT));
}
} catch (ActivityRunException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't update statistics for a simple client in {}", e, this);
}
}
use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.
the class CurrentActivityState method initialize.
// region Initialization and closing
/**
* Puts the activity state into operation:
*
* 1. finds/creates activity and optionally also work state container values;
* 2. initializes live structures - currently that means progress and statistics objects.
*
* This method may or may not be called just before the real run. For example, there can be a need to initialize
* the state of all child activities before starting their real run.
*/
public void initialize(OperationResult result) throws ActivityRunException {
if (initialized) {
return;
}
try {
stateItemPath = findOrCreateActivityState(result);
updatePersistenceType(result);
if (activityRun.shouldCreateWorkStateOnInitialization()) {
createWorkStateIfNeeded(result);
}
liveProgress.initialize(getStoredProgress());
liveStatistics.initialize();
initialized = true;
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | RuntimeException e) {
// We consider all such exceptions permanent. There's basically nothing that could resolve "by itself".
throw new ActivityRunException("Couldn't initialize activity state for " + getActivity() + ": " + e.getMessage(), FATAL_ERROR, PERMANENT_ERROR, e);
}
}
use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.
the class ActivityBasedTaskRun method setupTaskArchetypeIfNeeded.
private void setupTaskArchetypeIfNeeded(OperationResult result) throws ActivityRunException {
if (activityBasedTaskHandler.isAvoidAutoAssigningArchetypes()) {
return;
}
try {
RunningTask task = getRunningTask();
String defaultArchetypeOid = activityTree.getRootActivity().getHandler().getDefaultArchetypeOid();
if (defaultArchetypeOid != null) {
task.addArchetypeInformationIfMissing(defaultArchetypeOid);
task.flushPendingModifications(result);
}
} catch (CommonException e) {
throw new ActivityRunException("Couldn't setup the task archetype", FATAL_ERROR, PERMANENT_ERROR, e);
}
}
Aggregations