This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/enhanced-runmodes
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-jcr.git

commit e1b7e6b600ddfbebe5147da1b6a810c844b3a94b
Author: Konrad Windszus <[email protected]>
AuthorDate: Thu Jun 25 17:15:44 2020 +0200

    SLING-9031 SLING-8548 support enhanced run modes
    
    Both OR-logic and NOT operator are now supported
---
 pom.xml                                            |  4 +--
 .../provider/jcr/impl/FolderNameFilter.java        | 37 ++++++----------------
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/pom.xml b/pom.xml
index e558c1f..16a8946 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,11 +70,9 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <!-- this version must embed the same version of 
org.apache.felix.configadmin as this pom.xml to be able to read
-            the .config files being generated by the write back feature -->
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.core</artifactId>
-            <version>3.10.0</version> 
+            <version>3.11.5-SNAPSHOT</version> 
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git 
a/src/main/java/org/apache/sling/installer/provider/jcr/impl/FolderNameFilter.java
 
b/src/main/java/org/apache/sling/installer/provider/jcr/impl/FolderNameFilter.java
index d8be90f..ab3c9fd 100644
--- 
a/src/main/java/org/apache/sling/installer/provider/jcr/impl/FolderNameFilter.java
+++ 
b/src/main/java/org/apache/sling/installer/provider/jcr/impl/FolderNameFilter.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import org.apache.sling.installer.api.provider.RunModeSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +41,7 @@ import org.slf4j.LoggerFactory;
 class FolderNameFilter {
     private final Pattern pattern;
     private final String regexp;
-    private final Set<String> runModes;
+    private final Set<String> activeRunModes;
     private final String [] rootPaths;
     private final Map<String, Integer> rootPriorities = new HashMap<String, 
Integer>();
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -52,11 +53,11 @@ class FolderNameFilter {
     public static final int RUNMODE_PRIORITY_BOOST = 1;
     public static final int DEFAULT_ROOT_PRIORITY = 99;
 
-    FolderNameFilter(final String [] rootsConfig, final String regexp, final 
Set<String> runModes) {
+    FolderNameFilter(final String [] rootsConfig, final String regexp, final 
Set<String> activeRunModes) {
         final List<RootPathInfo> rootPathInfos = new ArrayList<RootPathInfo>();
         this.regexp = regexp;
         this.pattern = Pattern.compile(regexp);
-        this.runModes = runModes;
+        this.activeRunModes = activeRunModes;
 
         // Each entry in rootsConfig is like /libs:100, where 100
         // is the priority.
@@ -132,7 +133,6 @@ class FolderNameFilter {
      */
     int getPriority(final String path) {
        int result = 0;
-       List<String> modes = null;
        boolean match = false;
 
         // If path contains dots after the last /, remove suffixes
@@ -146,29 +146,10 @@ class FolderNameFilter {
         if(lastSlash > 0) {
                prefix = prefix.substring(lastSlash);
         }
-        if(prefix.indexOf(DOT) > 0) {
-            int pos = 0;
-            modes = new LinkedList<String>();
-            while( (pos = prefix.lastIndexOf(DOT)) >= 0) {
-                modes.add(prefix.substring(pos + 1));
-                prefix = prefix.substring(0, pos);
-                if(pattern.matcher(prefix).matches()) {
-                    result = getRootPriority(path);
-                    break;
-                }
-            }
-
-            // If path prefix matches, check that all our runmodes match
-            if(result > 0) {
-                for(String m : modes) {
-                    if(runModes.contains(m)) {
-                       result += RUNMODE_PRIORITY_BOOST;
-                    } else {
-                        result = 0;
-                        break;
-                    }
-                }
-            }
+        String modes = null;
+        if (prefix.indexOf(DOT) > 0) {
+            modes = prefix.substring(prefix.indexOf(DOT));
+            result = 
RunModeSupport.getNumberOfMatchingRunmodesFromDisjunctions(modes, 
activeRunModes);
 
         } else if(pattern.matcher(path).matches()) {
                match = true;
@@ -189,7 +170,7 @@ class FolderNameFilter {
     }
 
     public String toString() {
-        return getClass().getSimpleName() + " (" + regexp + "), RunModes=" + 
runModes;
+        return getClass().getSimpleName() + " (" + regexp + "), RunModes=" + 
activeRunModes;
     }
 
     int getRootPriority(String path) {

Reply via email to