Return-Path: X-Original-To: apmail-karaf-commits-archive@minotaur.apache.org Delivered-To: apmail-karaf-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BF212FA60 for ; Tue, 26 Mar 2013 16:30:50 +0000 (UTC) Received: (qmail 93972 invoked by uid 500); 26 Mar 2013 16:30:50 -0000 Delivered-To: apmail-karaf-commits-archive@karaf.apache.org Received: (qmail 93928 invoked by uid 500); 26 Mar 2013 16:30:50 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 93918 invoked by uid 99); 26 Mar 2013 16:30:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 16:30:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 16:30:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9742823888CD; Tue, 26 Mar 2013 16:30:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1461206 - in /karaf/cellar/branches/cellar-2.2.x/bundle: pom.xml src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java src/main/resources/OSGI-INF/blueprint/blueprint.xml Date: Tue, 26 Mar 2013 16:30:25 -0000 To: commits@karaf.apache.org From: anierbeck@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130326163025.9742823888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: anierbeck Date: Tue Mar 26 16:30:25 2013 New Revision: 1461206 URL: http://svn.apache.org/r1461206 Log: [KARAF-2251] - Cellar: features:install ignores incoming and outgoing blacklist Modified: karaf/cellar/branches/cellar-2.2.x/bundle/pom.xml karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml Modified: karaf/cellar/branches/cellar-2.2.x/bundle/pom.xml URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/pom.xml?rev=1461206&r1=1461205&r2=1461206&view=diff ============================================================================== --- karaf/cellar/branches/cellar-2.2.x/bundle/pom.xml (original) +++ karaf/cellar/branches/cellar-2.2.x/bundle/pom.xml Tue Mar 26 16:30:25 2013 @@ -42,6 +42,7 @@ org.apache.karaf.shell.console;version="[2.2,3)", org.apache.karaf.shell.console.commands;version="[2.2,3)", org.apache.karaf.shell.console.completer;version="[2.2,3)", + org.apache.karaf.features;version="[2.2,3)", org.osgi*, org.slf4j;resolution:=optional @@ -64,6 +65,12 @@ org.apache.felix.configadmin + + + org.apache.karaf.features + org.apache.karaf.features.core + + org.slf4j Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java?rev=1461206&r1=1461205&r2=1461206&view=diff ============================================================================== --- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java (original) +++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java Tue Mar 26 16:30:25 2013 @@ -13,12 +13,18 @@ */ package org.apache.karaf.cellar.bundle; +import java.util.ArrayList; +import java.util.List; + import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.control.BasicSwitch; import org.apache.karaf.cellar.core.control.Switch; import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventHandler; import org.apache.karaf.cellar.core.event.EventType; +import org.apache.karaf.features.BundleInfo; +import org.apache.karaf.features.Feature; +import org.apache.karaf.features.FeaturesService; import org.osgi.framework.BundleEvent; import org.osgi.framework.BundleException; import org.osgi.service.cm.Configuration; @@ -32,6 +38,8 @@ public class BundleEventHandler extends public static final String SWITCH_ID = "org.apache.karaf.cellar.bundle.handler"; private final Switch eventSwitch = new BasicSwitch(SWITCH_ID); + + private FeaturesService featureService; /** * Handles remote bundle events. @@ -54,6 +62,13 @@ public class BundleEventHandler extends try { //Check if the pid is marked as local. if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, event.getLocation(), EventType.INBOUND)) { + //check the features first + List matchingFeatures = retrieveFeature(event); + for (Feature feature : matchingFeatures) { + if (!isAllowed(event.getSourceGroup(), "features", feature.getName(), EventType.INBOUND)) { + LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in a feature marked as BLOCKED INBOUND", event.getLocation()); + } + } if (event.getType() == BundleEvent.INSTALLED) { LOGGER.debug("CELLAR BUNDLE: installing bundle {} from {}", event.getId(), event.getLocation()); installBundleFromLocation(event.getLocation()); @@ -73,10 +88,27 @@ public class BundleEventHandler extends } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED INBOUND", event.getLocation()); } catch (BundleException e) { LOGGER.error("CELLAR BUNDLE: failed to handle bundle event", e); - } + } catch (Exception e) { + LOGGER.error("CELLAR BUNDLE: failed to handle bundle event", e); + } } - /** + private List retrieveFeature(RemoteBundleEvent event) throws Exception { + Feature[] features = featureService.listFeatures(); + List matchingFeatures = new ArrayList(); + for (Feature feature : features) { + List bundles = feature.getBundles(); + for (BundleInfo bundleInfo : bundles) { + String location = bundleInfo.getLocation(); + if (location.equalsIgnoreCase(event.getLocation())) { + matchingFeatures.add(feature); + } + } + } + return matchingFeatures; + } + + /** * Initialization Method. */ public void init() { @@ -112,4 +144,18 @@ public class BundleEventHandler extends return RemoteBundleEvent.class; } + /** + * @return the featureService + */ + public FeaturesService getFeatureService() { + return featureService; + } + + /** + * @param featureService the featureService to set + */ + public void setFeatureService(FeaturesService featureService) { + this.featureService = featureService; + } + } Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1461206&r1=1461205&r2=1461206&view=diff ============================================================================== --- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original) +++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml Tue Mar 26 16:30:25 2013 @@ -42,6 +42,7 @@ + @@ -54,5 +55,6 @@ +