in src/main/java/org/apache/sling/discovery/impl/cluster/voting/VotingHelper.java [201:241]
public static List<VotingView> getYesVotingsOf(final ResourceResolver resourceResolver,
final Config config,
final String slingId) {
if (resourceResolver == null) {
throw new IllegalArgumentException("resourceResolver must not be null");
}
if (config == null) {
throw new IllegalArgumentException("config must not be null");
}
if (slingId == null || slingId.length() == 0) {
throw new IllegalArgumentException("slingId must not be null or empty");
}
final String ongoingVotingsPath = config.getOngoingVotingsPath();
final Resource ongoingVotingsResource = resourceResolver
.getResource(ongoingVotingsPath);
if (ongoingVotingsResource == null) {
return null;
}
final Iterable<Resource> children = ongoingVotingsResource.getChildren();
if (children == null) {
return null;
}
final Iterator<Resource> it = children.iterator();
final List<VotingView> result = new LinkedList<VotingView>();
while (it.hasNext()) {
Resource aChild = it.next();
VotingView c = new VotingView(aChild);
if (c.hasVotedYes(slingId)) {
result.add(c);
}
}
if (result.size() >= 1) {
// if result.size() is higher than 1, that means that there is more
// than 1 yes vote
// which can happen if the local instance is initiator of one
// and has voted on another voting
return result;
} else {
return null;
}
}