Search in sources :

Example 1 with CapabilitiesType

use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test030ResourceAndConnectorCaching.

@Test
public void test030ResourceAndConnectorCaching() throws Exception {
    TestUtil.displayTestTile("test030ResourceAndConnectorCaching");
    // GIVEN
    OperationResult result = new OperationResult(TestOpenDj.class.getName() + ".test010ResourceAndConnectorCaching");
    ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance(resource, ReadCapabilityType.class, false, result);
    assertNotNull("No configuredConnectorInstance", configuredConnectorInstance);
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    assertNotNull("No resource schema", resourceSchema);
    // WHEN
    PrismObject<ResourceType> resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
    // THEN
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    ResourceType resourceTypeAgain = resourceAgain.asObjectable();
    assertNotNull("No connector ref", resourceTypeAgain.getConnectorRef());
    assertNotNull("No connector ref OID", resourceTypeAgain.getConnectorRef().getOid());
    PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
    PrismContainer<Containerable> configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
    assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain));
    // Check resource schema caching
    ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext);
    assertNotNull("No resource schema (again)", resourceSchemaAgain);
    assertTrue("Resource schema was not cached", resourceSchema == resourceSchemaAgain);
    // Check capabilities caching
    CapabilitiesType capabilitiesType = resourceType.getCapabilities();
    assertNotNull("No capabilities fetched from provisioning", capabilitiesType);
    CachingMetadataType capCachingMetadataType = capabilitiesType.getCachingMetadata();
    assertNotNull("No capabilities caching metadata fetched from provisioning", capCachingMetadataType);
    CachingMetadataType capCachingMetadataTypeAgain = resourceTypeAgain.getCapabilities().getCachingMetadata();
    assertEquals("Capabilities caching metadata serial number has changed", capCachingMetadataType.getSerialNumber(), capCachingMetadataTypeAgain.getSerialNumber());
    assertEquals("Capabilities caching metadata timestamp has changed", capCachingMetadataType.getRetrievalTimestamp(), capCachingMetadataTypeAgain.getRetrievalTimestamp());
    // Rough test if everything is fine
    resource.asObjectable().setFetchResult(null);
    resourceAgain.asObjectable().setFetchResult(null);
    ObjectDelta<ResourceType> dummyResourceDiff = DiffUtil.diff(resource, resourceAgain);
    display("Dummy resource diff", dummyResourceDiff);
    assertTrue("The resource read again is not the same as the original. diff:" + dummyResourceDiff, dummyResourceDiff.isEmpty());
    // Now we stick our nose deep inside the provisioning impl. But we need
    // to make sure that the
    // configured connector is properly cached
    ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, false, result);
    assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAgain);
    assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain);
    // Check if the connector still works.
    OperationResult testResult = new OperationResult(TestOpenDj.class.getName() + ".test010ResourceAndConnectorCaching.test");
    configuredConnectorInstanceAgain.test(testResult);
    testResult.computeStatus();
    TestUtil.assertSuccess("Connector test failed", testResult);
    // Test connection should also refresh the connector by itself. So check if it has been refreshed
    ConnectorInstance configuredConnectorInstanceAfterTest = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, false, result);
    assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAfterTest);
    assertTrue("Connector instance was not cached", configuredConnectorInstanceAgain == configuredConnectorInstanceAfterTest);
    assertSteadyResource();
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Containerable(com.evolveum.midpoint.prism.Containerable) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) Test(org.testng.annotations.Test)

Example 2 with CapabilitiesType

use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project midpoint by Evolveum.

the class AbstractLdapTest method test030Capabilities.

@Test
public void test030Capabilities() throws Exception {
    final String TEST_NAME = "test030Capabilities";
    TestUtil.displayTestTile(this, TEST_NAME);
    CapabilitiesType capabilities = resourceType.getCapabilities();
    display("Resource capabilities", capabilities);
    assertNotNull("Null capabilities", capabilities);
    CapabilityCollectionType nativeCapabilitiesCollectionType = capabilities.getNative();
    assertNotNull("Null native capabilities type", nativeCapabilitiesCollectionType);
    List<Object> nativeCapabilities = nativeCapabilitiesCollectionType.getAny();
    assertNotNull("Null native capabilities", nativeCapabilities);
    assertFalse("Empty native capabilities", nativeCapabilities.isEmpty());
    assertCapability(nativeCapabilities, ReadCapabilityType.class);
    assertCapability(nativeCapabilities, CreateCapabilityType.class);
    assertCapability(nativeCapabilities, UpdateCapabilityType.class);
    assertCapability(nativeCapabilities, DeleteCapabilityType.class);
    // TODO: assert password capability. Check password readability.
    ActivationCapabilityType activationCapabilityType = CapabilityUtil.getCapability(nativeCapabilities, ActivationCapabilityType.class);
    assertActivationCapability(activationCapabilityType);
    assertAdditionalCapabilities(nativeCapabilities);
    assertStableSystem();
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with CapabilitiesType

use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project midpoint by Evolveum.

the class ResourceManager method supportsCapability.

private <T extends CapabilityType> boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection<Object> nativeCapabilities, Class<T> capabilityClass) {
    CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities();
    if (specifiedCapabilitiesType != null) {
        CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured();
        if (configuredCapCollectionType != null) {
            T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass);
            if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) {
                return false;
            }
        }
    }
    T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass);
    if (cap == null) {
        return false;
    }
    return CapabilityUtil.isCapabilityEnabled(cap);
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)

Example 4 with CapabilitiesType

use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project midpoint by Evolveum.

the class AbstractManualResourceTest method test003Connection.

@Test
public void test003Connection() throws Exception {
    final String TEST_NAME = "test003Connection";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // Check that there is a schema, but no capabilities before test (pre-condition)
    ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable();
    Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
    assertResourceSchemaBeforeTest(resourceXsdSchemaElementBefore);
    CapabilitiesType capabilities = resourceBefore.getCapabilities();
    if (capabilities != null) {
        AssertJUnit.assertNull("Native capabilities present before test connection. Bad test setup?", capabilities.getNative());
    }
    // WHEN
    OperationResult testResult = provisioningService.testResource(getResourceOid(), task);
    // THEN
    display("Test result", testResult);
    TestUtil.assertSuccess("Test resource failed (result)", testResult);
    PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result);
    ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
    display("Resource after test", resourceTypeRepoAfter);
    XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema();
    assertNotNull("No schema after test connection", xmlSchemaTypeAfter);
    Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceTypeRepoAfter);
    assertNotNull("No schema after test connection", resourceXsdSchemaElementAfter);
    String resourceXml = prismContext.serializeObjectToString(resourceRepoAfter, PrismContext.LANG_XML);
    display("Resource XML", resourceXml);
    CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata();
    assertNotNull("No caching metadata", cachingMetadata);
    assertNotNull("No retrievalTimestamp", cachingMetadata.getRetrievalTimestamp());
    assertNotNull("No serialNumber", cachingMetadata.getSerialNumber());
    Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter);
    ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resourceBefore.toString(), prismContext);
    assertNotNull("No schema after parsing", parsedSchema);
// schema will be checked in next test
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) Element(org.w3c.dom.Element) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) XmlSchemaType(com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Example 5 with CapabilitiesType

use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.

the class AbstractCswSource method getCapabilities.

protected CapabilitiesType getCapabilities() {
    CapabilitiesType caps = null;
    Subject subject = getSystemSubject();
    Csw csw = factory.getClientForSubject(subject);
    try {
        LOGGER.debug("Doing getCapabilities() call for CSW");
        GetCapabilitiesRequest request = new GetCapabilitiesRequest(CswConstants.CSW);
        request.setAcceptVersions(CswConstants.VERSION_2_0_2 + "," + CswConstants.VERSION_2_0_1);
        caps = csw.getCapabilities(request);
    } catch (CswException cswe) {
        LOGGER.info(CSW_SERVER_ERROR + " Received HTTP code '{}' from server for source with id='{}'. Set Logging to DEBUG for details.", cswe.getHttpStatus(), cswSourceConfiguration.getId());
        LOGGER.debug(CSW_SERVER_ERROR, cswe);
    } catch (WebApplicationException wae) {
        LOGGER.debug(handleWebApplicationException(wae), wae);
    } catch (Exception ce) {
        handleClientException(ce);
    }
    return caps;
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) WebApplicationException(javax.ws.rs.WebApplicationException) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Subject(ddf.security.Subject) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) WebApplicationException(javax.ws.rs.WebApplicationException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) JAXBException(javax.xml.bind.JAXBException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException)

Aggregations

CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)25 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)21 Test (org.junit.Test)20 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)19 GetCapabilitiesRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest)13 CapabilitiesType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 SectionsType (net.opengis.ows.v_1_0_0.SectionsType)6 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)5 Test (org.testng.annotations.Test)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)4 Csw (org.codice.ddf.spatial.ogc.csw.catalog.common.Csw)4 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 Task (com.evolveum.midpoint.task.api.Task)2 XmlSchemaType (com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType)2 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)2 Metacard (ddf.catalog.data.Metacard)2