private <O extends ObjectType> String executePersonaDelta(ObjectDelta<O> delta, String ownerOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, SecurityViolationException, PreconditionViolationException { Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta); LensContext<? extends ObjectType> context = contextFactory.createContext(deltas, null, task, result); // Persona changes are all "secondary" changes, trigerred by roles and policies. We do not want to authorize // them as REQUEST. Assignment of the persona role was REQUEST. Changes in persona itself is all EXECUTION. context.setExecutionPhaseOnly(true); context.setOwnerOid(ownerOid); clockwork.run(context, task, result); return ObjectDeltaOperation.findFocusDeltaOidInCollection(context.getExecutedDeltas()); }
protected <O extends ObjectType> String addObject(PrismObject<O> object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { ObjectDelta<O> addDelta = object.createAddDelta(); assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = executeChanges(addDelta, options, task, result); object.setOid(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedDeltas)); return object.getOid(); }
String userOid = ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges); assertNotNull("No user OID in delta after operation", userOid);
@Test public void test600AddUser1() throws Exception { final String TEST_NAME = "test600AddUser1"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> user1 = prismContext.createObject(UserType.class); prismContext.deltaFor(UserType.class) .item(UserType.F_NAME).replace(new PolyString("user1")) .item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(resourceDummyCoral, prismContext).asPrismContainerValue()) .item(ACTIVATION_ADMINISTRATIVE_STATUS_PATH).replace(ActivationStatusType.DISABLED) .asObjectDelta(null) .applyTo((PrismObject) user1); ObjectDelta<UserType> addDelta = user1.createAddDelta(); // WHEN displayWhen(TEST_NAME); Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = executeChanges(addDelta, null, task, result); // THEN displayThen(TEST_NAME); user1 = getUser(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges)); display("User after change execution", user1); DummyAccount dummyAccount = dummyResourceCoral.getAccountByUsername("user1"); display("Dummy account", dummyAccount); checkSuspendedAttribute(dummyAccount, Boolean.TRUE); String accountOid = getSingleLinkOid(user1); PrismObject<ShadowType> shadow = getShadowModel(accountOid); display("Shadow: ", shadow); // TODO check real state of the account and shadow }