use of com.evolveum.midpoint.provisioning.ucf.api.Operation in project midpoint by Evolveum.
the class AbstractModificationConverter method convert.
public void convert() throws SchemaException {
PropertyDelta<QName> auxiliaryObjectClassDelta = determineAuxilaryObjectClassDelta(changes);
ResourceObjectDefinition structuralObjectClassDefinition = resourceSchema.findDefinitionForObjectClass(objectDefinition.getTypeName());
if (structuralObjectClassDefinition == null) {
throw new SchemaException("No definition of structural object class " + objectDefinition.getTypeName() + " in " + connectorDescription);
}
Map<QName, ResourceObjectDefinition> auxiliaryObjectClassMap = new HashMap<>();
if (auxiliaryObjectClassDelta != null) {
// Auxiliary object class change means modification of __AUXILIARY_OBJECT_CLASS__ attribute
collect(PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME, auxiliaryObjectClassDelta, null, (pvals, midPointAttributeName) -> covertAuxiliaryObjectClassValuesToConnId(pvals, midPointAttributeName, auxiliaryObjectClassMap));
}
for (Operation operation : changes) {
if (operation instanceof PropertyModificationOperation) {
PropertyModificationOperation change = (PropertyModificationOperation) operation;
PropertyDelta<?> delta = change.getPropertyDelta();
if (delta.getParentPath().equivalent(ShadowType.F_ATTRIBUTES)) {
if (delta.getDefinition() == null || !(delta.getDefinition() instanceof ResourceAttributeDefinition)) {
ResourceAttributeDefinition def = objectDefinition.findAttributeDefinition(delta.getElementName());
if (def == null) {
String message = "No definition for attribute " + delta.getElementName() + " used in modification delta";
throw new SchemaException(message);
}
try {
delta.applyDefinition(def);
} catch (SchemaException e) {
throw e;
}
}
PlusMinusZero isInModifiedAuxilaryClass = null;
ResourceAttributeDefinition<?> structAttrDef = structuralObjectClassDefinition.findAttributeDefinition(delta.getElementName());
// aux object class, we cannot add/remove it with the object class unless it is normally requested
if (structAttrDef == null) {
if (auxiliaryObjectClassDelta != null && auxiliaryObjectClassDelta.isDelete()) {
// is removed, the attributes must be removed as well.
for (PrismPropertyValue<QName> auxPval : auxiliaryObjectClassDelta.getValuesToDelete()) {
ResourceObjectDefinition auxDef = auxiliaryObjectClassMap.get(auxPval.getValue());
ResourceAttributeDefinition<?> attrDef = auxDef.findAttributeDefinition(delta.getElementName());
if (attrDef != null) {
// means: is in removed auxiliary class
isInModifiedAuxilaryClass = PlusMinusZero.MINUS;
break;
}
}
}
if (auxiliaryObjectClassDelta != null && auxiliaryObjectClassDelta.isAdd()) {
// is added, the attributes must be added as well.
for (PrismPropertyValue<QName> auxPval : auxiliaryObjectClassDelta.getValuesToAdd()) {
ResourceObjectDefinition auxOcDef = auxiliaryObjectClassMap.get(auxPval.getValue());
ResourceAttributeDefinition<?> auxAttrDef = auxOcDef.findAttributeDefinition(delta.getElementName());
if (auxAttrDef != null) {
// means: is in added auxiliary class
isInModifiedAuxilaryClass = PlusMinusZero.PLUS;
break;
}
}
}
}
// Change in (ordinary) attributes. Transform to the ConnId attributes.
String connIdAttrName = connIdNameMapper.convertAttributeNameToConnId(delta, objectDefinition);
collect(connIdAttrName, delta, isInModifiedAuxilaryClass);
} else if (delta.getParentPath().equivalent(ShadowType.F_ACTIVATION)) {
convertFromActivation(delta);
} else if (delta.getParentPath().equivalent(SchemaConstants.PATH_PASSWORD)) {
convertFromPassword((PropertyDelta<ProtectedStringType>) delta);
} else if (delta.getPath().equivalent(ShadowType.F_AUXILIARY_OBJECT_CLASS)) {
// already processed
} else {
throw new SchemaException("Change of unknown attribute " + delta.getPath());
}
} else {
throw new IllegalArgumentException("Unknown operation type " + operation.getClass().getName() + ": " + operation);
}
}
}
Aggregations