Map<DeploymentContent, BundleSuggestion> urlToBeInstalled = new HashMap<DeploymentContent, BundleSuggestion>();
Iterator<DeploymentContent> it = content.iterator();
while (it.hasNext()) {
DeploymentContent bundleToFind = it.next();
Map<Version, List<BundleSuggestion>> bundlesuggestions = new HashMap<Version, List<BundleSuggestion>>();
for (BundleRepository obj : providers) {
BundleSuggestion suggestion = obj.suggestBundleToUse(bundleToFind);
if (suggestion != null) {
List<BundleSuggestion> suggestions = bundlesuggestions.get(suggestion.getVersion());
if (suggestions == null) {
suggestions = new ArrayList<BundleSuggestion>();
bundlesuggestions.put(suggestion.getVersion(), suggestions);
}
suggestions.add(suggestion);
}
}
BundleSuggestion suggestion = null;
if (!!!bundlesuggestions.isEmpty()) {
List<BundleSuggestion> thoughts = bundlesuggestions.get(bundleToFind.getExactVersion());
if (thoughts != null) {
Collections.sort(thoughts, new Comparator<BundleSuggestion>() {
public int compare(BundleSuggestion o1, BundleSuggestion o2)
{
return o1.getCost() - o2.getCost();
}
});
suggestion = thoughts.get(0);
}
}
// add the suggestion to the list
if (suggestion != null) {
urlToBeInstalled.put(bundleToFind, suggestion);
} else {
throw new ContextException("Unable to find bundle "+bundleToFind.getContentName() + "/" + bundleToFind.getExactVersion());
}
}
LOGGER.debug(LOG_EXIT, "getBundleSuggestions", new Object[] { urlToBeInstalled });