Search in sources :

Example 1 with ChangeProcessor

use of com.evolveum.midpoint.wf.impl.processors.ChangeProcessor in project midpoint by Evolveum.

the class WfHook method processModelInvocation.

private HookOperationMode processModelInvocation(@NotNull ModelContext<? extends ObjectType> modelContext, WfConfigurationType wfConfigurationType, @NotNull Task taskFromModel, @NotNull OperationResult result) {
    try {
        modelContext.reportProgress(new ProgressInformation(WORKFLOWS, ENTERING));
        for (ChangeProcessor changeProcessor : wfConfiguration.getChangeProcessors()) {
            LOGGER.trace("Trying change processor: {}", changeProcessor.getClass().getName());
            try {
                HookOperationMode hookOperationMode = changeProcessor.processModelInvocation(modelContext, wfConfigurationType, taskFromModel, result);
                if (hookOperationMode != null) {
                    return hookOperationMode;
                }
            } catch (ObjectNotFoundException | SchemaException | RuntimeException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Exception while running change processor {}", e, changeProcessor.getClass().getName());
                result.recordFatalError("Exception while running change processor " + changeProcessor.getClass(), e);
                return HookOperationMode.ERROR;
            }
        }
    } finally {
        if (result.isInProgress()) {
            // a bit of hack: IN_PROGRESS for workflows actually means "success"
            OperationResult r = result.clone();
            r.recordSuccess();
            modelContext.reportProgress(new ProgressInformation(WORKFLOWS, r));
        } else {
            modelContext.reportProgress(new ProgressInformation(WORKFLOWS, result));
        }
    }
    LOGGER.trace("No change processor caught this request, returning the FOREGROUND flag.");
    return HookOperationMode.FOREGROUND;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ChangeProcessor(com.evolveum.midpoint.wf.impl.processors.ChangeProcessor) ProgressInformation(com.evolveum.midpoint.model.api.ProgressInformation) HookOperationMode(com.evolveum.midpoint.model.api.hooks.HookOperationMode) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

ProgressInformation (com.evolveum.midpoint.model.api.ProgressInformation)1 HookOperationMode (com.evolveum.midpoint.model.api.hooks.HookOperationMode)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ChangeProcessor (com.evolveum.midpoint.wf.impl.processors.ChangeProcessor)1