Search in sources :

Example 6 with ActivityRunException

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);
    }
}
Also used : ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 7 with ActivityRunException

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);
    }
}
Also used : ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Experimental(com.evolveum.midpoint.util.annotation.Experimental)

Example 8 with ActivityRunException

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);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 9 with ActivityRunException

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

Aggregations

ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)9 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 NotNull (org.jetbrains.annotations.NotNull)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 NullSynchronizationObjectFilterImpl (com.evolveum.midpoint.model.impl.sync.tasks.NullSynchronizationObjectFilterImpl)1 ResourceObjectClass (com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)1 Synchronizer (com.evolveum.midpoint.model.impl.sync.tasks.Synchronizer)1 ActivityRunResult (com.evolveum.midpoint.repo.common.activity.run.ActivityRunResult)1 ActivityState (com.evolveum.midpoint.repo.common.activity.run.state.ActivityState)1 ImportController (com.evolveum.midpoint.report.impl.controller.ImportController)1 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 RunningTask (com.evolveum.midpoint.task.api.RunningTask)1 TaskException (com.evolveum.midpoint.task.api.TaskException)1 Experimental (com.evolveum.midpoint.util.annotation.Experimental)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 IOException (java.io.IOException)1