Exemplo n.º 1
0
  @Test
  public void test015SearchLdapConnector() throws Exception {
    final String TEST_NAME = "test015SearchLdapConnector";
    displayTestTitle(TEST_NAME);

    QueryType query = new QueryType();
    query.setFilter(
        ModelClientUtil.parseSearchFilterType(
            "<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >"
                + "<path>c:connectorType</path>"
                + "<value>"
                + CONNECTOR_LDAP_TYPE
                + "</value>"
                + "</equal>"));

    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();

    // WHEN
    modelPort.searchObjects(
        ModelClientUtil.getTypeQName(ConnectorType.class),
        query,
        null,
        objectListHolder,
        resultHolder);

    // THEN
    assertSuccess(resultHolder);
    ObjectListType objectList = objectListHolder.value;
    assertEquals("Unexpected number of LDAP connectors", 1, objectList.getObject().size());
    ConnectorType ldapConnector = (ConnectorType) objectList.getObject().get(0);
    assertNotNull("Null LDAP connector", ldapConnector);
    connectorLdapOid = ldapConnector.getOid();
    assertNotNull("Null LDAP connector OID", connectorLdapOid);
  }
  /**
   * Transforms midPoint XML configuration of the connector to the ICF configuration.
   *
   * <p>The "configuration" part of the XML resource definition will be used.
   *
   * <p>The provided ICF APIConfiguration will be modified, some values may be overwritten.
   *
   * @param apiConfig ICF connector configuration
   * @param resourceType midPoint XML configuration
   * @throws SchemaException
   * @throws ConfigurationException
   */
  public APIConfiguration transformConnectorConfiguration(PrismContainerValue configuration)
      throws SchemaException, ConfigurationException {

    APIConfiguration apiConfig = cinfo.createDefaultAPIConfiguration();
    ConfigurationProperties configProps = apiConfig.getConfigurationProperties();

    // The namespace of all the configuration properties specific to the
    // connector instance will have a connector instance namespace. This
    // namespace can be found in the resource definition.
    String connectorConfNs = connectorType.getNamespace();

    PrismContainer configurationPropertiesContainer =
        configuration.findContainer(
            ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    if (configurationPropertiesContainer == null) {
      // Also try this. This is an older way.
      configurationPropertiesContainer =
          configuration.findContainer(
              new QName(
                  connectorConfNs,
                  ConnectorFactoryIcfImpl
                      .CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME));
    }

    transformConnectorConfiguration(configProps, configurationPropertiesContainer, connectorConfNs);

    PrismContainer connectorPoolContainer =
        configuration.findContainer(
            new QName(
                ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION,
                ConnectorFactoryIcfImpl
                    .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME));
    ObjectPoolConfiguration connectorPoolConfiguration = apiConfig.getConnectorPoolConfiguration();
    transformConnectorPoolConfiguration(connectorPoolConfiguration, connectorPoolContainer);

    PrismProperty producerBufferSizeProperty =
        configuration.findProperty(
            new QName(
                ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION,
                ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME));
    if (producerBufferSizeProperty != null) {
      apiConfig.setProducerBufferSize(parseInt(producerBufferSizeProperty));
    }

    PrismContainer connectorTimeoutsContainer =
        configuration.findContainer(
            new QName(
                ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION,
                ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME));
    transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer);

    PrismContainer resultsHandlerConfigurationContainer =
        configuration.findContainer(
            new QName(
                ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION,
                ConnectorFactoryIcfImpl
                    .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME));
    ResultsHandlerConfiguration resultsHandlerConfiguration =
        apiConfig.getResultsHandlerConfiguration();
    transformResultsHandlerConfiguration(
        resultsHandlerConfiguration, resultsHandlerConfigurationContainer);

    return apiConfig;
  }