in scim-server/src/main/java/org/apache/directory/scim/server/rest/BulkResourceImpl.java [782:813]
private static void generateReverseDependenciesGraph(Map<String, Set<String>> reverseDependenciesGraph, String dependentBulkId, Object scimObject, Set<Schema.Attribute> scimObjectAttributes) {
for (Schema.Attribute scimObjectAttribute : scimObjectAttributes)
if (scimObjectAttribute.isScimResourceIdReference()) {
String reference = scimObjectAttribute.getAccessor().get(scimObject);
if (reference != null && reference.startsWith("bulkId:")) {
Set<String> dependents = reverseDependenciesGraph.computeIfAbsent(reference, (unused) -> new HashSet<>());
dependents.add("bulkId:" + dependentBulkId);
}
} else if (scimObjectAttribute.isMultiValued()) { // all multiValueds
// are COMPLEX, not
// all COMPLEXES are
// multiValued
Object attributeObject = scimObjectAttribute.getAccessor().get(scimObject);
if (attributeObject != null) {
Class<?> attributeObjectClass = attributeObject.getClass();
boolean isCollection = Collection.class.isAssignableFrom(attributeObjectClass);
Collection<?> attributeValues = isCollection ? (Collection<?>) attributeObject : List.of(attributeObject);
Set<Schema.Attribute> subAttributes = scimObjectAttribute.getAttributes();
for (Object attributeValue : attributeValues) {
generateReverseDependenciesGraph(reverseDependenciesGraph, dependentBulkId, attributeValue, subAttributes);
}
}
} else if (scimObjectAttribute.getType() == Schema.Attribute.Type.COMPLEX) {
Object attributeValue = scimObjectAttribute.getAccessor().get(scimObject);
Set<Schema.Attribute> subAttributes = scimObjectAttribute.getAttributes();
generateReverseDependenciesGraph(reverseDependenciesGraph, dependentBulkId, attributeValue, subAttributes);
}
}