int getPriority()

in src/main/java/org/apache/sling/installer/provider/jcr/impl/FolderNameFilter.java [132:186]


    int getPriority(final String path) {
    	int result = 0;
    	boolean match = false;

        // If path contains dots after the last /, remove suffixes
    	// starting with dots until path matches regexp, and accept
    	// if all suffixes
        // are included in our list of runmodes
        final char DOT = '.';

        String prefix = path;
        final int lastSlash = prefix.lastIndexOf('/');
        if(lastSlash > 0) {
        	prefix = prefix.substring(lastSlash);
        }
        String modes = null;
        if (prefix.indexOf(DOT) > 0) {
            int pos = 0;
            String pathAndRunmodes = prefix;
            while( (pos = prefix.lastIndexOf(DOT)) >= 0) {
                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) {
                modes = pathAndRunmodes.substring(pos+1);
                int runModeMatchCount = slingSettings.getBestRunModeMatchCountFromSpec(modes);
                if (runModeMatchCount > 0) {
                    result += RUNMODE_PRIORITY_BOOST * runModeMatchCount;
                } else {
                    result = 0;
                }
            }

        } else if(pattern.matcher(path).matches()) {
        	match = true;
        	result = getRootPriority(path);
        }

        if(modes != null) {
            if(log.isDebugEnabled()) {
                log.debug("getPriority(" + path + ")=" + result + " (prefix=" + prefix + ", run modes=" + modes + ")");
            }
        } else if(match ){
        	log.debug("getPriority({})={}", path, result);
        } else {
        	log.debug("getPriority({})={}, path doesn't match regexp", path, result);
        }

        return result;
    }