public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
ModuleRevisionId mrid, Date date) {
String name = getName();
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
ResolvedResource found = null;
List sorted = getLatestStrategy().sort(rress);
List rejected = new ArrayList();
List foundBlacklisted = new ArrayList();
IvyContext context = IvyContext.getContext();
for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
ResolvedResource rres = (ResolvedResource) iter.previous();
// we start by filtering based on information already available,
// even though we don't even know if the resource actually exist.
// But checking for existence is most of the time more costly than checking
// name, blacklisting and first level version matching
if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
Message.debug("\t" + name + ": filtered by name: " + rres);
continue;
}
ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
ResolveData data = context.getResolveData();
if (data != null && data.getReport() != null
&& data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
Message.debug("\t" + name + ": blacklisted: " + rres);
rejected.add(rres.getRevision() + " (blacklisted)");
foundBlacklisted.add(foundMrid);
continue;
}
if (!versionMatcher.accept(mrid, foundMrid)) {
Message.debug("\t" + name + ": rejected by version matcher: " + rres);
rejected.add(rres.getRevision());
continue;
}
if (rres.getResource() != null && !rres.getResource().exists()) {
Message.debug("\t" + name + ": unreachable: " + rres + "; res="
+ rres.getResource());
rejected.add(rres.getRevision() + " (unreachable)");
continue;
}
if ((date != null && rres.getLastModified() > date.getTime())) {
Message.verbose("\t" + name + ": too young: " + rres);
rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
continue;
}
if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
if (r == null) {
Message.debug("\t" + name + ": impossible to get module descriptor resource: "
+ rres);
rejected.add(rres.getRevision() + " (no or bad MD)");
continue;