You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/06/19 20:18:32 UTC

karaf git commit: [KARAF-4575] Re-add support of install and uninstall mode for feature repo-add and repo-remove

Repository: karaf
Updated Branches:
  refs/heads/master 9e301b649 -> dca11ea95


[KARAF-4575] Re-add support of install and uninstall mode for feature repo-add and repo-remove


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/dca11ea9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/dca11ea9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/dca11ea9

Branch: refs/heads/master
Commit: dca11ea9536dff2b1613dbb178b3030828b16373
Parents: 9e301b6
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Sun Jun 19 22:17:46 2016 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Sun Jun 19 22:17:46 2016 +0200

----------------------------------------------------------------------
 .../internal/service/FeaturesServiceImpl.java   | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/dca11ea9/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index ed2c6e9..556db75 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -449,10 +449,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
 
     @Override
     public void addRepository(URI uri, boolean install) throws Exception {
-        if (install) {
-            // TODO: implement
-            throw new UnsupportedOperationException();
-        }
         Repository repository = loadRepository(uri);
         synchronized (lock) {
             // Clean cache
@@ -465,6 +461,14 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             saveState();
         }
         callListeners(new RepositoryEvent(repository, RepositoryEvent.EventType.RepositoryAdded, false));
+        // install the features in the repo
+        if (install) {
+            HashSet<String> features = new HashSet<>();
+            for (Feature feature : repository.getFeatures()) {
+                features.add(feature.getName() + "/" + feature.getVersion());
+            }
+            installFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
+        }
     }
 
     @Override
@@ -500,6 +504,14 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             repo = new RepositoryImpl(uri, blacklisted);
         }
         callListeners(new RepositoryEvent(repo, RepositoryEvent.EventType.RepositoryRemoved, false));
+        // uninstall the features from the repository
+        if (uninstall) {
+            HashSet<String> features = new HashSet<>();
+            for (Feature feature : repo.getFeatures()) {
+                features.add(feature.getName() + "/" + feature.getVersion());
+            }
+            uninstallFeatures(features, EnumSet.noneOf(FeaturesService.Option.class));
+        }
     }
 
     @Override