// To avoid testing each child to the hacker,
// we verify here if the parent node is parent of
// any entry listed in the hacker.
// In most case, the dontTrust flag will false and
// no overhead will be caused in the child loop.
LDAPURL parentUrl = findUrlForDisplayedEntry(parent);
boolean dontTrust = numSubordinateHacker.containsChildrenOf(parentUrl);
// Walk through the entries
for (SearchResult entry : task.getChildEntries())
{
BasicNode child;
// Search a child node matching the DN of the entry
int index;
if (differential) {
// System.out.println("Differential mode -> starting to search");
index = findChildNode(parent, entry.getName());
// System.out.println("Differential mode -> ending to search");
}
else {
index = - (parent.getChildCount() + 1);
}
// If no node matches, we create a new node
if (index < 0) {
// -(index + 1) is the location where to insert the new node
index = -(index + 1);
child = new BasicNode(entry.getName());
parent.insert(child, index);
updateNodeRendering(child, entry);
insertIndex.add(new Integer(index));
// System.out.println("Inserted " + child.getDN() + " at " + index);
}
else { // Else we update the existing one
child = (BasicNode)parent.getChildAt(index);
if (updateNodeRendering(child, entry)) {
changedIndex.add(new Integer(index));
}
// The node is no longer obsolete
child.setObsolete(false);
}
// NUMSUBORDINATE HACK
// Let's see if child has subordinates or not.
// Thanks to slapd, we cannot always trust the
// numSubOrdinates attribute. If the child entry's DN
// is found in the hacker's list, then we ignore
// the numSubordinate attribute... :((
boolean hasNoSubOrdinates;
if (!child.hasSubOrdinates() && dontTrust) {
LDAPURL childUrl = findUrlForDisplayedEntry(child);
if (numSubordinateHacker.contains(childUrl)) {
// The numSubOrdinates we have is unreliable.
// child may potentially have subordinates.
hasNoSubOrdinates = false;
// System.out.println("numSubordinates of " + childUrl +