public void uninstallFeature(String name, String version) throws Exception {
uninstallFeature(name, version, EnumSet.noneOf(Option.class));
}
public void uninstallFeature(String name, String version, EnumSet<Option> options) throws Exception {
Feature feature = getFeature(name, version);
if (feature == null || !installed.containsKey(feature)) {
throw new Exception("Feature named '" + name
+ "' with version '" + version + "' is not installed");
}
boolean verbose = options != null && options.contains(Option.Verbose);
boolean refresh = options == null || !options.contains(Option.NoAutoRefreshBundles);
if (verbose) {
System.out.println("Uninstalling feature " + feature.getName() + " " + feature.getVersion());
}
// Grab all the bundles installed by this feature
// and remove all those who will still be in use.
// This gives this list of bundles to uninstall.
Set<Long> bundles = installed.remove(feature);
// Also remove bundles installed as conditionals
for (Conditional conditional : feature.getConditional()) {
Set<Long> ids = installed.remove(conditional.asFeature(feature.getName(), feature.getVersion()));
if (ids != null) {
bundles.addAll(ids);
}
}
// Verify all other conditionals
for (Feature dep : new ArrayList<Feature>(installed.keySet())) {
Feature f = getFeature(dep.getName(), dep.getVersion());
if (f != null) {
for (Conditional conditional : f.getConditional()) {
if (!dependenciesSatisfied(conditional.getCondition(), installed.keySet())) {
Set<Long> ids = installed.remove(conditional.asFeature(f.getName(), f.getVersion()));
if (ids != null) {
bundles.addAll(ids);
}
}
}