Search in sources :

Example 61 with ModelExecuteOptions

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

the class AsynchronousScriptExecutor method submitTask.

private void submitTask(OperationResult result, TaskType newTask) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    Set<ObjectDelta<? extends ObjectType>> deltas = singleton(DeltaFactory.Object.createAddDelta(newTask.asPrismObject()));
    ModelExecuteOptions options = new ModelExecuteOptions(actx.beans.prismContext).preAuthorized();
    Collection<ObjectDeltaOperation<? extends ObjectType>> operations = actx.beans.modelService.executeChanges(deltas, options, actx.task, result);
    String oid = ObjectDeltaOperation.findAddDeltaOid(operations, newTask.asPrismObject());
    result.setAsynchronousOperationReference(oid);
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 62 with ModelExecuteOptions

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

the class TestActivation method test115ModifyUserJackAdministrativeStatusNull.

/**
 * Re-enabling the user should enable the account as well. Even if the user is already enabled.
 */
@Test
public void test115ModifyUserJackAdministrativeStatusNull() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    // MID-6420
    ModelExecuteOptions options = ModelExecuteOptions.create(prismContext).pushChanges();
    // WHEN
    modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, options, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    DummyAccount account = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME);
    displayDumpable("Account after change", account);
    assertUserJack(userJack, USER_JACK_FULL_NAME);
    assertAdministrativeStatus(userJack, null);
    // Dummy account should still be enabled. It does not support validity, therefore
    // the account/administrativeStatus is mapped from user.effectiveStatus
    assertDummyActivationEnabledState(ACCOUNT_JACK_DUMMY_USERNAME, true);
    assertAccounts(USER_JACK_OID, 1);
    PrismObject<ShadowType> shadow = getShadowModel(accountOid);
    assertAccountShadowModel(shadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, getDummyResourceType());
    assertAdministrativeStatus(shadow, ActivationStatusType.ENABLED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestValidityRecomputeTask(com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 63 with ModelExecuteOptions

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

the class TestConnectorDummyFake method test350DowngradeRawAddDelete.

@Test
public void test350DowngradeRawAddDelete() 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(), connectorDummyOid);
    resourceDelta.addModification(connectorRefDeltaDel);
    ReferenceDelta connectorRefDeltaAdd = prismContext.deltaFactory().reference().createModificationAdd(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyFakeOid);
    resourceDelta.addModification(connectorRefDeltaAdd);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    modelService.executeChanges(deltas, options, task, result);
    // THEN
    result.computeStatus();
    display("executeChanges result", result);
    TestUtil.assertSuccess("executeChanges result", result);
    assertDowngrade(dummyResourceModelBefore);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) 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) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Example 64 with ModelExecuteOptions

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

the class FocusValidityScanPartialRun method createLensContext.

private LensContext<FocusType> createLensContext(@NotNull FocusType focus, @NotNull RunningTask workerTask, @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException, SecurityViolationException {
    // We want the reconcile option here. There may be accounts that are in wrong activation state.
    // We will not notice that unless we go with reconcile.
    ModelExecuteOptions options = new ModelExecuteOptions(PrismContext.get()).reconcile();
    LensContext<FocusType> lensContext = getModelBeans().contextFactory.createRecomputeContext(focus.asPrismObject(), options, workerTask, result);
    if (getValidityConstraint() != null) {
        addTriggeredPolicyRuleToContext(focus, lensContext, workerTask, result);
    }
    return lensContext;
}
Also used : FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions)

Example 65 with ModelExecuteOptions

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

the class TestTracing method test100IllegalChars.

/**
 * Tests illegal chars in mapping output.
 */
@Test
public void test100IllegalChars() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    deleteReportDataObjects(result);
    when();
    ModelExecuteOptions options = executeOptions();
    options.tracingProfile(createModelAndProvisioningLoggingTracingProfile());
    ObjectDelta<UserType> delta = deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(new AssignmentType(prismContext).targetRef(ROLE_ILLEGAL.oid, RoleType.COMPLEX_TYPE), new AssignmentType(prismContext).beginConstruction().resourceRef(RESOURCE_ILLEGAL.oid, ResourceType.COMPLEX_TYPE).<AssignmentType>end()).asObjectDelta(USER_JOE.oid);
    executeChanges(delta, options, task, result);
    then();
    assertSuccess(result);
    assertUserAfter(USER_JOE.oid).assignments().assertAssignments(2).end().links().assertLiveLinks(1);
    RESOURCE_ILLEGAL.controller.assertAccountByUsername("joe").assertFullName("A\u0007B");
    assertTraceCanBeParsed(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractEmptyModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractEmptyModelIntegrationTest)

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