Search in sources :

Example 16 with AsynchronousOperationResult

use of com.evolveum.midpoint.schema.result.AsynchronousOperationResult in project midpoint by Evolveum.

the class DeleteHelper method executeResourceDelete.

ProvisioningOperationState<AsynchronousOperationResult> executeResourceDelete(ProvisioningContext ctx, PrismObject<ShadowType> shadow, OperationProvisioningScriptsType scripts, ProvisioningOperationOptions options, Task task, OperationResult parentResult) throws SchemaException, GenericFrameworkException, CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException {
    ProvisioningOperationState<AsynchronousOperationResult> opState = new ProvisioningOperationState<>();
    opState.setRepoShadow(shadow);
    ConnectorOperationOptions connOptions = commonHelper.createConnectorOperationOptions(ctx, options, parentResult);
    try {
        AsynchronousOperationResult asyncReturnValue = resourceObjectConverter.deleteResourceObject(ctx, shadow, scripts, connOptions, parentResult);
        opState.processAsyncResult(asyncReturnValue);
    } catch (Exception ex) {
        try {
            handleDeleteError(ctx, shadow, options, opState, ex, parentResult.getLastSubresult(), task, parentResult);
        } catch (ObjectAlreadyExistsException e) {
            parentResult.recordFatalError(e);
            throw new SystemException(e.getMessage(), e);
        }
    }
    return opState;
}
Also used : AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) ConnectorOperationOptions(com.evolveum.midpoint.provisioning.ucf.api.ConnectorOperationOptions) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)

Example 17 with AsynchronousOperationResult

use of com.evolveum.midpoint.schema.result.AsynchronousOperationResult in project midpoint by Evolveum.

the class DeleteHelper method deleteShadowDirectly.

private OperationResultStatus deleteShadowDirectly(ProvisioningContext ctx, ProvisioningOperationOptions options, OperationProvisioningScriptsType scripts, ProvisioningOperationState<AsynchronousOperationResult> opState, ShadowLifecycleStateType shadowState, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException, GenericFrameworkException, SecurityViolationException, PolicyViolationException {
    PrismObject<ShadowType> repoShadow = opState.getRepoShadow();
    if (shadowState == ShadowLifecycleStateType.TOMBSTONE) {
        // Do not even try to delete resource object for tombstone shadows.
        // There may be dead shadow and live shadow for the resource object with the same identifiers.
        // If we try to delete dead shadow then we might delete existing object by mistake
        LOGGER.trace("DELETE {}: skipping resource deletion on tombstone shadow", repoShadow);
        opState.setExecutionStatus(PendingOperationExecutionStatusType.COMPLETED);
        result.createSubresult(OP_RESOURCE_OPERATION).recordNotApplicable();
        return null;
    }
    ConnectorOperationOptions connOptions = commonHelper.createConnectorOperationOptions(ctx, options, result);
    LOGGER.trace("DELETE {}: resource deletion, execution starting", repoShadow);
    try {
        ctx.checkNotInMaintenance();
        AsynchronousOperationResult asyncReturnValue = resourceObjectConverter.deleteResourceObject(ctx, repoShadow, scripts, connOptions, result);
        opState.processAsyncResult(asyncReturnValue);
        resourceManager.modifyResourceAvailabilityStatus(ctx.getResourceOid(), AvailabilityStatusType.UP, "deleting " + repoShadow + " finished successfully.", task, result, false);
        return null;
    } catch (Exception ex) {
        try {
            return handleDeleteError(ctx, repoShadow, options, opState, ex, result.getLastSubresult(), task, result);
        } catch (ObjectAlreadyExistsException e) {
            result.recordFatalError(e);
            throw new SystemException(e.getMessage(), e);
        }
    } finally {
        LOGGER.debug("DELETE {}: resource operation executed, operation state: {}", repoShadow, opState.shortDumpLazily());
    }
}
Also used : AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) ConnectorOperationOptions(com.evolveum.midpoint.provisioning.ucf.api.ConnectorOperationOptions) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)

Aggregations

AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)6 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)3 ArrayList (java.util.ArrayList)3 Duration (javax.xml.datatype.Duration)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 ConnectorOperationOptions (com.evolveum.midpoint.provisioning.ucf.api.ConnectorOperationOptions)2 AsynchronousOperationReturnValue (com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 GuardedString (org.identityconnectors.common.security.GuardedString)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1