use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType 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.ActivationType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createAccount.
protected PrismObject<ShadowType> createAccount(PrismObject<ResourceType> resource, String name, boolean enabled) throws SchemaException {
PrismObject<ShadowType> shadow = getShadowDefinition().instantiate();
ShadowType shadowType = shadow.asObjectable();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resource.getOid());
shadowType.setResourceRef(resourceRef);
RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
shadowType.setObjectClass(objectClassDefinition.getTypeName());
shadowType.setKind(ShadowKindType.ACCOUNT);
ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition);
RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next();
ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate();
icfsNameAttr.setRealValue(name);
attrCont.add(icfsNameAttr);
ActivationType activation = new ActivationType();
shadowType.setActivation(activation);
if (enabled) {
activation.setAdministrativeStatus(ActivationStatusType.ENABLED);
} else {
activation.setAdministrativeStatus(ActivationStatusType.DISABLED);
}
return shadow;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class AbstractBasicDummyTest method assertRepoShadowCacheActivation.
protected void assertRepoShadowCacheActivation(PrismObject<ShadowType> shadowRepo, ActivationStatusType expectedAdministrativeStatus) {
ActivationType activationType = shadowRepo.asObjectable().getActivation();
if (activationType == null) {
return;
}
ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
assertNull("Unexpected activation administrativeStatus in repo shadow " + shadowRepo + ": " + administrativeStatus, administrativeStatus);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class TestSchemaDelta method testDeleteUserAssignmentActivationSameNullIdApplyToObject.
@Test
public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws Exception {
final String TEST_NAME = "testDeleteUserAssignmentActivationSameNullIdApplyToObject";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
//Delta
ActivationType activationType = new ActivationType();
activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
// No container ID
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(USER_JACK_ASSIGNMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
// WHEN
userDelta.applyTo(user);
// THEN
System.out.println("User after delta application:");
System.out.println(user.debugDump());
assertEquals("Wrong OID", USER_JACK_OID, user.getOid());
PrismAsserts.assertPropertyValue(user, UserType.F_NAME, PrismTestUtil.createPolyString(USER_JACK_NAME));
PrismContainer<AssignmentType> assignmentContainer = user.findContainer(RoleType.F_ASSIGNMENT);
assertNotNull("No assignment", assignmentContainer);
assertEquals("Unexpected number of assignment values", 1, assignmentContainer.size());
PrismContainerValue<AssignmentType> assignmentValue = assignmentContainer.getValues().iterator().next();
AssignmentType assignment = assignmentValue.asContainerable();
ActivationType assignmentActivation = assignment.getActivation();
// activation should be gone (the error is that it is empty and not gone)
assertNull("Assignment activation is not gone", assignmentActivation);
ActivationType activation = user.asObjectable().getActivation();
assertNotNull("Activation missing", activation);
assertEquals("Wrong activation administrativeStatus", ActivationStatusType.ENABLED, activation.getAdministrativeStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.
the class ActivationProcessor method evaluateExistenceMapping.
private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context, final LensProjectionContext accCtx, final XMLGregorianCalendar now, final boolean current, Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
final String accCtxDesc = accCtx.toHumanReadableString();
final Boolean legal = accCtx.isLegal();
if (legal == null) {
throw new IllegalStateException("Null 'legal' for " + accCtxDesc);
}
ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return legal;
}
ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
if (activationType == null) {
return legal;
}
ResourceBidirectionalMappingType existenceType = activationType.getExistence();
if (existenceType == null) {
return legal;
}
List<MappingType> outbound = existenceType.getOutbound();
if (outbound == null || outbound.isEmpty()) {
// "default mapping"
return legal;
}
MappingEvaluatorParams<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>, ShadowType, F> params = new MappingEvaluatorParams<>();
params.setMappingTypes(outbound);
params.setMappingDesc("outbound existence mapping in projection " + accCtxDesc);
params.setNow(now);
params.setAPrioriTargetObject(accCtx.getObjectOld());
params.setEvaluateCurrent(current);
params.setTargetContext(accCtx);
params.setFixTarget(true);
params.setContext(context);
params.setInitializer(builder -> {
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSourceIdi = getLegalIdi(accCtx);
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSource = new Source<>(legalSourceIdi, ExpressionConstants.VAR_LEGAL);
builder.defaultSource(legalSource);
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedIdi = getAssignedIdi(accCtx);
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedSource = new Source<>(assignedIdi, ExpressionConstants.VAR_ASSIGNED);
builder.addSource(assignedSource);
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext());
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSource = new Source<>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS);
builder.addSource(focusExistsSource);
builder.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_SHADOW, accCtx.getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource());
builder.originType(OriginType.OUTBOUND);
builder.originObject(accCtx.getResource());
return builder;
});
final MutableBoolean output = new MutableBoolean(false);
params.setProcessor((mappingOutputPath, outputStruct) -> {
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = outputStruct.getOutputTriple();
if (outputTriple == null) {
// The "default existence mapping"
output.setValue(legal);
return false;
}
Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues();
// (e.g. because the condition is false). This should be fixed.
if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
throw new ExpressionEvaluationException("Activation existence expression resulted in null or empty value for projection " + accCtxDesc);
}
if (nonNegativeValues.size() > 1) {
throw new ExpressionEvaluationException("Activation existence expression resulted in too many values (" + nonNegativeValues.size() + ") for projection " + accCtxDesc);
}
output.setValue(nonNegativeValues.iterator().next().getValue());
return false;
});
PrismPropertyDefinitionImpl<Boolean> shadowExistsDef = new PrismPropertyDefinitionImpl<>(SHADOW_EXISTS_PROPERTY_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
shadowExistsDef.setMinOccurs(1);
shadowExistsDef.setMaxOccurs(1);
params.setTargetItemDefinition(shadowExistsDef);
mappingEvaluator.evaluateMappingSetProjection(params, task, result);
return (boolean) output.getValue();
}
Aggregations