use of com.evolveum.midpoint.schema.processor.CompositeObjectDefinition in project midpoint by Evolveum.
the class ShadowConstraintsChecker method check.
public void check(Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
CompositeObjectDefinition projOcDef = projectionContext.getCompositeObjectDefinition();
PrismObject<ShadowType> projectionNew = projectionContext.getObjectNew();
if (projectionNew == null) {
// This must be delete
LOGGER.trace("No new object in projection context. Current shadow satisfy constraints");
satisfiesConstraints = true;
return;
}
PrismContainer<?> attributesContainer = projectionNew.findContainer(ShadowType.F_ATTRIBUTES);
if (attributesContainer == null) {
// No attributes no constraint violations
LOGGER.trace("Current shadow does not contain attributes, skipping checking uniqueness.");
satisfiesConstraints = true;
return;
}
ConstraintViolationConfirmer confirmer = (conflictingShadowCandidate) -> {
boolean violation = true;
LensProjectionContext foundContext = context.findProjectionContextByOid(conflictingShadowCandidate.getOid());
if (foundContext != null) {
if (foundContext.isGone()) {
violation = false;
}
LOGGER.trace("Comparing with account in other context resulted to violation confirmation of {}", violation);
}
return violation;
};
constraintsCheckingResult = provisioningService.checkConstraints(projOcDef, projectionNew, projectionContext.getObjectOld(), projectionContext.getResource(), projectionContext.getOid(), projectionContext.getResourceShadowDiscriminator(), confirmer, context.getProjectionConstraintsCheckingStrategy(), task, result);
if (constraintsCheckingResult.isSatisfiesConstraints()) {
satisfiesConstraints = true;
return;
}
for (QName checkedAttributeName : constraintsCheckingResult.getCheckedAttributes()) {
if (constraintsCheckingResult.getConflictingAttributes().contains(checkedAttributeName)) {
if (isInDelta(checkedAttributeName, projectionContext.getPrimaryDelta())) {
throw new ObjectAlreadyExistsException("Attribute " + checkedAttributeName + " conflicts with existing object (and it is present in primary " + "account delta therefore no iteration is performed)");
}
}
}
if (projectionContext.isGone()) {
satisfiesConstraints = true;
} else {
satisfiesConstraints = false;
}
}
Aggregations