Search in sources :

Example 21 with ConnectorType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.

the class NameStep method isConfigurationSchemaCompatible.

private boolean isConfigurationSchemaCompatible(PrismObject<ConnectorType> newConnectorObject) {
    if (newConnectorObject == null) {
        // shouldn't occur
        return true;
    }
    PrismContainer<?> configuration = ResourceTypeUtil.getConfigurationContainer(resourceModelRaw.getObject());
    if (configuration == null || configuration.isEmpty() || configuration.getValue().hasNoItems()) {
        // no config -> no loss
        return true;
    }
    // for the time being let us simply compare namespaces of the current and old connector
    PrismObject<ConnectorType> existingConnectorObject = getExistingConnector();
    if (existingConnectorObject == null) {
        return true;
    }
    ConnectorType existingConnector = existingConnectorObject.asObjectable();
    ConnectorType newConnector = newConnectorObject.asObjectable();
    return StringUtils.equals(existingConnector.getNamespace(), newConnector.getNamespace());
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)

Example 22 with ConnectorType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.

the class ConnectorTypeUtil method parseConnectorSchema.

/**
 * Returns parsed connector schema
 */
public static PrismSchema parseConnectorSchema(ConnectorType connectorType, PrismContext prismContext) throws SchemaException {
    Element connectorSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(connectorType);
    if (connectorSchemaElement == null) {
        return null;
    }
    PrismSchema connectorSchema = PrismSchemaImpl.parse(connectorSchemaElement, true, "schema for " + connectorType, prismContext);
    // Make sure that the config container definition has a correct compile-time class name
    QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart());
    PrismContainerDefinition<ConnectorConfigurationType> configurationContainerDefinition = connectorSchema.findContainerDefinitionByElementName(configContainerQName);
    configurationContainerDefinition.toMutable().setCompileTimeClass(ConnectorConfigurationType.class);
    return connectorSchema;
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element)

Example 23 with ConnectorType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.

the class ConnectorFactoryBuiltinImpl method createConnectorStruct.

private ConnectorStruct createConnectorStruct(Class connectorClass, ManagedConnector annotation) throws ObjectNotFoundException, SchemaException {
    ConnectorStruct struct = new ConnectorStruct();
    struct.connectorClass = connectorClass;
    ConnectorType connectorType = new ConnectorType();
    String bundleName = connectorClass.getPackage().getName();
    String type = annotation.type();
    if (type == null || type.isEmpty()) {
        type = connectorClass.getSimpleName();
    }
    String version = annotation.version();
    UcfUtil.addConnectorNames(connectorType, "Built-in", bundleName, type, version, null);
    connectorType.setConnectorBundle(bundleName);
    connectorType.setConnectorType(type);
    connectorType.setVersion(version);
    connectorType.setFramework(SchemaConstants.UCF_FRAMEWORK_URI_BUILTIN);
    String namespace = CONFIGURATION_NAMESPACE_PREFIX + bundleName + "/" + type;
    connectorType.setNamespace(namespace);
    struct.connectorObject = connectorType;
    PrismSchema connectorSchema = generateConnectorConfigurationSchema(struct);
    if (connectorSchema != null) {
        LOGGER.trace("Generated connector schema for {}: {} definitions", connectorType, connectorSchema.getDefinitions().size());
        UcfUtil.setConnectorSchema(connectorType, connectorSchema);
        struct.connectorConfigurationSchema = connectorSchema;
    } else {
        LOGGER.warn("No connector schema generated for {}", connectorType);
    }
    return struct;
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)

Example 24 with ConnectorType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.

the class AbstractAdTest method test001ConnectorHostDiscovery.

@Test
public void test001ConnectorHostDiscovery() throws Exception {
    final String TEST_NAME = "test001ConnectorHostDiscovery";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.discoverConnectors(connectorHostType, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    SearchResultList<PrismObject<ConnectorType>> connectors = modelService.searchObjects(ConnectorType.class, null, null, task, result);
    boolean found = false;
    for (PrismObject<ConnectorType> connector : connectors) {
        if (CONNECTOR_AD_TYPE.equals(connector.asObjectable().getConnectorType())) {
            display("Found connector", connector);
            found = true;
        }
    }
    assertTrue("AD Connector not found", found);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 25 with ConnectorType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType in project midpoint by Evolveum.

the class TestSanity method test002AddDerbyResource.

@Test
public void test002AddDerbyResource() throws Exception {
    final String TEST_NAME = "test002AddDerbyResource";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME);
    checkRepoOpenDjResource();
    assertNoRepoCache();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DERBY_FILENAME));
    assertParentConsistency(resource);
    fillInConnectorRef(resource, IntegrationTestTools.DBTABLE_CONNECTOR_TYPE, result);
    OperationResultType resultType = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType);
    Holder<String> oidHolder = new Holder<String>();
    display("Adding Derby Resource", resource);
    // WHEN
    addObjectViaModelWS(resource.asObjectable(), null, oidHolder, resultHolder);
    // THEN
    // Check if Derby resource was imported correctly
    PrismObject<ResourceType> derbyResource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result);
    AssertJUnit.assertEquals(RESOURCE_DERBY_OID, derbyResource.getOid());
    assertNoRepoCache();
    String dbConnectorOid = derbyResource.asObjectable().getConnectorRef().getOid();
    PrismObject<ConnectorType> dbConnector = repositoryService.getObject(ConnectorType.class, dbConnectorOid, null, result);
    display("DB Connector: ", dbConnector);
    // Check if password was encrypted during import
    // via JAXB
    Object configurationPropertiesElement = JAXBUtil.findElement(derbyResource.asObjectable().getConnectorConfiguration().getAny(), new QName(dbConnector.asObjectable().getNamespace(), "configurationProperties"));
    Object passwordElement = JAXBUtil.findElement(JAXBUtil.listChildElements(configurationPropertiesElement), new QName(dbConnector.asObjectable().getNamespace(), "password"));
    System.out.println("Password element: " + passwordElement);
    // via prisms
    PrismContainerValue configurationProperties = derbyResource.findContainer(new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, new QName("configurationProperties"))).getValue();
    PrismProperty password = configurationProperties.findProperty(new QName(dbConnector.asObjectable().getNamespace(), "password"));
    System.out.println("Password property: " + password);
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)39 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 Test (org.testng.annotations.Test)17 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 Task (com.evolveum.midpoint.task.api.Task)12 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)12 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)8 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)8 SystemException (com.evolveum.midpoint.util.exception.SystemException)8 QName (javax.xml.namespace.QName)7 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)6 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)4 ConnectorConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType)4 ConnectorHostType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType)4 XmlSchemaType (com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType)4 Element (org.w3c.dom.Element)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3