Search in sources :

Example 1 with Schema

use of org.identityconnectors.framework.common.objects.Schema in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method retrieveResourceSchema.

private void retrieveResourceSchema(List<QName> generateObjectClasses, OperationResult parentResult) throws CommunicationException, ConfigurationException, GenericFrameworkException {
    // Connector operation cannot create result for itself, so we need to
    // create result for it
    OperationResult icfResult = parentResult.createSubresult(ConnectorFacade.class.getName() + ".schema");
    icfResult.addContext("connector", connIdConnectorFacade.getClass());
    org.identityconnectors.framework.common.objects.Schema icfSchema = null;
    try {
        // Fetch the schema from the connector (which actually gets that
        // from the resource).
        InternalMonitor.recordConnectorOperation("schema");
        // TODO have context present
        //recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null);
        icfSchema = connIdConnectorFacade.schema();
        //recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null);
        icfResult.recordSuccess();
    } catch (UnsupportedOperationException ex) {
        //recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null, ex);
        // The connector does no support schema() operation.
        icfResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, ex.getMessage());
        resetResourceSchema();
        return;
    } catch (Throwable ex) {
        //recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null, ex);
        // conditions.
        // Therefore this kind of heavy artillery is necessary.
        // ICF interface does not specify exceptions or other error
        // TODO maybe we can try to catch at least some specific exceptions
        Throwable midpointEx = processIcfException(ex, this, icfResult);
        // exception
        if (midpointEx instanceof CommunicationException) {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof ConfigurationException) {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw (ConfigurationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof RuntimeException) {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw (Error) midpointEx;
        } else {
            icfResult.recordFatalError(midpointEx.getMessage(), midpointEx);
            throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
        }
    }
    if (icfSchema == null) {
        icfResult.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Null schema returned");
        resetResourceSchema();
        return;
    }
    parseResourceSchema(icfSchema, generateObjectClasses);
}
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) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) Schema(org.identityconnectors.framework.common.objects.Schema)

Example 2 with Schema

use of org.identityconnectors.framework.common.objects.Schema in project midpoint by Evolveum.

the class ConnIdCapabilitiesAndSchemaParser method fetchConnIdSchema.

private Schema fetchConnIdSchema(OperationResult parentResult) throws CommunicationException, ConfigurationException, GenericFrameworkException {
    // Connector operation cannot create result for itself, so we need to create result for it
    OperationResult result = parentResult.createSubresult(OP_SCHEMA);
    result.addContext("connector", connIdConnectorFacade.getClass());
    try {
        LOGGER.debug("Fetching schema from {}", connectorHumanReadableName);
        // Fetch the schema from the connector (which actually gets that from the resource).
        InternalMonitor.recordConnectorOperation("schema");
        // TODO have context present
        Schema connIdSchema = connIdConnectorFacade.schema();
        if (connIdSchema == null) {
            result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Null schema returned");
        } else {
            result.recordSuccess();
        }
        return connIdSchema;
    } catch (UnsupportedOperationException ex) {
        // recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null, ex);
        // The connector does no support schema() operation.
        result.recordStatus(OperationResultStatus.NOT_APPLICABLE, ex.getMessage());
        return null;
    } catch (Throwable ex) {
        // recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_SCHEMA, null, ex);
        // conditions.
        // Therefore this kind of heavy artillery is necessary.
        // ICF interface does not specify exceptions or other error
        // TODO maybe we can try to catch at least some specific exceptions
        Throwable midpointEx = ConnIdUtil.processConnIdException(ex, connectorHumanReadableName, result);
        result.recordFatalError(midpointEx.getMessage(), midpointEx);
        castAndThrowException(ex, midpointEx);
        throw new AssertionError("not here");
    } finally {
        result.close();
    }
}
Also used : Schema(org.identityconnectors.framework.common.objects.Schema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 3 with Schema

use of org.identityconnectors.framework.common.objects.Schema in project CzechIdMng by bcvsolutions.

the class ConnIdIcConfigurationService method getSchema.

@Override
public IcSchema getSchema(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration) {
    Assert.notNull(connectorInstance.getConnectorKey());
    Assert.notNull(connectorConfiguration);
    if (connectorInstance.isRemote()) {
        LOG.info(MessageFormat.format("Get Schema of remote connector - ConnId ({0})", connectorInstance.getConnectorServer().getFullServerName()));
    } else {
        LOG.info(MessageFormat.format("Get Schema - ConnId ({0})", connectorInstance.getConnectorKey().toString()));
    }
    ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
    Schema schema = conn.schema();
    return ConnIdIcConvertUtil.convertConnIdSchema(schema);
}
Also used : Schema(org.identityconnectors.framework.common.objects.Schema) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema) ConnectorFacade(org.identityconnectors.framework.api.ConnectorFacade)

Example 4 with Schema

use of org.identityconnectors.framework.common.objects.Schema in project midpoint by Evolveum.

the class ConnIdCapabilitiesAndSchemaParser method retrieveResourceCapabilitiesAndSchema.

/**
 * Retrieves and parses resource capabilities and schema.
 *
 * Schema is immutable after this method.
 */
void retrieveResourceCapabilitiesAndSchema(List<QName> generateObjectClasses, OperationResult result) throws CommunicationException, ConfigurationException, GenericFrameworkException, SchemaException {
    fetchSupportedOperations(result);
    // sets supportsSchema flag
    processOperationCapabilities();
    if (supportsSchema) {
        Schema connIdSchema = fetchConnIdSchema(result);
        if (connIdSchema == null) {
            addBasicReadCapability();
        } else {
            parseResourceSchema(connIdSchema, generateObjectClasses);
        }
    }
}
Also used : Schema(org.identityconnectors.framework.common.objects.Schema)

Aggregations

Schema (org.identityconnectors.framework.common.objects.Schema)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)1 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 IcSchema (eu.bcvsolutions.idm.ic.api.IcSchema)1 ConnectorFacade (org.identityconnectors.framework.api.ConnectorFacade)1