}
private List<Diff> compare(JCRNodeWrapper frozenNode, JCRNodeWrapper node, String basePath) throws RepositoryException {
List<Diff> diffs = new ArrayList<Diff>();
ListOrderedMap uuids1 = getChildEntries(frozenNode, node.getSession());
ListOrderedMap uuids2 = getChildEntries(node, node.getSession());
if (!uuids1.values().equals(uuids2.values())) {
for (Iterator iterator = uuids2.keySet().iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
if (uuids1.containsKey(key) && !uuids1.get(key).equals(uuids2.get(key))) {
diffs.add(new ChildRenamedDiff(key, addPath(basePath,(String) uuids1.get(key)),addPath(basePath, (String) uuids2.get(key))));
}
}
}
if (!uuids1.keyList().equals(uuids2.keyList())) {
List<String> added = new ArrayList<String>(uuids2.keySet());
added.removeAll(uuids1.keySet());
List<String> removed = new ArrayList<String>(uuids1.keySet());
removed.removeAll(uuids2.keySet());
// Ordering
Map<String,String> oldOrdering = getOrdering(uuids1, removed);
Map<String,String> newOrdering = getOrdering(uuids2, added);
if (!newOrdering.equals(oldOrdering)) {
for (Map.Entry<String, String> entry : newOrdering.entrySet()) {
diffs.add(new ChildNodeReorderedDiff(entry.getKey(), newOrdering.get(entry.getKey()),
addPath(basePath,(String) uuids2.get(entry.getKey())), (String) uuids2.get(newOrdering.get(entry.getKey())),newOrdering));
}
}
// Removed nodes
for (String s : removed) {
try {
sourceNode.getSession().getNodeByUUID(s);
// Item has been moved
} catch (ItemNotFoundException e) {
diffs.add(new ChildRemovedDiff(s,addPath(basePath, (String) uuids1.get(s))));
}
}
// Added nodes
for (String s : added) {
if (s.equals(uuids2.lastKey())) {
diffs.add(new ChildAddedDiff(s, addPath(basePath, (String) uuids2.get(s)), null));
} else {
diffs.add(new ChildAddedDiff(s, addPath(basePath, (String) uuids2.get(s)), (String) uuids2.get(uuids2.get(uuids2.indexOf(s)+1))));
}
}
}
PropertyIterator pi1 = frozenNode.getProperties();