Search in sources :

Example 26 with Host

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType.Host in project midpoint by Evolveum.

the class ConnectorManager method getConnectorTypeReadOnly.

public ConnectorType getConnectorTypeReadOnly(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException {
    if (connectorSpec.getConnectorOid() == null) {
        result.recordFatalError("Connector OID missing in " + connectorSpec);
        throw new ObjectNotFoundException("Connector OID missing in " + connectorSpec);
    }
    String connOid = connectorSpec.getConnectorOid();
    ConnectorType connectorType = connectorTypeCache.get(connOid);
    if (connectorType == null) {
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly());
        PrismObject<ConnectorType> repoConnector = repositoryService.getObject(ConnectorType.class, connOid, options, result);
        connectorType = repoConnector.asObjectable();
        connectorTypeCache.put(connOid, connectorType);
    } else {
        String currentConnectorVersion = repositoryService.getVersion(ConnectorType.class, connOid, result);
        if (!currentConnectorVersion.equals(connectorType.getVersion())) {
            Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly());
            PrismObject<ConnectorType> repoConnector = repositoryService.getObject(ConnectorType.class, connOid, options, result);
            connectorType = repoConnector.asObjectable();
            connectorTypeCache.put(connOid, connectorType);
        }
    }
    if (connectorType.getConnectorHost() == null && connectorType.getConnectorHostRef() != null) {
        // We need to resolve the connector host
        String connectorHostOid = connectorType.getConnectorHostRef().getOid();
        PrismObject<ConnectorHostType> connectorHost = repositoryService.getObject(ConnectorHostType.class, connectorHostOid, null, result);
        connectorType.setConnectorHost(connectorHost.asObjectable());
    }
    PrismObject<ConnectorType> connector = connectorType.asPrismObject();
    Object userDataEntry = connector.getUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA);
    if (userDataEntry == null) {
        InternalMonitor.recordConnectorSchemaParse();
        PrismSchema connectorSchema = ConnectorTypeUtil.parseConnectorSchema(connectorType, prismContext);
        if (connectorSchema == null) {
            throw new SchemaException("No connector schema in " + connectorType);
        }
        connector.setUserData(USER_DATA_KEY_PARSED_CONNECTOR_SCHEMA, connectorSchema);
    }
    return connectorType;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 Test (org.testng.annotations.Test)11 Task (com.evolveum.midpoint.task.api.Task)8 ScriptCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)7 ConnectorHostType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)5 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)5 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)5 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)5 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)5 QName (javax.xml.namespace.QName)5 Entry (org.apache.directory.api.ldap.model.entry.Entry)5 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)3 TestConnectionCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType)3