ONOS-785 Adding distributed store for apps & app admin CLIs

Change-Id: Ia7639f3258fca2a18ba513f0c95de0ab8ea7ceee
diff --git a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index 08c91a4..1d38215 100644
--- a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -21,6 +21,7 @@
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.onosproject.app.ApplicationAdminService;
 import org.onosproject.app.ApplicationEvent;
@@ -202,13 +203,19 @@
 
     private void installAppFeatures(Application app) throws Exception {
         for (String name : app.features()) {
-            featuresService.installFeature(name);
+            Feature feature = featuresService.getFeature(name);
+            if (!featuresService.isInstalled(feature)) {
+                featuresService.installFeature(name);
+            }
         }
     }
 
     private void uninstallAppFeatures(Application app) throws Exception {
         for (String name : app.features()) {
-            featuresService.uninstallFeature(name);
+            Feature feature = featuresService.getFeature(name);
+            if (featuresService.isInstalled(feature)) {
+                featuresService.uninstallFeature(name);
+            }
         }
     }