use of com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType.COMPLETED in project midpoint by Evolveum.
the class AbstractManualResourceTest method test230ModifyAccountWillChangePasswordAndEnable.
/**
* Change password, enable. There is still pending disable delta. Make sure all the deltas are
* stored correctly.
*/
@Test
public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception {
final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable";
displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, userWillOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, ActivationStatusType.ENABLED);
ProtectedStringType ps = new ProtectedStringType();
ps.setClearValue(USER_WILL_PASSWORD_NEW);
delta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_VALUE, ps);
display("ObjectDelta", delta);
accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
// WHEN
displayWhen(TEST_NAME);
executeChanges(delta, null, task, result);
// THEN
displayThen(TEST_NAME);
display("result", result);
willSecondLastCaseOid = assertInProgress(result);
accountWillSecondReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
display("Repo shadow", shadowRepo);
assertPendingOperationDeltas(shadowRepo, 3);
PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
assertPendingOperation(shadowRepo, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
assertNotNull("No ID in pending operation", pendingOperation.getId());
// Still old data in the repo. The operation is not completed yet.
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
PrismObject<ShadowType> shadowProvisioning = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
display("Model shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, USER_WILL_NAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, USER_WILL_NAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowProvisioning);
assertPendingOperationDeltas(shadowProvisioning, 3);
pendingOperation = findPendingOperation(shadowProvisioning, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
assertPendingOperation(shadowProvisioning, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
PrismObject<ShadowType> shadowProvisioningFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
display("Model shadow (future)", shadowProvisioningFuture);
assertShadowName(shadowProvisioningFuture, USER_WILL_NAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadow(shadowProvisioningFuture);
assertNotNull("No async reference in result", willSecondLastCaseOid);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
assertCase(willSecondLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType.COMPLETED in project midpoint by Evolveum.
the class AbstractManualResourceTest method test302RecomputeWill.
/**
* Recompute. Make sure model will not try to delete the account again.
*/
@Test
public void test302RecomputeWill() throws Exception {
final String TEST_NAME = "test302RecomputeWill";
displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
displayWhen(TEST_NAME);
recomputeUser(userWillOid, task, result);
// THEN
displayThen(TEST_NAME);
display("result", result);
assertSuccess(result);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
display("Repo shadow", shadowRepo);
assertPendingOperationDeltas(shadowRepo, 1);
PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, null);
assertPendingOperation(shadowRepo, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertNotNull("No ID in pending operation", pendingOperation.getId());
// Still old data in the repo. The operation is not completed yet.
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
display("Model shadow", shadowModel);
ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
assertShadowName(shadowModel, USER_WILL_NAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
assertAttribute(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
assertAttributeFromBackingStore(shadowModel, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowModel);
assertPendingOperationDeltas(shadowModel, 1);
pendingOperation = findPendingOperation(shadowModel, OperationResultStatusType.IN_PROGRESS, null);
assertPendingOperation(shadowModel, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
PrismObject<ShadowType> shadowModelFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
display("Model shadow (future)", shadowModelFuture);
assertShadowName(shadowModelFuture, USER_WILL_NAME);
assertShadowDead(shadowModelFuture);
assertShadowPassword(shadowModelFuture);
// Make sure that the account is still linked
PrismObject<UserType> userAfter = getUser(userWillOid);
display("User after", userAfter);
String accountWillOidAfter = getSingleLinkOid(userAfter);
assertEquals(accountWillOid, accountWillOidAfter);
assertNoAssignments(userAfter);
assertNotNull("No async reference in result", willLastCaseOid);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType.COMPLETED in project midpoint by Evolveum.
the class CaseClosing method processDelayedExecution.
private void processDelayedExecution(CaseType currentCase, CaseType rootCase, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
LOGGER.debug("Approval case {} is completed; but execution is delayed so let's check other subcases of {}", currentCase, rootCase);
beans.executionHelper.closeCaseInRepository(currentCase, result);
List<CaseType> subcases = beans.miscHelper.getSubcases(rootCase, result);
// TODO what about race conditions, i.e. what if remaining cases are closed "at once"?!
if (subcases.stream().allMatch(CaseTypeUtil::isClosed)) {
LOGGER.debug("All subcases of {} are closed, so let's execute the deltas", rootCase);
beans.executionHelper.submitExecutionTaskIfNeeded(rootCase, subcases, operation.getTask(), result);
} else {
LOGGER.debug("Some subcases of {} are not closed yet. Delta execution is therefore postponed.", rootCase);
for (CaseType subcase : subcases) {
LOGGER.debug(" - {}: state={} (isClosed={})", subcase, subcase.getState(), CaseTypeUtil.isClosed(subcase));
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType.COMPLETED in project midpoint by Evolveum.
the class ManualConnectorInstance method addCase.
private PrismObject<CaseType> addCase(String operation, String description, String resourceOid, String shadowName, @Nullable String shadowOid, ObjectDeltaType objectDelta, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException {
if (randomDelayRange != 0) {
int waitMillis = RND.nextInt(randomDelayRange);
LOGGER.info("Manual connector waiting {} ms before creating the case", waitMillis);
try {
Thread.sleep(waitMillis);
} catch (InterruptedException e) {
LOGGER.error("Manual connector wait is interrupted");
}
LOGGER.info("Manual connector wait is over");
}
PrismObject<ResourceType> resource;
try {
resource = repositoryService.getObject(ResourceType.class, resourceOid, null, result);
} catch (ObjectNotFoundException e) {
// object not found" with subsequent handling as such.
throw new SystemException("Resource " + resourceOid + " couldn't be found", e);
}
ObjectReferenceType archetypeRef = ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_MANUAL_CASE.value(), ObjectTypes.ARCHETYPE);
// @formatter:off
CaseType aCase = new CaseType(getPrismContext()).name(String.format("Request to %s '%s' on '%s'", operation, shadowName, resource.getName().getOrig())).description(description).state(// Case opening process will be completed by CaseEngine
SchemaConstants.CASE_STATE_CREATED).objectRef(resourceOid, ResourceType.COMPLEX_TYPE).requestorRef(task != null ? task.getOwnerRef() : null).beginManualProvisioningContext().beginPendingOperation().type(PendingOperationTypeType.MANUAL).delta(objectDelta).<ManualProvisioningContextType>end().schema(createCaseSchema(resource.asObjectable().getBusiness())).<CaseType>end().archetypeRef(archetypeRef.clone()).beginAssignment().targetRef(archetypeRef).<CaseType>end().beginMetadata().createTimestamp(clock.currentTimeXMLGregorianCalendar()).end();
if (shadowOid != null) {
aCase.targetRef(shadowOid, ShadowType.COMPLEX_TYPE);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("CREATING CASE:\n{}", aCase.debugDumpLazily(1));
}
repositoryService.addObject(aCase.asPrismObject(), null, result);
// "Admitting" the case into case management: e.g. sending notifications, auditing the case creation, and so on
caseEventDispatcher.dispatchCaseCreationEvent(aCase, task, result);
return aCase.asPrismObject();
}
Aggregations