Search in sources :

Example 6 with CapabilitiesType

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

the class ResourceObjectConverter method transformActivationAttributesAdd.

private void transformActivationAttributesAdd(ProvisioningContext ctx, ShadowType shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    final ActivationType activation = shadow.getActivation();
    if (activation == null) {
        return;
    }
    PrismContainer attributesContainer = shadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES);
    CapabilitiesType connectorCapabilities = ctx.getConnectorCapabilities(CreateCapabilityType.class);
    ActivationCapabilityType activationCapability = CapabilityUtil.getEffectiveCapability(connectorCapabilities, ActivationCapabilityType.class);
    if (activation.getAdministrativeStatus() != null) {
        if (!CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
            ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapability, shadow, result);
            if (capActStatus == null) {
                throw new SchemaException("Attempt to change activation/administrativeStatus on " + ctx.getResource() + " that has neither native" + " nor simulated activation capability");
            }
            ResourceAttribute<?> newSimulatedAttr = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result);
            if (newSimulatedAttr != null) {
                Class<?> simulatedAttrValueClass = getAttributeValueClass(ctx, shadow, newSimulatedAttr, capActStatus);
                Object newSimulatedAttrRealValue;
                if (activation.getAdministrativeStatus() == ActivationStatusType.ENABLED) {
                    newSimulatedAttrRealValue = getEnableValue(capActStatus, simulatedAttrValueClass);
                } else {
                    newSimulatedAttrRealValue = getDisableValue(capActStatus, simulatedAttrValueClass);
                }
                Item existingSimulatedAttr = attributesContainer.findItem(newSimulatedAttr.getElementName());
                if (!isBlank(newSimulatedAttrRealValue)) {
                    PrismPropertyValue newSimulatedAttrValue = new PrismPropertyValue(newSimulatedAttrRealValue);
                    if (existingSimulatedAttr == null) {
                        newSimulatedAttr.add(newSimulatedAttrValue);
                        attributesContainer.add(newSimulatedAttr);
                    } else {
                        existingSimulatedAttr.replace(newSimulatedAttrValue);
                    }
                } else if (existingSimulatedAttr != null) {
                    attributesContainer.remove(existingSimulatedAttr);
                }
                activation.setAdministrativeStatus(null);
            }
        }
    }
    // TODO enable non-string lockout values (MID-3374)
    if (activation.getLockoutStatus() != null) {
        if (!CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
            ActivationLockoutStatusCapabilityType capActStatus = getActivationLockoutStatusFromSimulatedActivation(ctx, activationCapability, shadow, result);
            if (capActStatus == null) {
                throw new SchemaException("Attempt to change activation/lockout on " + ctx.getResource() + " that has neither native" + " nor simulated activation capability");
            }
            ResourceAttribute<?> activationSimulateAttribute = getSimulatedActivationLockoutStatusAttribute(ctx, shadow, capActStatus, result);
            if (activationSimulateAttribute != null) {
                LockoutStatusType status = activation.getLockoutStatus();
                String activationRealValue = null;
                if (status == LockoutStatusType.NORMAL) {
                    activationRealValue = getLockoutNormalValue(capActStatus);
                } else {
                    activationRealValue = getLockoutLockedValue(capActStatus);
                }
                Item existingAttribute = attributesContainer.findItem(activationSimulateAttribute.getElementName());
                if (!StringUtils.isBlank(activationRealValue)) {
                    activationSimulateAttribute.add(new PrismPropertyValue(activationRealValue));
                    if (attributesContainer.findItem(activationSimulateAttribute.getElementName()) == null) {
                        attributesContainer.add(activationSimulateAttribute);
                    } else {
                        attributesContainer.findItem(activationSimulateAttribute.getElementName()).replace(activationSimulateAttribute.getValue());
                    }
                } else if (existingAttribute != null) {
                    attributesContainer.remove(existingAttribute);
                }
                activation.setLockoutStatus(null);
            }
        }
    }
}
Also used : ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 7 with CapabilitiesType

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

the class TestCswEndpoint method testCapabilitiesRequestOperationsMetadata.

@Test
public void testCapabilitiesRequestOperationsMetadata() {
    // Should only return the OperationsMetadata section
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    gcr.setSections(CswEndpoint.OPERATIONS_METADATA);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gcr);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyFilterCapabilities(ct);
    assertThat(ct.getServiceIdentification(), nullValue());
    assertThat(ct.getServiceProvider(), nullValue());
    verifyOperationsMetadata(ct);
}
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 8 with CapabilitiesType

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

the class TestCswEndpoint method testGetCapabilitiesTypeBadSection.

@Test
public void testGetCapabilitiesTypeBadSection() {
    // Shouldn't return any sections
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    SectionsType stv = new SectionsType();
    stv.setSection(Arrays.asList("bad"));
    gct.setSections(stv);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyFilterCapabilities(ct);
    assertThat(ct.getServiceIdentification(), nullValue());
    assertThat(ct.getServiceProvider(), nullValue());
    assertThat(ct.getOperationsMetadata(), nullValue());
}
Also used : SectionsType(net.opengis.ows.v_1_0_0.SectionsType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) 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 9 with CapabilitiesType

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

the class TestCswEndpoint method testCapabilitiesRequestBadSection.

@Test
public void testCapabilitiesRequestBadSection() {
    // Shouldn't return any sections
    GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
    gcr.setSections("bad");
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gcr);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    assertThat(ct.getOperationsMetadata(), nullValue());
    assertThat(ct.getServiceIdentification(), nullValue());
    assertThat(ct.getServiceProvider(), nullValue());
    verifyFilterCapabilities(ct);
}
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 10 with CapabilitiesType

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

the class TestCswEndpoint method testGetCapabilitiesTypeServiceIdentification.

@Test
public void testGetCapabilitiesTypeServiceIdentification() {
    // Should only return the ServiceIdentification section
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    SectionsType stv = new SectionsType();
    stv.setSection(Arrays.asList(CswEndpoint.SERVICE_IDENTIFICATION));
    gct.setSections(stv);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyServiceIdentification(ct);
    verifyFilterCapabilities(ct);
    assertThat(ct.getServiceProvider(), nullValue());
    assertThat(ct.getOperationsMetadata(), nullValue());
}
Also used : SectionsType(net.opengis.ows.v_1_0_0.SectionsType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

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