Search in sources :

Example 31 with CapabilitiesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType in project ddf by codice.

the class CswEndpointTest method testThirdPartyTypeNames.

@Test
public void testThirdPartyTypeNames() throws Exception {
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gcr);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(countTypeNames(ct, CswConstants.DESCRIBE_RECORD, CswConstants.TYPE_NAME_PARAMETER, THIRD_PARTY_TYPE_NAME), is(1L));
    assertThat(countTypeNames(ct, CswConstants.GET_RECORDS, CswConstants.TYPE_NAMES_PARAMETER, THIRD_PARTY_TYPE_NAME), is(1L));
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 32 with CapabilitiesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.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 = modelService.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) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 33 with CapabilitiesType

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

the class ResourceObjectConverter method determineActivationChange.

private Collection<Operation> determineActivationChange(ProvisioningContext ctx, ShadowType shadow, Collection<? extends ItemDelta> objectChange, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ResourceType resource = ctx.getResource();
    Collection<Operation> operations = new ArrayList<>();
    CapabilitiesType connectorCapabilities = ctx.getConnectorCapabilities(UpdateCapabilityType.class);
    ActivationCapabilityType activationCapability = CapabilityUtil.getEffectiveCapability(connectorCapabilities, ActivationCapabilityType.class);
    // administrativeStatus
    PropertyDelta<ActivationStatusType> enabledPropertyDelta = PropertyDelta.findPropertyDelta(objectChange, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    if (enabledPropertyDelta != null) {
        if (activationCapability == null) {
            SchemaException e = new SchemaException("Attempt to change activation administrativeStatus on " + resource + " which does not have the capability");
            result.recordFatalError(e);
            throw e;
        }
        ActivationStatusType status = enabledPropertyDelta.getPropertyNewMatchingPath().getRealValue();
        LOGGER.trace("Found activation administrativeStatus change to: {}", status);
        if (CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
            // Native activation, need to check if there is not also change to simulated activation which may be in conflict
            checkSimulatedActivationAdministrativeStatus(ctx, objectChange, status, activationCapability, shadow, result);
            operations.add(new PropertyModificationOperation(enabledPropertyDelta));
        } else {
            // Try to simulate activation capability
            PropertyModificationOperation activationAttribute = convertToSimulatedActivationAdministrativeStatusAttribute(ctx, enabledPropertyDelta, shadow, status, activationCapability, result);
            if (activationAttribute != null) {
                operations.add(activationAttribute);
            }
        }
    }
    // validFrom
    PropertyDelta<XMLGregorianCalendar> validFromPropertyDelta = PropertyDelta.findPropertyDelta(objectChange, SchemaConstants.PATH_ACTIVATION_VALID_FROM);
    if (validFromPropertyDelta != null) {
        if (CapabilityUtil.getEffectiveActivationValidFrom(activationCapability) == null) {
            SchemaException e = new SchemaException("Attempt to change activation validFrom on " + resource + " which does not have the capability");
            result.recordFatalError(e);
            throw e;
        }
        XMLGregorianCalendar xmlCal = validFromPropertyDelta.getPropertyNewMatchingPath().getRealValue();
        LOGGER.trace("Found activation validFrom change to: {}", xmlCal);
        operations.add(new PropertyModificationOperation(validFromPropertyDelta));
    }
    // validTo
    PropertyDelta<XMLGregorianCalendar> validToPropertyDelta = PropertyDelta.findPropertyDelta(objectChange, SchemaConstants.PATH_ACTIVATION_VALID_TO);
    if (validToPropertyDelta != null) {
        if (CapabilityUtil.getEffectiveActivationValidTo(activationCapability) == null) {
            SchemaException e = new SchemaException("Attempt to change activation validTo on " + resource + " which does not have the capability");
            result.recordFatalError(e);
            throw e;
        }
        XMLGregorianCalendar xmlCal = validToPropertyDelta.getPropertyNewMatchingPath().getRealValue();
        LOGGER.trace("Found activation validTo change to: {}", xmlCal);
        operations.add(new PropertyModificationOperation(validToPropertyDelta));
    }
    PropertyDelta<LockoutStatusType> lockoutPropertyDelta = PropertyDelta.findPropertyDelta(objectChange, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
    if (lockoutPropertyDelta != null) {
        if (activationCapability == null) {
            SchemaException e = new SchemaException("Attempt to change activation lockoutStatus on " + resource + " which does not have the capability");
            result.recordFatalError(e);
            throw e;
        }
        LockoutStatusType status = lockoutPropertyDelta.getPropertyNewMatchingPath().getRealValue();
        LOGGER.trace("Found activation lockoutStatus change to: {}", status);
        if (CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
            // Native lockout, need to check if there is not also change to simulated activation which may be in conflict
            checkSimulatedActivationLockoutStatus(ctx, objectChange, status, activationCapability, shadow, result);
            operations.add(new PropertyModificationOperation(lockoutPropertyDelta));
        } else {
            // Try to simulate lockout capability
            PropertyModificationOperation activationAttribute = convertToSimulatedActivationLockoutStatusAttribute(ctx, lockoutPropertyDelta, shadow, status, activationCapability, result);
            operations.add(activationAttribute);
        }
    }
    return operations;
}
Also used : ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 34 with CapabilitiesType

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

the class AbstractBasicDummyTest method test025CapabilitiesRepo.

/**
	 * Check if the cached native capabilities were properly stored in the repo 
	 */
@Test
public void test025CapabilitiesRepo() throws Exception {
    final String TEST_NAME = "test025CapabilitiesRepo";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    // WHEN
    PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
    ;
    // THEN
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    // Check native capabilities
    ResourceType resourceType = resource.asObjectable();
    CapabilitiesType capabilitiesType = resourceType.getCapabilities();
    assertNotNull("No capabilities in repo, the capabilities were not cached", capabilitiesType);
    CapabilityCollectionType nativeCapabilities = capabilitiesType.getNative();
    System.out.println("Native capabilities: " + PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
    System.out.println("resource: " + resourceType.asPrismObject().debugDump());
    List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
    assertNotNull("password native capability not present", capCred.getPassword());
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
    if (supportsActivation()) {
        assertNotNull("native activation capability not present", capAct);
        assertNotNull("native activation status capability not present", capAct.getStatus());
    } else {
        assertNull("native activation capability sneaked in", capAct);
    }
    TestConnectionCapabilityType capTest = CapabilityUtil.getCapability(nativeCapabilitiesList, TestConnectionCapabilityType.class);
    assertNotNull("native test capability not present", capTest);
    ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
    assertNotNull("native script capability not present", capScript);
    assertNotNull("No host in native script capability", capScript.getHost());
    assertFalse("No host in native script capability", capScript.getHost().isEmpty());
    // TODO: better look inside
    CachingMetadataType repoCapabilitiesCachingMetadataType = capabilitiesType.getCachingMetadata();
    assertNotNull("No repo capabilities caching metadata", repoCapabilitiesCachingMetadataType);
    assertNotNull("No repo capabilities caching metadata timestamp", repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
    assertNotNull("No repo capabilities caching metadata serial number", repoCapabilitiesCachingMetadataType.getSerialNumber());
    assertEquals("Repo capabilities caching metadata timestamp does not match previously returned value", capabilitiesCachingMetadataType.getRetrievalTimestamp(), repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
    assertEquals("Repo capabilities caching metadata serial does not match previously returned value", capabilitiesCachingMetadataType.getSerialNumber(), repoCapabilitiesCachingMetadataType.getSerialNumber());
    assertSteadyResource();
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) TestConnectionCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ScriptCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) PrismObject(com.evolveum.midpoint.prism.PrismObject) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) Test(org.testng.annotations.Test)

Example 35 with CapabilitiesType

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

the class ResourceManager method isComplete.

private boolean isComplete(PrismObject<ResourceType> resource) {
    ResourceType resourceType = resource.asObjectable();
    Element xsdSchema = ResourceTypeUtil.getResourceXsdSchema(resource);
    if (xsdSchema == null) {
        return false;
    }
    CapabilitiesType capabilitiesType = resourceType.getCapabilities();
    if (capabilitiesType == null) {
        return false;
    }
    CachingMetadataType capCachingMetadata = capabilitiesType.getCachingMetadata();
    if (capCachingMetadata == null) {
        return false;
    }
    return true;
}
Also used : CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) Element(org.w3c.dom.Element) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)

Aggregations

CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)45 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)40 Test (org.junit.Test)40 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)38 GetCapabilitiesRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest)24 SectionsType (net.opengis.ows.v_1_0_0.SectionsType)12 CapabilitiesType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 DomainType (net.opengis.ows.v_1_0_0.DomainType)5 Operation (net.opengis.ows.v_1_0_0.Operation)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)4 Test (org.testng.annotations.Test)4 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)2 Task (com.evolveum.midpoint.task.api.Task)2 Metacard (ddf.catalog.data.Metacard)2