kwin commented on code in PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1993744775
########## vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java: ########## @@ -239,12 +243,68 @@ public boolean covers(@NotNull String path) { } /** - * Checks if the given item is an ancestor of the root node. + * Checks if the given path is an ancestor of the filter's root path. * @param path path of the item to check * @return {@code true} if the given item is an ancestor */ public boolean isAncestor(@NotNull String path) { - return path.equals(root) || root.startsWith(path + "/") || "/".equals(path); + boolean isAncestor = path.equals(root) || path.equals("/") || root.startsWith(path + "/"); + log.debug("isAncestor(root={}, path={}) -> {}", root, path, isAncestor); + return isAncestor; + } + + /** + * Matches the given path with this filter's root. If it is an ancestor, returns the name of the first + * path segment of the remaining filter root "below" path. If it's unrelated, return an empty string + * (indicating that no child node will ever math). Otherwise return {@code null).} + * + * @param path Path to check + * @return first path segment of non-matched path, or {@code null} when path not ancestor + */ + public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull String path) { Review Comment: A Unit test would be nice for this. ########## vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/SiblingIterationIT.java: ########## @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.vault.packaging.integration; + +import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; +import org.apache.jackrabbit.vault.fs.api.PathFilterSet; +import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter; +import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf; +import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter; +import org.apache.jackrabbit.vault.fs.impl.AggregateImpl; +import org.apache.jackrabbit.vault.packaging.ExportOptions; +import org.apache.jackrabbit.vault.packaging.VaultPackage; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.event.Level; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.nodetype.NodeType; +import java.io.File; +import java.io.IOException; +import java.util.Properties; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +/** + * Tests checking whether siblings Review Comment: this sentence should have a verb :-) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org