for (PluginType metadata : toInstall) {
// 2. Unload obsoleted configurations
PluginArtifactType instance = metadata.getPluginArtifact().get(0);
List<Artifact> obsoletes = new ArrayList<Artifact>();
for (ArtifactType obs : instance.getObsoletes()) {
Artifact obsolete = toArtifact(obs);
Artifact[] list = configManager.getArtifactResolver().queryArtifacts(obsolete);
for (Artifact artifact : list) {
if (configManager.isLoaded(artifact)) {
if (configManager.isRunning(artifact)) {
configManager.stopConfiguration(artifact);
}
configManager.unloadConfiguration(artifact);
obsoletes.add(artifact);
}
}
}
// 3. Download the artifact if necessary, and its dependencies
Set<Artifact> working = new HashSet<Artifact>();
Stack<Artifact> parentStack = new Stack<Artifact>();
if (instance.getModuleId() != null) {
List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
downloadArtifact(toArtifact(instance.getModuleId()), metaMap, repos,
username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, true);
} else {
List<DependencyType> deps = instance.getDependency();
for (DependencyType dep : deps) {
Artifact entry = toArtifact(dep);
List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
downloadArtifact(entry, metaMap, repos,
username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, dep.isStart());
}
}