Search in sources :

Example 16 with ProvisioningOperationOptions

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();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 17 with ProvisioningOperationOptions

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);
    }
}
Also used : ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions)

Example 18 with ProvisioningOperationOptions

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");
        }
    }
}
Also used : AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) AsynchronousOperationReturnValue(com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta)

Aggregations

ProvisioningOperationOptions (com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 OwnerResolver (com.evolveum.midpoint.security.api.OwnerResolver)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)2 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 GenericConnectorException (com.evolveum.midpoint.provisioning.api.GenericConnectorException)1 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)1 ResourceOperationDescription (com.evolveum.midpoint.provisioning.api.ResourceOperationDescription)1 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)1 RepoAddOptions (com.evolveum.midpoint.repo.api.RepoAddOptions)1