Repository: karaf-cellar
Updated Branches:
  refs/heads/master fe8db32c2 -> bbe948805


[KARAF-4736] Align cluster feature install options with the local ones


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

Branch: refs/heads/master
Commit: bbe948805f9be12037894e88f85de6b7d5165273
Parents: fe8db32
Author: Jean-Baptiste Onofré <jbono...@apache.org>
Authored: Sun Oct 16 07:24:51 2016 +0200
Committer: Jean-Baptiste Onofré <jbono...@apache.org>
Committed: Sun Oct 16 07:24:51 2016 +0200

----------------------------------------------------------------------
 .../cellar/features/ClusterFeaturesEvent.java   | 16 +++++++++-
 .../cellar/features/FeaturesEventHandler.java   | 10 +++++-
 .../management/CellarFeaturesMBean.java         | 33 ++++----------------
 .../internal/CellarFeaturesMBeanImpl.java       | 21 ++++---------
 .../features/shell/InstallFeatureCommand.java   | 15 +++++----
 .../features/shell/UninstallFeatureCommand.java |  2 +-
 6 files changed, 46 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
index 13866c5..efc0110 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
@@ -28,6 +28,8 @@ public class ClusterFeaturesEvent extends Event {
     private String version;
     private Boolean noRefresh;
     private Boolean noStart;
+    private Boolean noManage;
+    private Boolean upgrade;
     private EventType type;
     private Node local;
 
@@ -37,15 +39,19 @@ public class ClusterFeaturesEvent extends Event {
         this.version = version;
         this.noRefresh = false;
         this.noStart = false;
+        this.noManage = false;
+        this.upgrade = false;
         this.type = type;
     }
 
-    public ClusterFeaturesEvent(String name, String version, Boolean noClean, 
Boolean noRefresh, Boolean noStart, EventType type) {
+    public ClusterFeaturesEvent(String name, String version, Boolean 
noRefresh, Boolean noStart, Boolean noManage, Boolean upgrade, EventType type) {
         super(name + separator + version);
         this.name = name;
         this.version = version;
         this.noRefresh = noRefresh;
         this.noStart = noStart;
+        this.noManage = noManage;
+        this.upgrade = upgrade;
         this.type = type;
     }
 
@@ -65,6 +71,14 @@ public class ClusterFeaturesEvent extends Event {
         return noStart;
     }
 
+    public Boolean getNoManage() {
+        return noManage;
+    }
+
+    public Boolean getUpgrade() {
+        return upgrade;
+    }
+
     public EventType getType() {
         return type;
     }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
index 1d9c7f9..f8ad537 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
@@ -85,9 +85,11 @@ public class FeaturesEventHandler extends FeaturesSupport 
implements EventHandle
             FeatureEvent.EventType type = event.getType();
             Boolean isInstalled = isFeatureInstalledLocally(name, version);
             try {
-                if (FeatureEvent.EventType.FeatureInstalled.equals(type) && 
!isInstalled) {
+                if (FeatureEvent.EventType.FeatureInstalled.equals(type)) {
                     boolean noRefresh = event.getNoRefresh();
                     boolean noStart = event.getNoStart();
+                    boolean noManage = event.getNoManage();
+                    boolean upgrade = event.getUpgrade();
                     EnumSet<FeaturesService.Option> options = 
EnumSet.noneOf(FeaturesService.Option.class);
                     if (noRefresh) {
                         
options.add(FeaturesService.Option.NoAutoRefreshBundles);
@@ -95,6 +97,12 @@ public class FeaturesEventHandler extends FeaturesSupport 
implements EventHandle
                     if (noStart) {
                         options.add(FeaturesService.Option.NoAutoStartBundles);
                     }
+                    if (noManage) {
+                        
options.add(FeaturesService.Option.NoAutoManageBundles);
+                    }
+                    if (upgrade) {
+                        options.add(FeaturesService.Option.Upgrade);
+                    }
                     if (version != null) {
                         LOGGER.debug("CELLAR FEATURE: installing feature 
{}/{}", name, version);
                         featuresService.installFeature(name, version, options);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/management/CellarFeaturesMBean.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/management/CellarFeaturesMBean.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/management/CellarFeaturesMBean.java
index ea63a29..10ffd81 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/management/CellarFeaturesMBean.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/management/CellarFeaturesMBean.java
@@ -94,23 +94,13 @@ public interface CellarFeaturesMBean {
      *
      * @param group the cluster group name.
      * @param name the feature name.
-     * @param noClean true to not uninstall the bundles if the installation of 
the feature failed, false else.
-     * @param noRefresh true to not automatically refresh the bundles, false 
else.
-     * @throws Exception in case of install failure.
-     */
-    void installFeature(String group, String name, boolean noClean, boolean 
noRefresh) throws Exception;
-
-    /**
-     * Install a feature in a cluster group.
-     *
-     * @param group the cluster group name.
-     * @param name the feature name.
-     * @param noClean true to not uninstall the bundles if the installation of 
the feature failed, false else.
      * @param noRefresh true to not automatically refresh the bundles, false 
else.
      * @param noStart true to not automatically start the bundles, false else.
+     * @param noManage true to not automatically manage the bundles, false 
else.
+     * @param upgrade true to upgrade an existing feature or install it, false 
else.
      * @throws Exception in case of install failure.
      */
-    void installFeature(String group, String name, boolean noClean, boolean 
noRefresh, boolean noStart) throws Exception;
+    void installFeature(String group, String name, boolean noRefresh, boolean 
noStart, boolean noManage, boolean upgrade) throws Exception;
 
     /**
      * Install a feature in a cluster group.
@@ -128,24 +118,13 @@ public interface CellarFeaturesMBean {
      * @param group the cluster group name.
      * @param name the feature name.
      * @param version the feature version.
-     * @param noClean true to not uninstall the bundles if the installation of 
the feature failed, false else.
-     * @param noRefresh true to not automatically refresh the bundles, false 
else.
-     * @throws Exception in case of install failure.
-     */
-    void installFeature(String group, String name, String version, boolean 
noClean, boolean noRefresh) throws Exception;
-
-    /**
-     * Install a feature in a cluster group.
-     *
-     * @param group the cluster group name.
-     * @param name the feature name.
-     * @param version the feature version.
-     * @param noClean true to not uninstall the bundles if the installation of 
the feature failued, false else.
      * @param noRefresh true to not automatically refresh the bundles, false 
else.
      * @param noStart true to not automatically start the bundles, false else.
+     * @param noManage true to not automatically manage the bundles, false 
else.
+     * @param upgrade true to upgrade an existing feature or install it, false 
else.
      * @throws Exception in case of install failure.
      */
-    void installFeature(String group, String name, String version, boolean 
noClean, boolean noRefresh, boolean noStart) throws Exception;
+    void installFeature(String group, String name, String version, boolean 
noRefresh, boolean noStart, boolean noManage, boolean upgrade) throws Exception;
 
     /**
      * Uninstall a feature from a cluster group.

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java
index 6ce36e5..8f0cc94 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/management/internal/CellarFeaturesMBeanImpl.java
@@ -97,12 +97,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean 
implements CellarFeat
     }
 
     @Override
-    public void installFeature(String groupName, String name, String version, 
boolean noClean, boolean noRefresh) throws Exception {
-        this.installFeature(groupName, name, version, noClean, noRefresh, 
false);
-    }
-
-    @Override
-    public void installFeature(String groupName, String name, String version, 
boolean noClean, boolean noRefresh, boolean noStart) throws Exception {
+    public void installFeature(String groupName, String name, String version, 
boolean noRefresh, boolean noStart, boolean noManage, boolean upgrade) throws 
Exception {
         // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
@@ -164,14 +159,14 @@ public class CellarFeaturesMBeanImpl extends 
StandardMBean implements CellarFeat
         }
 
         // broadcast the cluster event
-        ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, 
noClean, noRefresh, noStart, FeatureEvent.EventType.FeatureInstalled);
+        ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, 
noRefresh, noStart, noManage, upgrade, FeatureEvent.EventType.FeatureInstalled);
         event.setSourceGroup(group);
         eventProducer.produce(event);
     }
 
     @Override
     public void installFeature(String groupName, String name, String version) 
throws Exception {
-        this.installFeature(groupName, name, version, false, false);
+        this.installFeature(groupName, name, version, false, false, false, 
false);
     }
 
     @Override
@@ -179,14 +174,10 @@ public class CellarFeaturesMBeanImpl extends 
StandardMBean implements CellarFeat
         this.installFeature(groupName, name, null);
     }
 
-    @Override
-    public void installFeature(String groupName, String name, boolean noClean, 
boolean noRefresh) throws Exception {
-        this.installFeature(groupName, name, null, noClean, noRefresh, false);
-    }
 
     @Override
-    public void installFeature(String groupName, String name, boolean noClean, 
boolean noRefresh, boolean noStart) throws Exception {
-        this.installFeature(groupName, name, null, noClean, noRefresh, 
noStart);
+    public void installFeature(String groupName, String name, boolean 
noRefresh, boolean noStart, boolean noManage, boolean upgrade) throws Exception 
{
+        this.installFeature(groupName, name, null, noRefresh, noStart, 
noManage, upgrade);
     }
 
     @Override
@@ -257,7 +248,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean 
implements CellarFeat
         }
 
         // broadcast the cluster event
-        ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, 
false, noRefresh, false, FeatureEvent.EventType.FeatureUninstalled);
+        ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, 
noRefresh, false, false, false, FeatureEvent.EventType.FeatureUninstalled);
         event.setSourceGroup(group);
         eventProducer.produce(event);
     }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
index 6abd0f7..5be077b 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
@@ -41,15 +41,18 @@ import java.util.Map;
 @Service
 public class InstallFeatureCommand extends CellarCommandSupport {
 
-    @Option(name = "-c", aliases = {"--no-clean"}, description = "Do not 
uninstall bundles on failure", required = false, multiValued = false)
-    boolean noClean;
-
-    @Option(name = "-r", aliases = {"--no-auto-refresh"}, description = "Do 
not automatically refresh bundles", required = false, multiValued = false)
+    @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not 
automatically refresh bundles", required = false, multiValued = false)
     boolean noRefresh;
 
-    @Option(name = "-s", aliases = {"--no-auto-start"}, description = "Do not 
automatically start bundles", required = false, multiValued = false)
+    @Option(name = "-s", aliases = "--no-auto-start", description = "Do not 
start the bundles", required = false, multiValued = false)
     boolean noStart;
 
+    @Option(name = "-m", aliases = "--no-auto-manager", description = "Do not 
automatically manage bundles", required = false, multiValued = false)
+    boolean noManage;
+
+    @Option(name = "-u", aliases = "--upgrade", description = "Perform an 
upgrade of feature if previous version are installed or install it", required = 
false, multiValued = false)
+    boolean upgrade;
+
     @Argument(index = 0, name = "group", description = "The cluster group 
name", required = true, multiValued = false)
     @Completion(AllGroupsCompleter.class)
     String groupName;
@@ -133,7 +136,7 @@ public class InstallFeatureCommand extends 
CellarCommandSupport {
                     clusterFeatures.put(foundKey, found);
 
                     // broadcast the cluster event
-                    ClusterFeaturesEvent event = new 
ClusterFeaturesEvent(found.getName(), found.getVersion(), noClean, noRefresh, 
noStart, FeatureEvent.EventType.FeatureInstalled);
+                    ClusterFeaturesEvent event = new 
ClusterFeaturesEvent(found.getName(), found.getVersion(), noRefresh, noStart, 
noManage, upgrade, FeatureEvent.EventType.FeatureInstalled);
                     event.setSourceGroup(group);
                     eventProducer.produce(event);
                 } else {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/bbe94880/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
----------------------------------------------------------------------
diff --git 
a/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
 
b/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
index 9bc7620..96f6945 100644
--- 
a/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
+++ 
b/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
@@ -125,7 +125,7 @@ public class UninstallFeatureCommand extends 
CellarCommandSupport {
                 clusterFeatures.put(foundKey, found);
 
                 // broadcast the cluster event
-                ClusterFeaturesEvent event = new 
ClusterFeaturesEvent(found.getName(), found.getVersion(), false, noRefresh, 
false, FeatureEvent.EventType.FeatureUninstalled);
+                ClusterFeaturesEvent event = new 
ClusterFeaturesEvent(found.getName(), found.getVersion(), noRefresh, false, 
false, false, FeatureEvent.EventType.FeatureUninstalled);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }

Reply via email to