Search in sources :

Example 21 with ConnectorInstance

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

the class ResourceManager method updateResourceSchema.

private void updateResourceSchema(List<ConnectorSpec> allConnectorSpecs, OperationResult parentResult, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException {
    ResourceSchema resourceSchema = ResourceSchemaFactory.getRawSchema(resource);
    if (resourceSchema != null) {
        for (ConnectorSpec connectorSpec : allConnectorSpecs) {
            ConnectorInstance instance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult);
            instance.updateSchema(resourceSchema);
        }
    }
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)

Example 22 with ConnectorInstance

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

the class ResourceManager method executeScript.

public Object executeScript(String resourceOid, ProvisioningScriptType script, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PrismObject<ResourceType> resource = getResource(resourceOid, null, task, result);
    ConnectorSpec connectorSpec = selectConnectorSpec(resource, ScriptCapabilityType.class);
    if (connectorSpec == null) {
        throw new UnsupportedOperationException("No connector supports script capability");
    }
    ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
    ExecuteProvisioningScriptOperation scriptOperation = ProvisioningUtil.convertToScriptOperation(script, "script on " + resource, prismContext);
    try {
        UcfExecutionContext ucfCtx = new UcfExecutionContext(lightweightIdentifierGenerator, resource.asObjectable(), task);
        return connectorInstance.executeScript(scriptOperation, ucfCtx, result);
    } catch (GenericFrameworkException e) {
        // Not expected. Transform to system exception
        result.recordFatalError("Generic provisioning framework error", e);
        throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e);
    }
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ExecuteProvisioningScriptOperation(com.evolveum.midpoint.provisioning.ucf.api.ExecuteProvisioningScriptOperation) UcfExecutionContext(com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext)

Example 23 with ConnectorInstance

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

the class ResourceManager method completeConnectorCapabilities.

private void completeConnectorCapabilities(ConnectorSpec connectorSpec, CapabilitiesType capType, ItemPath itemPath, boolean forceRefresh, Collection<Object> retrievedCapabilities, Collection<ItemDelta<?, ?>> modifications, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
    if (capType.getNative() != null && !capType.getNative().getAny().isEmpty()) {
        if (!forceRefresh) {
            CachingMetadataType cachingMetadata = capType.getCachingMetadata();
            if (cachingMetadata == null) {
                cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
                modifications.add(prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_CACHING_METADATA), connectorSpec.getResource().getDefinition(), cachingMetadata));
            }
            return;
        }
    }
    if (retrievedCapabilities == null) {
        try {
            InternalMonitor.recordCount(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT);
            ConnectorInstance connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
            retrievedCapabilities = connector.fetchCapabilities(result);
        } catch (GenericFrameworkException e) {
            throw new GenericConnectorException("Generic error in connector " + connectorSpec + ": " + e.getMessage(), e);
        }
    }
    CapabilityCollectionType nativeCapType = new CapabilityCollectionType();
    capType.setNative(nativeCapType);
    nativeCapType.getAny().addAll(retrievedCapabilities);
    CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
    capType.setCachingMetadata(cachingMetadata);
    // noinspection unchecked
    ObjectDelta<ResourceType> capabilitiesReplaceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), itemPath, capType.asPrismContainerValue().clone());
    modifications.addAll(capabilitiesReplaceDelta.getModifications());
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException)

Example 24 with ConnectorInstance

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

the class ResourceManager method getConnectorOperationalStatus.

public List<ConnectorOperationalStatus> getConnectorOperationalStatus(PrismObject<ResourceType> resource, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
    List<ConnectorOperationalStatus> statuses = new ArrayList<>();
    for (ConnectorSpec connectorSpec : getAllConnectorSpecs(resource)) {
        ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
        ConnectorOperationalStatus operationalStatus = connectorInstance.getOperationalStatus();
        if (operationalStatus != null) {
            operationalStatus.setConnectorName(connectorSpec.getConnectorName());
            statuses.add(operationalStatus);
        }
    }
    return statuses;
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 25 with ConnectorInstance

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

the class ResourceManager method fetchResourceSchema.

private ResourceSchema fetchResourceSchema(PrismObject<ResourceType> resource, Map<String, Collection<Object>> capabilityMap, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException, ObjectNotFoundException, SchemaException {
    ConnectorSpec connectorSpec = selectConnectorSpec(resource, capabilityMap, SchemaCapabilityType.class);
    if (connectorSpec == null) {
        LOGGER.debug("No connector has schema capability, cannot fetch resource schema");
        return null;
    }
    InternalMonitor.recordCount(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT);
    List<QName> generateObjectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource);
    ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, parentResult);
    LOGGER.debug("Trying to get schema from {}, objectClasses to generate: {}", connectorSpec, generateObjectClasses);
    ResourceSchema rawResourceSchema = connectorInstance.fetchResourceSchema(parentResult);
    if (ResourceTypeUtil.isValidateSchema(resource.asObjectable())) {
        ResourceTypeUtil.validateSchema(rawResourceSchema, resource);
    }
    return rawResourceSchema;
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) QName(javax.xml.namespace.QName)

Aggregations

ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)29 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 GenericConnectorException (com.evolveum.midpoint.provisioning.api.GenericConnectorException)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 Test (org.testng.annotations.Test)5 AbstractManagedConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManagedConnectorInstance)4 AbstractManualConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.connectors.AbstractManualConnectorInstance)4 ResourceObjectIdentification (com.evolveum.midpoint.schema.processor.ResourceObjectIdentification)4 Task (com.evolveum.midpoint.task.api.Task)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)3 Containerable (com.evolveum.midpoint.prism.Containerable)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)3 QName (javax.xml.namespace.QName)3 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)2