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);
}
}
}
}
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);
}
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());
}
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);
}
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());
}
Aggregations