Search in sources :

Example 16 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ProvisioningServiceImpl method deleteObject.

@Override
public <T extends ObjectType> void deleteObject(Class<T> type, String oid, ProvisioningOperationOptions options, OperationProvisioningScriptsType scripts, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    Validate.notNull(oid, "Oid of object to delete must not be null.");
    Validate.notNull(parentResult, "Operation result must not be null.");
    LOGGER.trace("**PROVISIONING: Start to delete object with oid {}", oid);
    OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".deleteObject");
    result.addParam("oid", oid);
    result.addParam("scripts", scripts);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    //TODO: is critical when shadow does not exits anymore?? do we need to log it?? if not, change null to allowNotFound options
    PrismObject<T> object = getRepoObject(type, oid, null, result);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("**PROVISIONING: Object from repository to delete:\n{}", object.debugDump());
    }
    if (object.canRepresent(ShadowType.class) && !ProvisioningOperationOptions.isRaw(options)) {
        try {
            getShadowCache(Mode.STANDARD).deleteShadow((PrismObject<ShadowType>) object, options, scripts, task, result);
        } catch (CommunicationException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: communication problem: " + e.getMessage(), e);
            throw new CommunicationException(e.getMessage(), e);
        } catch (GenericFrameworkException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: generic error in the connector: " + e.getMessage(), e);
            throw new CommunicationException(e.getMessage(), e);
        } catch (SchemaException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: schema problem: " + e.getMessage(), e);
            throw new SchemaException(e.getMessage(), e);
        } catch (ConfigurationException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: configuration problem: " + e.getMessage(), e);
            throw e;
        } catch (SecurityViolationException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: security violation: " + e.getMessage(), e);
            throw e;
        } catch (ExpressionEvaluationException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: expression errror: " + e.getMessage(), e);
            throw e;
        } catch (RuntimeException e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: " + e.getMessage(), e);
            throw new SystemException(e);
        }
    } else if (object.canRepresent(ResourceType.class)) {
        resourceManager.deleteResource(oid, options, task, result);
    } else {
        try {
            getCacheRepositoryService().deleteObject(type, oid, result);
        } catch (ObjectNotFoundException ex) {
            result.recordFatalError(ex);
            result.cleanupResult(ex);
            throw ex;
        }
    }
    LOGGER.trace("**PROVISIONING: Finished deleting object.");
    result.computeStatus();
    result.cleanupResult();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 17 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method fetchConnectorObject.

/**
	 * Returns null if nothing is found.
	 */
private ConnectorObject fetchConnectorObject(StateReporter reporter, ObjectClassComplexTypeDefinition objectClassDefinition, ObjectClass icfObjectClass, Uid uid, OperationOptions options, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SecurityViolationException, SchemaException, ConfigurationException {
    // Connector operation cannot create result for itself, so we need to
    // create result for it
    OperationResult icfResult = parentResult.createMinorSubresult(ConnectorFacade.class.getName() + ".getObject");
    icfResult.addParam("objectClass", icfObjectClass.toString());
    icfResult.addParam("uid", uid.getUidValue());
    icfResult.addArbitraryObjectAsParam("options", options);
    icfResult.addContext("connector", connIdConnectorFacade.getClass());
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Fetching connector object ObjectClass={}, UID={}, options={}", new Object[] { icfObjectClass, uid, ConnIdUtil.dumpOptions(options) });
    }
    ConnectorObject co = null;
    try {
        // Invoke the ICF connector
        InternalMonitor.recordConnectorOperation("getObject");
        recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
        co = connIdConnectorFacade.getObject(icfObjectClass, uid, options);
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
        icfResult.recordSuccess();
    } catch (Throwable ex) {
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, ex, uid);
        String desc = this.getHumanReadableName() + " while getting object identified by ICF UID '" + uid.getUidValue() + "'";
        Throwable midpointEx = processIcfException(ex, desc, icfResult);
        icfResult.computeStatus("Add object failed");
        // exception
        if (midpointEx instanceof CommunicationException) {
            icfResult.muteError();
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof ConfigurationException) {
            throw (ConfigurationException) midpointEx;
        } else if (midpointEx instanceof SecurityViolationException) {
            throw (SecurityViolationException) midpointEx;
        } else if (midpointEx instanceof ObjectNotFoundException) {
            LOGGER.trace("Got ObjectNotFoundException while looking for resource object ConnId UID: {}", uid);
            return null;
        } else if (midpointEx instanceof RuntimeException) {
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            // This should not happen. But some connectors are very strange.
            throw new SystemException("ERROR: " + midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
        } else {
            throw new SystemException(midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
        }
    }
    return co;
}
Also used : CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) GuardedString(org.identityconnectors.common.security.GuardedString)

Example 18 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method executeScript.

@Override
public Object executeScript(ExecuteProvisioningScriptOperation scriptOperation, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
    OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".executeScript");
    Object output = null;
    try {
        output = executeScriptIcf(reporter, scriptOperation, result);
    } catch (CommunicationException e) {
        result.recordFatalError(e);
        throw e;
    } catch (GenericFrameworkException e) {
        result.recordFatalError(e);
        throw e;
    } catch (RuntimeException e) {
        result.recordFatalError(e);
        throw e;
    }
    result.computeStatus();
    return output;
}
Also used : CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject)

Example 19 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method fetchCurrentToken.

@Override
public <T> PrismProperty<T> fetchCurrentToken(ObjectClassComplexTypeDefinition objectClassDef, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
    OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".fetchCurrentToken");
    result.addParam("objectClass", objectClassDef);
    ObjectClass icfObjectClass;
    if (objectClassDef == null) {
        icfObjectClass = ObjectClass.ALL;
    } else {
        icfObjectClass = connIdNameMapper.objectClassToIcf(objectClassDef, getSchemaNamespace(), connectorType, legacySchema);
    }
    OperationResult icfResult = result.createSubresult(ConnectorFacade.class.getName() + ".sync");
    icfResult.addContext("connector", connIdConnectorFacade.getClass());
    icfResult.addArbitraryObjectAsParam("icfObjectClass", icfObjectClass);
    SyncToken syncToken = null;
    try {
        InternalMonitor.recordConnectorOperation("getLatestSyncToken");
        recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
        syncToken = connIdConnectorFacade.getLatestSyncToken(icfObjectClass);
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
        icfResult.recordSuccess();
        icfResult.addReturn("syncToken", syncToken == null ? null : String.valueOf(syncToken.getValue()));
    } catch (Throwable ex) {
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef, ex);
        Throwable midpointEx = processIcfException(ex, this, icfResult);
        result.computeStatus();
        // exception
        if (midpointEx instanceof CommunicationException) {
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof RuntimeException) {
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            throw (Error) midpointEx;
        } else {
            throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
        }
    }
    if (syncToken == null) {
        result.recordWarning("Resource have not provided a current sync token");
        return null;
    }
    PrismProperty<T> property = getToken(syncToken);
    result.recordSuccess();
    return property;
}
Also used : SyncToken(org.identityconnectors.framework.common.objects.SyncToken) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult)

Example 20 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class AbstractManualConnectorInstance method deleteObject.

@Override
public AsynchronousOperationResult deleteObject(ObjectClassComplexTypeDefinition objectClass, Collection<Operation> additionalOperations, Collection<? extends ResourceAttribute<?>> identifiers, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException {
    OperationResult result = parentResult.createSubresult(OPERATION_DELETE);
    String ticketIdentifier = null;
    try {
        ticketIdentifier = createTicketDelete(objectClass, identifiers, result);
    } catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ConfigurationException | RuntimeException | Error e) {
        result.recordFatalError(e);
        throw e;
    }
    result.recordInProgress();
    result.setAsynchronousOperationReference(ticketIdentifier);
    return AsynchronousOperationResult.wrap(result);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult)

Aggregations

GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)43 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)33 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)20 SystemException (com.evolveum.midpoint.util.exception.SystemException)18 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)13 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)13 GuardedString (org.identityconnectors.common.security.GuardedString)9 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)9 ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)8 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)8 QName (javax.xml.namespace.QName)8 OperationOptionsBuilder (org.identityconnectors.framework.common.objects.OperationOptionsBuilder)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)7 ConnectorObject (org.identityconnectors.framework.common.objects.ConnectorObject)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 OperationOptions (org.identityconnectors.framework.common.objects.OperationOptions)6