Search in sources :

Example 1 with CommonMockActivityHelper

use of com.evolveum.midpoint.repo.common.tasks.handlers.CommonMockActivityHelper in project midpoint by Evolveum.

the class SimpleMockActivityRun method runLocally.

@Override
@NotNull
protected ActivityRunResult runLocally(OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
    String message = activity.getWorkDefinition().getMessage();
    Operation operation = activityState.getLiveItemProcessingStatistics().recordOperationStart(new IterativeOperationStartInfo(new IterationItemInformation(message, null, null, null)));
    // to avoid wall clock time of 0 (failing throughput-assuming tests)
    MiscUtil.sleepCatchingInterruptedException(10);
    LOGGER.info("Message: {}", message);
    getRecorder().recordExecution(message);
    CommonMockActivityHelper helper = getActivityHandler().getMockHelper();
    helper.increaseExecutionCount(activityState, result);
    try {
        helper.failIfNeeded(this, activity.getWorkDefinition().getInitialFailures());
        QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.SUCCESS);
        operation.done(qualifiedOutcome, null);
        incrementProgress(qualifiedOutcome);
    } catch (Exception e) {
        QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.FAILURE);
        operation.done(qualifiedOutcome, e);
        incrementProgress(qualifiedOutcome);
        throw e;
    }
    return standardRunResult();
}
Also used : QualifiedItemProcessingOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType) CommonMockActivityHelper(com.evolveum.midpoint.repo.common.tasks.handlers.CommonMockActivityHelper) IterativeOperationStartInfo(com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo) Operation(com.evolveum.midpoint.schema.statistics.Operation) IterationItemInformation(com.evolveum.midpoint.schema.statistics.IterationItemInformation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CommonMockActivityHelper (com.evolveum.midpoint.repo.common.tasks.handlers.CommonMockActivityHelper)1 IterationItemInformation (com.evolveum.midpoint.schema.statistics.IterationItemInformation)1 IterativeOperationStartInfo (com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo)1 Operation (com.evolveum.midpoint.schema.statistics.Operation)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 QualifiedItemProcessingOutcomeType (com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType)1 NotNull (org.jetbrains.annotations.NotNull)1