Search in sources :

Example 6 with ConnectorOperationOptions

use of com.evolveum.midpoint.provisioning.ucf.api.ConnectorOperationOptions 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

ConnectorOperationOptions (com.evolveum.midpoint.provisioning.ucf.api.ConnectorOperationOptions)6 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)5 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)5 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)2 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)2 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)2 AsynchronousOperationReturnValue (com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue)2 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 Collection (java.util.Collection)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ResourceOperationDescription (com.evolveum.midpoint.provisioning.api.ResourceOperationDescription)1 ProvisioningContext (com.evolveum.midpoint.provisioning.impl.ProvisioningContext)1 RefreshShadowOperation (com.evolveum.midpoint.schema.RefreshShadowOperation)1 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)1 ResourceObjectIdentification (com.evolveum.midpoint.schema.processor.ResourceObjectIdentification)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 PendingOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType)1 RunAsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.RunAsCapabilityType)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1