use of com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions in project midpoint by Evolveum.
the class TestDummyNegative method test221DeleteAccountResourceNotFound.
/**
* Deleting an account with resourceRef pointing to non-existent resource.
*/
@Test
public void test221DeleteAccountResourceNotFound() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
syncServiceMock.reset();
ShadowType accountType = parseObjectType(ACCOUNT_ELAINE_RESOURCE_NOT_FOUND_FILE);
PrismObject<ShadowType> account = accountType.asPrismObject();
account.checkConsistence();
display("Adding shadow", account);
try {
when();
String oid = repositoryService.addObject(account, null, result);
ProvisioningOperationOptions options = ProvisioningOperationOptions.createForce(true);
provisioningService.deleteObject(ShadowType.class, oid, options, null, task, result);
} catch (SchemaException e) {
displayExpectedException(e);
}
// FIXME: is this really notify failure? the resource does not exist but shadow is deleted. maybe other case of notify?
// syncServiceMock.assertNotifyFailureOnly();
}
use of com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions in project midpoint by Evolveum.
the class DeltaExecution method deleteProvisioningObject.
private PrismObject<E> deleteProvisioningObject(Class<E> type, String oid, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException {
ProvisioningOperationOptions options = getProvisioningOptions();
PrismObject<E> objectToDelete = null;
try {
Collection<SelectorOptions<GetOperationOptions>> getOptions = b.schemaService.getOperationOptionsBuilder().readOnly().noFetch().futurePointInTime().build();
objectToDelete = b.provisioningService.getObject(type, oid, getOptions, task, result);
} catch (ObjectNotFoundException ex) {
// this is almost OK, mute the error and try to delete account (it will fail if something is wrong)
result.muteLastSubresultError();
}
OperationProvisioningScriptsType scripts;
if (ShadowType.class.isAssignableFrom(type)) {
scripts = prepareScripts(objectToDelete, ProvisioningOperationTypeType.DELETE, result);
} else {
scripts = null;
}
ModelImplUtils.setRequestee(task, context);
try {
return b.provisioningService.deleteObject(type, oid, options, scripts, task, result);
} finally {
ModelImplUtils.clearRequestee(task);
}
}
use of com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions in project midpoint by Evolveum.
the class RefreshHelper method retryOperation.
private void retryOperation(ProvisioningContext ctx, ObjectDelta<ShadowType> pendingDelta, ProvisioningOperationState<? extends AsynchronousOperationResult> opState, Task task, OperationResult result) throws CommunicationException, GenericFrameworkException, ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, EncryptionException {
ProvisioningOperationOptions options = ProvisioningOperationOptions.createForceRetry(false);
// TODO
OperationProvisioningScriptsType scripts = null;
if (pendingDelta.isAdd()) {
PrismObject<ShadowType> resourceObjectToAdd = pendingDelta.getObjectToAdd();
addHelper.addShadowAttempt(ctx, resourceObjectToAdd, scripts, (ProvisioningOperationState<AsynchronousOperationReturnValue<PrismObject<ShadowType>>>) opState, options, task, result);
}
if (pendingDelta.isModify()) {
if (opState.objectExists()) {
modifyHelper.modifyShadowAttempt(ctx, pendingDelta.getModifications(), scripts, options, (ProvisioningOperationState<AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>>>) opState, true, task, result);
} else {
result.recordFatalError("Object does not exist on the resource yet, modification attempt was skipped");
}
}
if (pendingDelta.isDelete()) {
if (opState.objectExists()) {
deleteHelper.deleteShadowAttempt(ctx, options, scripts, (ProvisioningOperationState<AsynchronousOperationResult>) opState, task, result);
} else {
result.recordFatalError("Object does not exist on the resource yet, deletion attempt was skipped");
}
}
}
Aggregations