public void installAssertAndUninstallFeatures(String... feature) throws Exception { boolean success = false; Set<String> features = new HashSet<>(Arrays.asList(feature)); try { System.out.println("Installing " + features); featureService.installFeatures(features, NO_AUTO_REFRESH); for (String curFeature : feature) { assertFeatureInstalled(curFeature); } success = true; } finally { System.out.println("Uninstalling " + features); try { featureService.uninstallFeatures(features, NO_AUTO_REFRESH); } catch (Exception e) { if (success) { throw e; } } } }
/** * The feature service does not uninstall feature dependencies when uninstalling a single feature. * So we need to make sure we uninstall all features that were newly installed. * * @param featuresBefore * @throws Exception */ public void uninstallNewFeatures(Set<Feature> featuresBefore) throws Exception { Feature[] features = featureService.listInstalledFeatures(); Set<String> uninstall = new HashSet<>(); for (Feature curFeature : features) { if (!featuresBefore.contains(curFeature)) { uninstall.add(curFeature.getId()); } } try { System.out.println("Uninstalling " + uninstall); featureService.uninstallFeatures(uninstall, NO_AUTO_REFRESH); } catch (Exception e) { LOG.error(e.getMessage(), e); } }
protected void doExecute(FeaturesService admin) throws Exception { addOption(FeaturesService.Option.Simulate, simulate); addOption(FeaturesService.Option.Verbose, verbose); addOption(FeaturesService.Option.NoAutoRefreshBundles, noRefresh); admin.uninstallFeatures(new HashSet<>(features), region, options); } }
protected void doExecute(FeaturesService admin) throws Exception { addOption(FeaturesService.Option.Simulate, simulate); addOption(FeaturesService.Option.Verbose, verbose); addOption(FeaturesService.Option.NoAutoRefreshBundles, noRefresh); admin.uninstallFeatures(new HashSet<>(features), region, options); } }