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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations