You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Mark Adamcin (Jira)" <ji...@apache.org> on 2019/09/20 17:23:00 UTC

[jira] [Comment Edited] (JCRVLT-378) WorkspaceFilter.contains return false negative

    [ https://issues.apache.org/jira/browse/JCRVLT-378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16934596#comment-16934596 ] 

Mark Adamcin edited comment on JCRVLT-378 at 9/20/19 5:22 PM:
--------------------------------------------------------------

[~kwin] I think this might be a wider convention for fuzzy default include behavior.

It uses the opposite type of the first include/exclude as the default return value. I believe this is done to eliminate boilerplate <exclude pattern=".*"/> elements when the intent was to include only specific descendants of a filtered root.

 The specific line with this effect is `boolean result = !entries.get(0).include;`
{code:java}
/**
 * Evaluates the filters if this set does {@link #covers(String) cover} the
 * given item. otherwise {@code false} is returned.
 * The result of the evaluation is the polarity of the last matched path.
 * If no filter matches it returns {@code true}
 * if the first filter is an exclude filter or if no filter is defined;
 * {@code false} if the first filter is an include filter.
 *
 * @param path the path to check
 * @return {@code true} if this set matches the item
 */
public boolean contains(@Nonnull String path) {
    if (!covers(path)) {
        return false;
    }
    List<Entry<PathFilter>> entries = getEntries();
    if (entries.isEmpty()) {
        return true;
    } else {
        boolean result = !entries.get(0).include;
        for (Entry<PathFilter> entry: entries) {
            if (entry.filter.matches(path)) {
                result = entry.include;
            }
        }
        return result;
    }
}
{code}
 


was (Author: madamcin):
[~kwin] I think this might be a wider convention for fuzzy default include behavior.

It uses the opposite type of the first include/exclude as the default return value. I believe this is done to eliminate boilerplate <exclude pattern=".*"/> elements when the intent was to include only specific descendants of a filtered root.

 
{code:java}
/**
 * Evaluates the filters if this set does {@link #covers(String) cover} the
 * given item. otherwise {@code false} is returned.
 * The result of the evaluation is the polarity of the last matched path.
 * If no filter matches it returns {@code true}
 * if the first filter is an exclude filter or if no filter is defined;
 * {@code false} if the first filter is an include filter.
 *
 * @param path the path to check
 * @return {@code true} if this set matches the item
 */
public boolean contains(@Nonnull String path) {
    if (!covers(path)) {
        return false;
    }
    List<Entry<PathFilter>> entries = getEntries();
    if (entries.isEmpty()) {
        return true;
    } else {
        boolean result = !entries.get(0).include;
        for (Entry<PathFilter> entry: entries) {
            if (entry.filter.matches(path)) {
                result = entry.include;
            }
        }
        return result;
    }
}
{code}
 

> WorkspaceFilter.contains return false negative
> ----------------------------------------------
>
>                 Key: JCRVLT-378
>                 URL: https://issues.apache.org/jira/browse/JCRVLT-378
>             Project: Jackrabbit FileVault
>          Issue Type: Bug
>          Components: vlt
>            Reporter: Konrad Windszus
>            Priority: Major
>
> For this workspace filter
> {code}
> <filter root="/var/acs-commons">
>         <include pattern="/var/acs-commons/httpcache"/>
>         <include pattern="/var/acs-commons/httpcache/root"/>
> </filter>
> {code}
> The call of {{WorkspaceFilter.contains("/var/acs-commons")}} returns {{false}}.
> This is unexpected because this is the root path itself.
> So this node should be installed (including all direct properties) and only sub nodes are being filtered with the includes/excludes.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)