use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class TestActivationComputer method testGetProposedAdministrativeEnabled.
@Test
public void testGetProposedAdministrativeEnabled() throws Exception {
System.out.println("\n===[ testGetProposedAdministrativeEnabled ]===\n");
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_PROPOSED, activationType);
// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class InactivateShadowAction method handle.
/* (non-Javadoc)
* @see com.evolveum.midpoint.model.sync.Action#handle(com.evolveum.midpoint.model.lens.LensContext, com.evolveum.midpoint.model.sync.SynchronizationSituation, java.util.Map, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public <F extends FocusType> void handle(LensContext<F> context, SynchronizationSituation<F> situation, Map<QName, Object> parameters, Task task, OperationResult parentResult) {
ActivationStatusType desiredStatus = ActivationStatusType.DISABLED;
LensProjectionContext projectionContext = context.getProjectionContextsIterator().next();
PrismObject<ShadowType> objectCurrent = projectionContext.getObjectCurrent();
if (objectCurrent != null) {
PrismProperty<Object> administrativeStatusProp = objectCurrent.findProperty(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (administrativeStatusProp != null) {
if (desiredStatus.equals(administrativeStatusProp.getRealValue())) {
// Desired status already set, nothing to do
return;
}
}
}
ObjectDelta<ShadowType> activationDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, projectionContext.getOid(), SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getPrismContext(), desiredStatus);
projectionContext.setPrimaryDelta(activationDelta);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class TestActivation method assertEffectiveStatus.
private <F extends FocusType> void assertEffectiveStatus(PrismObject<F> focus, ActivationStatusType expected) {
ActivationType activation = focus.asObjectable().getActivation();
assertNotNull("No activation in " + focus, activation);
assertEquals("Unexpected effective activation status in " + focus, expected, activation.getEffectiveStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType 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;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class ResourceObjectConverter method convertToSimulatedActivationAdministrativeStatusAttribute.
private PropertyModificationOperation convertToSimulatedActivationAdministrativeStatusAttribute(ProvisioningContext ctx, PropertyDelta activationDelta, ShadowType shadow, ActivationStatusType status, ActivationCapabilityType activationCapabilityType, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ResourceType resource = ctx.getResource();
ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapabilityType, shadow, result);
if (capActStatus == null) {
throw new SchemaException("Attempt to modify activation on " + resource + " which does not have activation capability");
}
ResourceAttribute<?> simulatedAttribute = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result);
if (simulatedAttribute == null) {
return null;
}
Class<?> simulatedAttrValueClass = getAttributeValueClass(ctx, shadow, simulatedAttribute, capActStatus);
PropertyDelta<?> simulatedAttrDelta;
if (status == null && activationDelta.isDelete()) {
LOGGER.trace("deleting activation property.");
simulatedAttrDelta = PropertyDelta.createModificationDeleteProperty(new ItemPath(ShadowType.F_ATTRIBUTES, simulatedAttribute.getElementName()), simulatedAttribute.getDefinition(), simulatedAttribute.getRealValue());
} else if (status == ActivationStatusType.ENABLED) {
Object enableValue = getEnableValue(capActStatus, simulatedAttrValueClass);
simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), enableValue);
} else {
Object disableValue = getDisableValue(capActStatus, simulatedAttrValueClass);
simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), disableValue);
}
PropertyModificationOperation attributeChange = new PropertyModificationOperation(simulatedAttrDelta);
return attributeChange;
}
Aggregations