Merge pull request #70 from Jahia/blacklist-optimization

Slightly optimized code for group configuration
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
index a1d0f3c..965e09c 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
@@ -172,7 +172,6 @@
      * @param type the event type (inbound, outbound).
      */
     public Boolean isAllowed(Group group, String category, String event, EventType type) {
-        Boolean result = true;
         Set<String> whiteList = getListEntries(Configurations.WHITELIST, group, category, type);
         Set<String> blackList = getListEntries(Configurations.BLACKLIST, group, category, type);
 
@@ -183,21 +182,23 @@
         }
 
         // if no white listed items we assume all are accepted.
+        Boolean result = true;
         if (!whiteList.isEmpty()) {
             result = false;
             for (String whiteListItem : whiteList) {
-                if (wildCardMatch(event, whiteListItem))
+                if (wildCardMatch(event, whiteListItem)) {
                     result = true;
+                    break;
+                }
             }
         }
 
         if (result) {
+            // we passed whitelist, now check the blacklist
             // if any blackList item matched, then false is returned.
-            if (!blackList.isEmpty()) {
-                for (String blackListItem : blackList) {
-                    if (wildCardMatch(event, blackListItem)) {
-                        return false;
-                    }
+            for (String blackListItem : blackList) {
+                if (wildCardMatch(event, blackListItem)) {
+                    return false;
                 }
             }
         }