throw new MissingDependencyException("Already installed", toArtifact(metadata.getPluginArtifact().get(0).getModuleId()), (Stack<Artifact>) null);
}
verifyPrerequisites(metadata);
}
PluginArtifactType instance = metadata.getPluginArtifact().get(0);
if (instance.getModuleId() != null) {
if (metadata.isPluginGroup() != null && !metadata.isPluginGroup()) {
metaMap.put(toArtifact(instance.getModuleId()), metadata);
}
}
toInstall.add(metadata);
} catch (MissingDependencyException e) {
poller.addSkippedConfigID(e);
}
}
// Step 2: everything is valid, do the installation
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) {
Artifact entry = toArtifact(instance.getModuleId());
List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
downloadArtifact(entry, metaMap, repos,
username, password, new ResultsFileWriteMonitor(poller, log), working, parentStack, false, servers, true);
downloadedArtifacts.add(entry);
} 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, log), working, parentStack, false, servers, dep.isStart());