use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class AbstractModelImplementationIntegrationTest method addModificationToContextReplaceAccountAttribute.
protected <T> ObjectDelta<ShadowType> addModificationToContextReplaceAccountAttribute(LensContext<UserType> context, String accountOid, String attributeLocalName, T... propertyValues) throws SchemaException {
LensProjectionContext accCtx = context.findProjectionContextByOid(accountOid);
ObjectDelta<ShadowType> accountDelta = createAccountDelta(accCtx, accountOid, attributeLocalName, propertyValues);
accCtx.addPrimaryDelta(accountDelta);
return accountDelta;
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class DeleteShadowAction method handle.
/* (non-Javadoc)
* @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public <F extends FocusType> void handle(LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) {
LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
projectionContext.setSynchronizationIntent(SynchronizationIntent.DELETE);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class InactivateShadowAction method handle.
/* (non-Javadoc)
* @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public <F extends FocusType> void handle(LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) {
ActivationStatusType desiredStatus = ActivationStatusType.DISABLED;
LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
PrismObject<ShadowType> objectCurrent = projectionContext.getObjectCurrent();
if (objectCurrent != null) {
PrismProperty<Object> administrativeStatusProp = objectCurrent.findProperty(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (administrativeStatusProp != null) {
if (desiredStatus.equals(administrativeStatusProp.getRealValue())) {
// Desired status already set, nothing to do
return;
}
}
}
ObjectDelta<ShadowType> activationDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, projectionContext.getOid(), SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getPrismContext(), desiredStatus);
projectionContext.setPrimaryDelta(activationDelta);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class UnlinkAction method handle.
/* (non-Javadoc)
* @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public <F extends FocusType> void handle(LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) {
LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
projectionContext.setSynchronizationIntent(SynchronizationIntent.UNLINK);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestSynchronizationService method test199DeletedAccountJackTotal.
/**
* Delete the account but also the shadow in the repo. The system should work well.
*/
@Test
public void test199DeletedAccountJackTotal() throws Exception {
final String TEST_NAME = "test199DeletedAccountJackTotal";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
MockLensDebugListener mockListener = new MockLensDebugListener();
clockwork.setDebugListener(mockListener);
getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME);
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setCurrentShadow(shadow);
change.setResource(getDummyResourceObject());
ObjectDelta<ShadowType> syncDelta = ObjectDelta.createDeleteDelta(ShadowType.class, accountShadowJackDummyOid, prismContext);
change.setObjectDelta(syncDelta);
repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result);
// WHEN
synchronizationService.notifyChange(change, task, result);
// THEN
LensContext<UserType> context = mockListener.getLastSyncContext();
display("Resulting context (as seen by debug listener)", context);
assertNotNull("No resulting context (as seen by debug listener)", context);
assertNotNull("No focus context", context.getFocusContext());
assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
assertSideEffectiveDeltasOnly("user secondary delta", context.getFocusContext().getSecondaryDelta());
ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null, true);
LensProjectionContext accCtx = context.findProjectionContext(rat);
assertNotNull("No account sync context for " + rat, accCtx);
assertEquals("Wrong detected situation in context", SynchronizationSituationType.DELETED, accCtx.getSynchronizationSituationDetected());
PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
assertNotLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJackDummyOid);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
assertLinks(userAfter, 0);
result.computeStatus();
display("Final result", result);
TestUtil.assertSuccess(result, 1);
assertNoObject(ShadowType.class, accountShadowJackDummyOid, task, result);
}
Aggregations