public ObjectDeltaTypeAsserter<PendingOperationAsserter<R>> delta() { return new ObjectDeltaTypeAsserter<>(pendingOperation.getDelta(), this, "delta in "+desc()); }
private static boolean isPendingAddOperation(PendingOperationType pendingOperation) { return ChangeTypeType.ADD.equals(pendingOperation.getDelta().getChangeType()) && !PendingOperationExecutionStatusType.COMPLETED.equals(pendingOperation.getExecutionStatus()); }
private boolean hasPendingAddOperation(PrismObject<ShadowType> objectCurrent) { List<PendingOperationType> pendingOperations = objectCurrent.asObjectable().getPendingOperation(); for (PendingOperationType pendingOperation: pendingOperations) { if (pendingOperation.getExecutionStatus() != PendingOperationExecutionStatusType.EXECUTING) { continue; } ObjectDeltaType delta = pendingOperation.getDelta(); if (delta == null) { continue; } if (delta.getChangeType() != ChangeTypeType.ADD) { continue; } return true; } return false; }
public ChangeTypeType findPreviousPendingLifecycleOperationInGracePeriod(ProvisioningContext ctx, PrismObject<ShadowType> shadow, XMLGregorianCalendar now) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation(); if (pendingOperations == null || pendingOperations.isEmpty()) { return null; } Duration gracePeriod = ProvisioningUtil.getGracePeriod(ctx); ChangeTypeType found = null; for (PendingOperationType pendingOperation : pendingOperations) { ObjectDeltaType delta = pendingOperation.getDelta(); if (delta == null) { continue; } ChangeTypeType changeType = delta.getChangeType(); if (ChangeTypeType.MODIFY.equals(changeType)) { continue; } if (ProvisioningUtil.isOverPeriod(now, gracePeriod, pendingOperation)) { continue; } if (changeType == ChangeTypeType.DELETE) { // DELETE always wins return changeType; } else { // If there is an ADD then let's check for delete. found = changeType; } } return found; }
private PendingOperationType findExistingPendingOperation(PrismObject<ShadowType> currentShadow, ObjectDelta<ShadowType> proposedDelta, boolean processInProgress) throws SchemaException { for (PendingOperationType pendingOperation: currentShadow.asObjectable().getPendingOperation()) { OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); if (!isInProgressOrRequested(resultStatus, processInProgress)) { continue; } ObjectDeltaType deltaType = pendingOperation.getDelta(); if (deltaType == null) { continue; } ObjectDelta<Objectable> delta = DeltaConvertor.createObjectDelta(deltaType, prismContext); if (!matchPendingDelta(delta, proposedDelta)) { continue; } return pendingOperation; } return null; }
private boolean matches(PendingOperationType operation) { ObjectDeltaType delta = operation.getDelta();
protected PendingOperationType assertPendingOperation( PrismObject<ShadowType> shadow, PendingOperationType pendingOperation, XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus, XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { assertNotNull("No operation ", pendingOperation); ObjectDeltaType deltaType = pendingOperation.getDelta(); assertNotNull("No delta in pending operation in "+shadow, deltaType); // TODO: check content of pending operations in the shadow TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); assertEquals("Wrong execution status in pending operation in "+shadow, expectedExecutionStatus, executiontStatus); OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); assertEquals("Wrong result status in pending operation in "+shadow, expectedResultStatus, resultStatus); // TODO: assert other timestamps if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); } return pendingOperation; }
continue; ObjectDeltaType delta = pendingOperation.getDelta(); if (expectedChangeType != null) { if (!expectedChangeType.equals(delta.getChangeType())) {
protected void assertTest919ShadowRepo(PrismObject<ShadowType> shadowRepo, Task task, OperationResult result) throws Exception { ObjectDeltaType deletePendingDelta = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { ObjectDeltaType delta = pendingOperation.getDelta(); if (delta.getChangeType() == ChangeTypeType.ADD) { ObjectType objectToAdd = delta.getObjectToAdd(); display("Pending ADD object", objectToAdd.asPrismObject()); } if (delta.getChangeType() == ChangeTypeType.DELETE) { if (deletePendingDelta != null) { fail("More than one delete pending delta found:\n"+deletePendingDelta+"\n"+delta); } deletePendingDelta = delta; } } assertNotNull("No delete pending delta", deletePendingDelta); }
private PendingOperationType assertPendingOperation( PrismObject<ShadowType> shadow, PendingOperationType pendingOperation, XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, OperationResultStatusType expectedStatus, XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { assertNotNull("No operation ", pendingOperation); ObjectDeltaType deltaType = pendingOperation.getDelta(); assertNotNull("No delta in pending operation in "+shadow, deltaType); // TODO: check content of pending operations in the shadow TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); OperationResultStatusType status = pendingOperation.getResultStatus(); assertEquals("Wrong status in pending operation in "+shadow, expectedStatus, status); if (expectedStatus != OperationResultStatusType.IN_PROGRESS) { TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); } return pendingOperation; }
private PendingOperationType findPendingOperation(PrismObject<ShadowType> shadow, OperationResultStatusType expectedResult, ItemPath itemPath) { List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation(); for (PendingOperationType pendingOperation: pendingOperations) { OperationResultStatusType result = pendingOperation.getResultStatus(); if (result == null) { result = OperationResultStatusType.IN_PROGRESS; } if (pendingOperation.getResultStatus() != expectedResult) { continue; } if (itemPath == null) { return pendingOperation; } ObjectDeltaType delta = pendingOperation.getDelta(); assertNotNull("No delta in pending operation in "+shadow, delta); for (ItemDeltaType itemDelta: delta.getItemDelta()) { ItemPath deltaPath = itemDelta.getPath().getItemPath(); if (itemPath.equivalent(deltaPath)) { return pendingOperation; } } } return null; }
List<PendingOperationType> sortedOperations = shadowCaretaker.sortPendingOperations(pendingExecutionOperations); for (PendingOperationType pendingOperation: sortedOperations) { ObjectDeltaType pendingDeltaType = pendingOperation.getDelta(); ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext); applyDefinition(pendingDelta, shadow.asObjectable(), result);
ObjectDeltaType pendingDeltaType = pendingOperation.getDelta(); ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext); if (pendingDelta.isAdd()) {
shadowDelta.applyTo(repoShadow); ObjectDeltaType pendingDeltaType = pendingOperation.getDelta(); ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext);
protected void assertTest910ShadowRepo(PrismObject<ShadowType> shadowRepo, Task task, OperationResult result) throws Exception { assertShadowNotDead(shadowRepo); ObjectDeltaType addPendingDelta = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { ObjectDeltaType delta = pendingOperation.getDelta(); if (delta.getChangeType() == ChangeTypeType.ADD) { ObjectType objectToAdd = delta.getObjectToAdd(); display("Pending ADD object", objectToAdd.asPrismObject()); if (addPendingDelta != null) { fail("More than one add pending delta found:\n"+addPendingDelta+"\n"+delta); } addPendingDelta = delta; } if (delta.getChangeType() == ChangeTypeType.DELETE) { fail("Unexpected delete pending delta found:\n"+delta); } if (isActivationStatusModifyDelta(delta, ActivationStatusType.ENABLED)) { fail("Unexpected enable pending delta found:\n"+delta); } } assertNotNull("No add pending delta", addPendingDelta); }
@Override protected void assertTest919ShadowRepo(PrismObject<ShadowType> shadowRepo, Task task, OperationResult result) throws Exception { ObjectDeltaType disablePendingDelta = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { ObjectDeltaType delta = pendingOperation.getDelta(); if (delta.getChangeType() == ChangeTypeType.ADD) { ObjectType objectToAdd = delta.getObjectToAdd(); display("Pending ADD object", objectToAdd.asPrismObject()); } if (isActivationStatusModifyDelta(delta, ActivationStatusType.DISABLED)) { if (disablePendingDelta != null) { fail("More than one disable pending delta found:\n"+disablePendingDelta+"\n"+delta); } disablePendingDelta = delta; } if (isActivationStatusModifyDelta(delta, ActivationStatusType.ENABLED)) { fail("Unexpected enable pending delta found:\n"+delta); } if (delta.getChangeType() == ChangeTypeType.DELETE) { fail("Unexpected delete pending delta found:\n"+disablePendingDelta+"\n"+delta); } } assertNotNull("No disable pending delta", disablePendingDelta); }
protected void assertTest528Deltas(PrismObject<ShadowType> shadowRepo, OperationResult result) { assertPendingOperationDeltas(shadowRepo, 3); ObjectDeltaType deltaModify = null; ObjectDeltaType deltaAdd = null; ObjectDeltaType deltaDelete = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { assertEquals("Wrong status in pending delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); ObjectDeltaType delta = pendingOperation.getDelta(); if (ChangeTypeType.ADD.equals(delta.getChangeType())) { deltaAdd = delta; } if (ChangeTypeType.MODIFY.equals(delta.getChangeType())) { deltaModify = delta; } if (ChangeTypeType.DELETE.equals(delta.getChangeType())) { deltaDelete = delta; } } assertNotNull("No add pending delta", deltaAdd); assertNotNull("No modify pending delta", deltaModify); assertNotNull("No delete pending delta", deltaDelete); }
@Override protected void assertTest526Deltas(PrismObject<ShadowType> shadowRepo, OperationResult result) { assertPendingOperationDeltas(shadowRepo, 3); ObjectDeltaType deltaModify = null; ObjectDeltaType deltaAdd = null; ObjectDeltaType deltaDisable = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { ObjectDeltaType delta = pendingOperation.getDelta(); if (ChangeTypeType.ADD.equals(delta.getChangeType())) { deltaAdd = delta; assertEquals("Wrong status in add delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); } if (ChangeTypeType.MODIFY.equals(delta.getChangeType()) && OperationResultStatusType.SUCCESS.equals(pendingOperation.getResultStatus())) { deltaModify = delta; } if (ChangeTypeType.MODIFY.equals(delta.getChangeType()) && OperationResultStatusType.IN_PROGRESS.equals(pendingOperation.getResultStatus())) { deltaDisable = delta; } } assertNotNull("No add pending delta", deltaAdd); assertNotNull("No modify pending delta", deltaModify); assertNotNull("No disable pending delta", deltaDisable); }
protected void assertTest526Deltas(PrismObject<ShadowType> shadowRepo, OperationResult result) { assertPendingOperationDeltas(shadowRepo, 3); ObjectDeltaType deltaModify = null; ObjectDeltaType deltaAdd = null; ObjectDeltaType deltaDelete = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { ObjectDeltaType delta = pendingOperation.getDelta(); if (ChangeTypeType.ADD.equals(delta.getChangeType())) { deltaAdd = delta; assertEquals("Wrong status in add delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); } if (ChangeTypeType.MODIFY.equals(delta.getChangeType())) { deltaModify = delta; assertEquals("Wrong status in modify delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); } if (ChangeTypeType.DELETE.equals(delta.getChangeType())) { deltaDelete = delta; assertEquals("Wrong status in delete delta", OperationResultStatusType.IN_PROGRESS, pendingOperation.getResultStatus()); } } assertNotNull("No add pending delta", deltaAdd); assertNotNull("No modify pending delta", deltaModify); assertNotNull("No delete pending delta", deltaDelete); }
shadowDelta.addModification(completionTimestampDelta); ObjectDeltaType pendingDeltaType = pendingOperation.getDelta(); ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext);