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 2020/06/29 13:53:14 UTC
[karaf-cellar] branch master updated: Slightly optimized code for
group configuration management
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf-cellar.git
The following commit(s) were added to refs/heads/master by this push:
new 0e6c2a9 Slightly optimized code for group configuration management
new d0ed440 Merge pull request #70 from Jahia/blacklist-optimization
0e6c2a9 is described below
commit 0e6c2a928790cc89d135167f6ed68ae64dd20c2a
Author: tdraier <td...@jahia.com>
AuthorDate: Thu Oct 3 15:44:35 2019 +0200
Slightly optimized code for group configuration
management
---
.../java/org/apache/karaf/cellar/core/CellarSupport.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
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 8904cea..586bc5e 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 @@ public class CellarSupport {
* @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 @@ public class CellarSupport {
}
// 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;
}
}
}