in src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingHelper.java [159:192]
public static VotingView getWinningVoting(
final ResourceResolver resourceResolver, final Config config) {
String ongoingVotingsPath = config.getOngoingVotingsPath();
Resource ongoingVotingsResource = resourceResolver
.getResource(ongoingVotingsPath);
if (ongoingVotingsResource == null) {
// it is legal that at this stage there is no ongoingvotings node yet
// for example when there was never a voting yet
logger.debug("getWinningVoting: no ongoing votings parent resource found");
return null;
}
Iterable<Resource> children = ongoingVotingsResource.getChildren();
Iterator<Resource> it = children.iterator();
List<VotingView> result = new LinkedList<VotingView>();
while (it.hasNext()) {
Resource aChild = it.next();
VotingView c = new VotingView(aChild);
boolean ongoing = c.isOngoingVoting(config);
boolean winning = c.isWinning();
if (ongoing && winning) {
if (logger.isDebugEnabled()) {
logger.debug("getWinningVoting: a winning voting: " + aChild);
}
result.add(c);
} else {
logger.debug("getWinningVote: not winning: vote="+aChild+" is ongoing="+ongoing+", winning="+winning);
}
}
if (result.size() == 1) {
return result.get(0);
} else {
return null;
}
}