// Do a first loop to build the main catalog (new_groups)...
for (LdapRecord r : set) {
// new_groups (me)...
IEntityGroup g = r.getGroup();
new_groups.put(g.getLocalKey(), g);
}
// Do a second loop to build local indeces...
for (LdapRecord r : set) {
IEntityGroup g = r.getGroup();
// new_parents (I am a parent for all my children)...
for (String childKey : r.getKeysOfChildren()) {
// NB: We're only interested in relationships between
// objects in the main catalog (i.e. new_groups);
// discard everything else...
if (!new_groups.containsKey(childKey)) {
break;
}
List<String> parentsList = new_parents.get(childKey);
if (parentsList == null) {
// first parent for this child...
parentsList = Collections.synchronizedList(new LinkedList<String>());
new_parents.put(childKey, parentsList);
}
parentsList.add(g.getLocalKey());
}
// new_children...
List<String> childrenList = Collections.synchronizedList(new LinkedList<String>());
for (String childKey : r.getKeysOfChildren()) {
// NB: We're only interested in relationships between
// objects in the main catalog (i.e. new_groups);
// discard everything else...
if (new_groups.containsKey(childKey)) {
childrenList.add(childKey);
}
}
new_children.put(g.getLocalKey(), childrenList);
// new_keysByUpperCaseName...
List<String> groupsWithMyName = new_keysByUpperCaseName.get(g.getName().toUpperCase());
if (groupsWithMyName == null) {
// I am the first group with my name (pretty likely)...
groupsWithMyName = Collections.synchronizedList(new LinkedList<String>());
new_keysByUpperCaseName.put(g.getName().toUpperCase(), groupsWithMyName);
}
groupsWithMyName.add(g.getLocalKey());
}
/*
* Now load the ROOT_GROUP into the collections...