Search in sources :

Example 36 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ProvisioningServiceImpl method getConnectorOperationalStatus.

@Override
public List<ConnectorOperationalStatus> getConnectorOperationalStatus(String resourceOid, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createMinorSubresult(ProvisioningService.class.getName() + ".getConnectorOperationalStatus");
    result.addParam("resourceOid", resourceOid);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    PrismObject<ResourceType> resource;
    try {
        resource = resourceManager.getResource(resourceOid, null, task, result);
    } catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException ex) {
        ProvisioningUtil.recordFatalError(LOGGER, result, ex.getMessage(), ex);
        throw ex;
    }
    List<ConnectorOperationalStatus> stats;
    try {
        stats = resourceManager.getConnectorOperationalStatus(resource, result);
    } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException ex) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Getting operations status from connector for resource " + resourceOid + " failed: " + ex.getMessage(), ex);
        throw ex;
    }
    result.computeStatus();
    result.cleanupResult();
    return stats;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 37 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ResourceManager method testConnectionConnector.

public void testConnectionConnector(ConnectorSpec connectorSpec, Map<String, Collection<Object>> capabilityMap, Task task, OperationResult parentResult) {
    // === test INITIALIZATION ===
    OperationResult initResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_INITIALIZATION.getOperation());
    ConnectorInstance connector;
    try {
        // TODO: this returns configured instance. Then there is another configuration down below.
        // this means double configuration of the connector. TODO: clean this up
        connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, true, initResult);
        initResult.recordSuccess();
    } catch (ObjectNotFoundException e) {
        // The connector was not found. The resource definition is either
        // wrong or the connector is not
        // installed.
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("The connector was not found: " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Schema error while dealing with the connector definition: " + e.getMessage(), e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Unexpected runtime error: " + e.getMessage(), e);
        return;
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    LOGGER.debug("Testing connection using {}", connectorSpec);
    // === test CONFIGURATION ===
    OperationResult configResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_CONFIGURATION.getOperation());
    try {
        PrismObject<ResourceType> resource = connectorSpec.getResource();
        PrismObjectDefinition<ResourceType> newResourceDefinition = resource.getDefinition().clone();
        applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, configResult);
        PrismContainerValue<ConnectorConfigurationType> connectorConfiguration = connectorSpec.getConnectorConfiguration().getValue();
        connector.configure(connectorConfiguration, configResult);
        configResult.recordSuccess();
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Communication error", e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Generic error", e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Schema error", e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Configuration error", e);
        return;
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Object not found", e);
        return;
    } catch (ExpressionEvaluationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Expression error", e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Unexpected runtime error", e);
        return;
    }
    // === test CONNECTION ===
    // delegate the main part of the test to the connector
    connector.test(parentResult);
    parentResult.computeStatus();
    if (!parentResult.isAcceptable()) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.DOWN, parentResult);
        // messages.
        return;
    } else {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.UP, parentResult);
    }
    OperationResult capabilitiesResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_CAPABILITIES.getOperation());
    try {
        InternalMonitor.recordConnectorCapabilitiesFetchCount();
        Collection<Object> capabilities = connector.fetchCapabilities(capabilitiesResult);
        capabilityMap.put(connectorSpec.getConnectorName(), capabilities);
        capabilitiesResult.recordSuccess();
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Communication error", e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Generic error", e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Configuration error", e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Unexpected runtime error", e);
        return;
    }
}
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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 38 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ResourceManager method testConnection.

public void testConnection(PrismObject<ResourceType> resource, Task task, OperationResult parentResult) {
    List<ConnectorSpec> allConnectorSpecs;
    try {
        allConnectorSpecs = getAllConnectorSpecs(resource);
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        parentResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    Map<String, Collection<Object>> capabilityMap = new HashMap<>();
    for (ConnectorSpec connectorSpec : allConnectorSpecs) {
        OperationResult connectorTestResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_TEST.getOperation());
        connectorTestResult.addParam(OperationResult.PARAM_NAME, connectorSpec.getConnectorName());
        connectorTestResult.addParam(OperationResult.PARAM_OID, connectorSpec.getConnectorOid());
        testConnectionConnector(connectorSpec, capabilityMap, task, connectorTestResult);
        connectorTestResult.computeStatus();
    }
    // === test SCHEMA ===
    OperationResult schemaResult = parentResult.createSubresult(ConnectorTestOperation.RESOURCE_SCHEMA.getOperation());
    ResourceSchema schema = null;
    try {
        schema = fetchResourceSchema(resource, capabilityMap, task, schemaResult);
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Generic error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    if (schema == null || schema.isEmpty()) {
        // If there is a static schema in resource definition this may still be OK
        try {
            schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
        } catch (SchemaException e) {
            modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
            schemaResult.recordFatalError(e);
            return;
        }
        if (schema == null || schema.isEmpty()) {
            modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
            schemaResult.recordFatalError("Connector does not support schema and no static schema available");
            return;
        }
    }
    // capability.
    try {
        resource = completeResource(resource, schema, true, capabilityMap, null, task, schemaResult);
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Object not found (unexpected error, probably a bug): " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Schema processing error (probably connector bug): " + e.getMessage(), e);
        return;
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (ExpressionEvaluationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Expression error: " + e.getMessage(), e);
        return;
    }
    schemaResult.recordSuccess();
// TODO: connector sanity (e.g. refined schema, at least one account type, identifiers
// in schema, etc.)
}
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) HashMap(java.util.HashMap) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection)

Example 39 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ProvisioningServiceImpl method synchronize.

@SuppressWarnings("rawtypes")
@Override
public int synchronize(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    Validate.notNull(shadowCoordinates, "Coordinates oid must not be null.");
    String resourceOid = shadowCoordinates.getResourceOid();
    Validate.notNull(resourceOid, "Resource oid must not be null.");
    Validate.notNull(task, "Task must not be null.");
    Validate.notNull(parentResult, "Operation result must not be null.");
    OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".synchronize");
    result.addParam(OperationResult.PARAM_OID, resourceOid);
    result.addParam(OperationResult.PARAM_TASK, task.toString());
    int processedChanges = 0;
    try {
        // Resolve resource
        PrismObject<ResourceType> resource = getObject(ResourceType.class, resourceOid, null, task, result);
        ResourceType resourceType = resource.asObjectable();
        LOGGER.trace("**PROVISIONING: Start synchronization of resource {} ", resourceType);
        // getting token form task
        PrismProperty tokenProperty = getTokenProperty(shadowCoordinates, task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("**PROVISIONING: Got token property: {} from the task extension.", SchemaDebugUtil.prettyPrint(tokenProperty));
        }
        processedChanges = getShadowCache(Mode.STANDARD).synchronize(shadowCoordinates, tokenProperty, task, result);
        LOGGER.debug("Synchronization of {} done, token {}, {} changes", resource, tokenProperty, processedChanges);
    } catch (ObjectNotFoundException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object not found: " + e.getMessage(), e);
        throw e;
    } catch (CommunicationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: communication problem: " + e.getMessage(), e);
        throw e;
    } catch (ObjectAlreadyExistsException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object already exists problem: " + e.getMessage(), e);
        throw new SystemException(e);
    } catch (GenericFrameworkException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: generic connector framework error: " + e.getMessage(), e);
        throw new GenericConnectorException(e.getMessage(), e);
    } catch (SchemaException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: schema problem: " + e.getMessage(), e);
        throw e;
    } catch (SecurityViolationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: security violation: " + e.getMessage(), e);
        throw e;
    } catch (ConfigurationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: configuration problem: " + e.getMessage(), e);
        throw e;
    } catch (RuntimeException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: unexpected problem: " + e.getMessage(), e);
        throw e;
    } catch (ExpressionEvaluationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: expression error: " + e.getMessage(), e);
        throw e;
    }
    result.recordSuccess();
    result.cleanupResult();
    return processedChanges;
}
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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) LabeledString(com.evolveum.midpoint.schema.LabeledString) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) SystemException(com.evolveum.midpoint.util.exception.SystemException) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 40 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ProvisioningServiceImpl method countObjects.

public <T extends ObjectType> Integer countObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createMinorSubresult(ProvisioningService.class.getName() + ".countObjects");
    result.addParam("objectType", type);
    result.addParam("query", query);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    ObjectFilter filter = null;
    if (query != null) {
        filter = ObjectQueryUtil.simplify(query.getFilter());
        query = query.cloneEmpty();
        query.setFilter(filter);
    }
    if (filter != null && filter instanceof NoneFilter) {
        result.recordSuccessIfUnknown();
        result.cleanupResult();
        LOGGER.trace("Finished counting. Nothing to do. Filter is NONE");
        return 0;
    }
    GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options);
    if (!ShadowType.class.isAssignableFrom(type) || GetOperationOptions.isNoFetch(rootOptions) || GetOperationOptions.isRaw(rootOptions)) {
        int count = getCacheRepositoryService().countObjects(type, query, parentResult);
        result.computeStatus();
        result.recordSuccessIfUnknown();
        result.cleanupResult();
        return count;
    }
    Integer count;
    try {
        count = getShadowCache(Mode.STANDARD).countObjects(query, task, result);
        result.computeStatus();
    } catch (ConfigurationException | CommunicationException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, null, e);
        throw e;
    } finally {
        result.cleanupResult();
    }
    return count;
}
Also used : NoneFilter(com.evolveum.midpoint.prism.query.NoneFilter) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)110 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)86 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)81 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)71 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)65 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 SystemException (com.evolveum.midpoint.util.exception.SystemException)29 Task (com.evolveum.midpoint.task.api.Task)27 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)26 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)20 QName (javax.xml.namespace.QName)20 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)18 ArrayList (java.util.ArrayList)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)13 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)13