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 2012/05/09 13:50:31 UTC

svn commit: r1336112 - in /karaf/cellar/trunk: core/src/main/java/org/apache/karaf/cellar/core/shell/ features/src/main/java/org/apache/karaf/cellar/features/shell/ features/src/main/resources/OSGI-INF/blueprint/

Author: jbonofre
Date: Wed May  9 11:50:31 2012
New Revision: 1336112

URL: http://svn.apache.org/viewvc?rev=1336112&view=rev
Log:
[KARAF-1429] Check if a feature cluster event is allowed outbound in cluster:feature-* commands

Modified:
    karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
    karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
    karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
    karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
    karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml

Modified: karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java?rev=1336112&r1=1336111&r2=1336112&view=diff
==============================================================================
--- karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java (original)
+++ karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java Wed May  9 11:50:31 2012
@@ -17,6 +17,7 @@ import org.apache.karaf.cellar.core.Clus
 import org.apache.karaf.cellar.core.GroupManager;
 import org.apache.karaf.cellar.core.event.EventTransportFactory;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * Abstract Cellar command.
@@ -25,6 +26,7 @@ public abstract class CellarCommandSuppo
 
     protected ClusterManager clusterManager;
     protected GroupManager groupManager;
+    protected ConfigurationAdmin configurationAdmin;
 
     public ClusterManager getClusterManager() {
         return clusterManager;
@@ -42,4 +44,12 @@ public abstract class CellarCommandSuppo
         this.groupManager = groupManager;
     }
 
+    public ConfigurationAdmin getConfigurationAdmin() {
+        return configurationAdmin;
+    }
+
+    public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
+        this.configurationAdmin = configurationAdmin;
+    }
+
 }

Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java?rev=1336112&r1=1336111&r2=1336112&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java (original)
+++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java Wed May  9 11:50:31 2012
@@ -13,8 +13,10 @@
  */
 package org.apache.karaf.cellar.features.shell;
 
+import org.apache.karaf.cellar.core.CellarSupport;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.apache.karaf.cellar.features.Constants;
 import org.apache.karaf.cellar.features.FeatureInfo;
@@ -121,6 +123,14 @@ public abstract class FeatureCommandSupp
         }
     }
 
+    public boolean isAllowed(Group group, String category, String name, EventType type) {
+        CellarSupport support = new CellarSupport();
+        support.setClusterManager(this.clusterManager);
+        support.setGroupManager(this.groupManager);
+        support.setConfigurationAdmin(this.configurationAdmin);
+        return support.isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND);
+    }
+
     public BundleContext getBundleContext() {
         return bundleContext;
     }

Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java?rev=1336112&r1=1336111&r2=1336112&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java (original)
+++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java Wed May  9 11:50:31 2012
@@ -13,9 +13,12 @@
  */
 package org.apache.karaf.cellar.features.shell;
 
+import org.apache.karaf.cellar.core.CellarSupport;
 import org.apache.karaf.cellar.core.Group;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
+import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.cellar.features.Constants;
 import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
 import org.apache.karaf.features.FeatureEvent;
 import org.apache.karaf.shell.commands.Argument;
@@ -46,7 +49,7 @@ public class InstallFeatureCommand exten
 
         // check if the producer is ON
         if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
-            System.err.println("Cluster event producer is OFF for this node");
+            System.err.println("Cluster event producer is OFF");
             return null;
         }
 
@@ -58,7 +61,13 @@ public class InstallFeatureCommand exten
             return null;
         }
 
-        // update the distributed map
+        // check if the outbound event is allowed
+        if (!isAllowed(group, Constants.FEATURES_CATEGORY, feature, EventType.OUTBOUND)) {
+            System.err.println("Feature " + feature + " is blocked outbound");
+            return null;
+        }
+
+        // update the distributed resource
         updateFeatureStatus(groupName, feature, version, true);
 
         // broadcast the cluster event

Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java?rev=1336112&r1=1336111&r2=1336112&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java (original)
+++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java Wed May  9 11:50:31 2012
@@ -16,6 +16,8 @@ package org.apache.karaf.cellar.features
 import org.apache.karaf.cellar.core.Group;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
+import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.cellar.features.Constants;
 import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
 import org.apache.karaf.features.FeatureEvent;
 import org.apache.karaf.shell.commands.Argument;
@@ -58,6 +60,12 @@ public class UninstallFeatureCommand ext
             return null;
         }
 
+        // check if the outbound event is allowed
+        if (!isAllowed(group, Constants.FEATURES_CATEGORY, feature, EventType.OUTBOUND)) {
+            System.err.println("Feature " + feature + " is blocked outbound");
+            return null;
+        }
+
         // update distributed set
         updateFeatureStatus(groupName, feature, version, false);
 

Modified: karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml?rev=1336112&r1=1336111&r2=1336112&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml (original)
+++ karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml Wed May  9 11:50:31 2012
@@ -20,6 +20,7 @@
             <action class="org.apache.karaf.cellar.features.shell.InstallFeatureCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
+                <property name="configurationAdmin" ref="configurationAdmin"/>
                 <property name="featuresService" ref="featuresService"/>
                 <property name="eventProducer" ref="eventProducer"/>
             </action>
@@ -32,6 +33,7 @@
             <action class="org.apache.karaf.cellar.features.shell.UninstallFeatureCommand">
                 <property name="clusterManager" ref="clusterManager"/>
                 <property name="groupManager" ref="groupManager"/>
+                <property name="configurationAdmin" ref="configurationAdmin"/>
                 <property name="featuresService" ref="featuresService"/>
                 <property name="eventProducer" ref="eventProducer"/>
             </action>