Search in sources :

Example 26 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class SynchronizationServiceImpl method createOptions.

@NotNull
private <F extends FocusType> ModelExecuteOptions createOptions(SynchronizationContext<F> syncCtx, ResourceObjectShadowChangeDescription change) {
    ModelExecuteOptionsType explicitOptions = syncCtx.getExecuteOptions();
    ModelExecuteOptions options = explicitOptions != null ? ModelExecuteOptions.fromModelExecutionOptionsType(explicitOptions) : ModelExecuteOptions.create(prismContext);
    if (options.getReconcile() == null) {
        Boolean doReconciliation = syncCtx.isDoReconciliation();
        if (doReconciliation != null) {
            options.reconcile(doReconciliation);
        } else {
            // There is no other good way how to reflect the changes from the shadow.
            if (change.getObjectDelta() == null) {
                options.reconcile();
            }
        }
    }
    if (options.getLimitPropagation() == null) {
        options.limitPropagation(syncCtx.isLimitPropagation());
    }
    return options;
}
Also used : ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class RecomputeExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    boolean dryRun = operationsHelper.getDryRun(action, input, context, globalResult);
    ModelExecuteOptions options = operationsHelper.getOptions(action, input, context, globalResult);
    options.reconcile(true);
    TriggerCreationType triggerCreation = action instanceof RecomputeActionExpressionType ? ((RecomputeActionExpressionType) action).getTriggered() : null;
    iterateOverObjects(input, context, globalResult, (object, item, result) -> recompute(object, dryRun, options, triggerCreation, context, result), (object, exception) -> context.println("Failed to recompute " + object + drySuffix(dryRun) + exceptionSuffix(exception)));
    return input;
}
Also used : TriggerCreationType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerCreationType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) RecomputeActionExpressionType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.RecomputeActionExpressionType)

Example 28 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class ModifyExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ModelExecuteOptions options = operationsHelper.getOptions(action, input, context, globalResult);
    boolean dryRun = operationsHelper.getDryRun(action, input, context, globalResult);
    ObjectDeltaType deltaBean = expressionHelper.getActionArgument(ObjectDeltaType.class, action, ModifyActionExpressionType.F_DELTA, PARAM_DELTA, input, context, null, PARAM_DELTA, globalResult);
    if (deltaBean == null) {
        Throwable ex = new SchemaException("Found no delta to be applied");
        // TODO value for error reporting (3rd parameter)
        processActionException(ex, NAME, null, context);
        context.println("Found no delta to be applied");
        return input;
    }
    iterateOverObjects(input, context, globalResult, (object, item, result) -> modify(object, dryRun, options, deltaBean, context, result), (object, exception) -> context.println("Failed to modify " + object + drySuffix(dryRun) + exceptionSuffix(exception)));
    return input;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions)

Example 29 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestConnectorDummyFake method test450DowngradeRawReplace.

@Test
public void test450DowngradeRawReplace() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    ObjectDelta<ResourceType> resourceDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID);
    ReferenceDelta connectorRefDeltaReplace = prismContext.deltaFactory().reference().createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyFakeOid);
    resourceDelta.addModification(connectorRefDeltaReplace);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    executeChanges(resourceDelta, options, task, result);
    // THEN
    assertSuccess(result);
    assertDowngrade(dummyResourceModelBefore);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test)

Example 30 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestConnectorDummyFake method test300UpgradeRawAddDelete.

@Test
public void test300UpgradeRawAddDelete() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    ObjectDelta<ResourceType> resourceDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID);
    ReferenceDelta connectorRefDeltaDel = prismContext.deltaFactory().reference().createModificationDelete(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyFakeOid);
    resourceDelta.addModification(connectorRefDeltaDel);
    ReferenceDelta connectorRefDeltaAdd = prismContext.deltaFactory().reference().createModificationAdd(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyOid);
    resourceDelta.addModification(connectorRefDeltaAdd);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    executeChanges(resourceDelta, options, task, result);
    // THEN
    assertSuccess(result);
    assertUpgrade(dummyResourceModelBefore);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test)

Aggregations

ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)80 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)45 Test (org.testng.annotations.Test)30 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 RestartResponseException (org.apache.wicket.RestartResponseException)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3 ExecuteChangeOptionsDto (com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 NotNull (org.jetbrains.annotations.NotNull)3