in src/main/java/org/apache/sling/discovery/impl/common/View.java [123:168]
public String matches(final Set<String> view) throws Exception {
final Set<String> viewCopy = new HashSet<String>(view);
final Resource members = getResource().getChild("members");
if (members == null) {
throw new Exception("no members resource found");
}
try{
final Iterator<Resource> it = members.getChildren().iterator();
StringBuffer sb = new StringBuffer();
boolean success = true;
while (it.hasNext()) {
Resource aMemberRes = it.next();
if (sb.length() != 0) {
sb.append(", ");
}
if (!viewCopy.remove(aMemberRes.getName())) {
success = false;
sb.append("old: " + aMemberRes.getName());
} else {
sb.append("fine: " + aMemberRes.getName());
}
}
// now the ViewCopy set must be empty to represent a match
if (viewCopy.size() != 0) {
success = false;
if (sb.length() != 0) {
sb.append(", ");
}
for (String newlyAdded : viewCopy) {
sb.append("new: " + newlyAdded);
}
}
if (success) {
return null;
} else {
return sb.toString();
}
} catch(RuntimeException re) {
// SLING-2945 : the members resource could have been deleted
// by another party simultaneously
// so treat this situation nicely
logger.info("matches: cannot compare due to "+re);
throw new Exception("RuntimeException: "+re, re);
}
}