Map<String, Module> pending = new HashMap(this.pendingMananger.getModules());
Iterator<Map.Entry<String, Module>> it = pending.entrySet().iterator();
while (it.hasNext() == true) {
Map.Entry<String, Module> entry = it.next();
Module module = entry.getValue();
DeploymentQueryResult res = this.deployManager.canDeploy(module);
if (res.getResult() == false) {
StringBuffer message = new StringBuffer("[MODULES] Unable to install " +
module.getName() + ":\n");
for (String reason : res.getReasons()) {
message.append(reason + "\n");
}
logger.warning(message.toString());
it.remove();
}
}
/*
* Check to see that the module can be safely installed by making sure
* that first its dependencies are met.
*/
Map<Module, List<ModuleInfo>> failures =
new LinkedHashMap<Module, List<ModuleInfo>>();
Map<String, Module> passed = this.checkDependencies(pending, failures);
/* Format a message to describe any failures */
if (failures.isEmpty() == false) {
StringBuffer failureMessage = new StringBuffer("[MODULES] Module dependency failures: \n");
for (Map.Entry<Module, List<ModuleInfo>> e : failures.entrySet()) {
failureMessage.append("Module " + e.getKey().getName() +
" depends on ");
for (ModuleInfo depend : e.getValue()) {
failureMessage.append(depend.getName() + " ");
failureMessage.append(" v. " + depend.getMajor() + ".");
failureMessage.append(depend.getMinor() + ".");
failureMessage.append(depend.getMini() + " ");
}
failureMessage.append("\n");
}
logger.warning(failureMessage.toString());
}
/*
* Next check whether the module is overwriting an existing installed
* module. Make sure that the new version of the module does not
* violate the dependencies of other modules.
*/
Iterator<Map.Entry<String, Module>> it1 = passed.entrySet().iterator();
while (it1.hasNext() == true) {
Map.Entry<String, Module> entry = it1.next();
ModuleInfo info = entry.getValue().getInfo();
OverwriteQueryResult res = ModuleOverwriteUtils.canOverwrite(info);
if (res.getResult() == false) {
StringBuffer message = new StringBuffer("[MODULES] Unable to replace module " +
info.getName() + ":\n");
for (String reason : res.getReasons()) {
message.append(reason + "\n");
}
logger.warning(message.toString());
it1.remove();