jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1868470 - in /jackrabbit/commons/filevault/trunk: vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/ vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/ vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/ ...
Date Tue, 15 Oct 2019 08:19:41 GMT
Author: kwin
Date: Tue Oct 15 08:19:41 2019
New Revision: 1868470

URL: http://svn.apache.org/viewvc?rev=1868470&view=rev
Log:
JCRVLT-368 throw proper exception in case invalid filter pattern is
given

some javadoc cleanup

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/invalid-pattern.xml
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrWorkspaceFilter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallState.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilterTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/FilterSetTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestFilteredPropertyExport.java
    jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationExecutor.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationViolation.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/ValidatorFactory.java
    jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
Tue Oct 15 08:19:41 2019
@@ -23,6 +23,8 @@ import java.io.StringWriter;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+
 /**
  * The item filter is used to include or exclude a set of paths.
  * It is usually part of a {@link PathFilterSet}.

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
Tue Oct 15 08:19:41 2019
@@ -145,10 +145,15 @@ public class DefaultWorkspaceFilter impl
             // only handle path filters
             PathFilter filter = entry.getFilter();
             if (filter instanceof DefaultPathFilter) {
-                if (entry.isInclude()) {
-                    bothFilter.addInclude(new DefaultPropertyPathFilter(((DefaultPathFilter)
filter).getPattern()));
-                } else {
-                    bothFilter.addExclude(new DefaultPropertyPathFilter(((DefaultPathFilter)
filter).getPattern()));
+                try {
+                    if (entry.isInclude()) {
+                        bothFilter.addInclude(new DefaultPropertyPathFilter(((DefaultPathFilter)
filter).getPattern()));
+                    } else {
+                        bothFilter.addExclude(new DefaultPropertyPathFilter(((DefaultPathFilter)
filter).getPattern()));
+                    }
+                } catch (ConfigurationException e) {
+                    // cannot not happen as pattern is always valid
+                    
                 }
             } else {
                 throw new IllegalArgumentException("Can only export default path filters,
yet.");
@@ -474,7 +479,7 @@ public class DefaultWorkspaceFilter impl
     /**
      * Resets the source content to a null state.
      * This leads to generating the source from scratch if necessary.
-     * Is called implicitly for every modifying operation ({@link #add(PathFilterSet)}, {@link
#add(PathFilterSet, PathFilterSet)}, {@link #addPropertyFilterSet(PathFilterSet)}, {@link
#load(Element)}, {@link #load(InputStream) and {@link #load(File)}).
+     * Is called implicitly for every modifying operation ({@link #add(PathFilterSet)}, {@link
#add(PathFilterSet, PathFilterSet)}, {@link #addPropertyFilterSet(PathFilterSet)}, {@link
#load(Element)}, {@link #load(InputStream)} and {@link #load(File)}).
      */
     @SuppressWarnings("unused")
     public void resetSource() {
@@ -658,7 +663,7 @@ public class DefaultWorkspaceFilter impl
      */
     private static class DefaultPropertyPathFilter extends DefaultPathFilter {
 
-        private DefaultPropertyPathFilter(String pattern) {
+        private DefaultPropertyPathFilter(String pattern) throws ConfigurationException {
             super(pattern);
         }
 
@@ -666,7 +671,11 @@ public class DefaultWorkspaceFilter impl
         public PathFilter translate(PathMapping mapping) {
             DefaultPathFilter mapped =  (DefaultPathFilter) super.translate(mapping);
             if (mapped != this) {
-                mapped = new DefaultPropertyPathFilter(mapped.getPattern());
+                try {
+                    mapped = new DefaultPropertyPathFilter(mapped.getPattern());
+                } catch (ConfigurationException e) {
+                    // cannot happen as pattern is always valiid
+                }
             }
             return mapped;
         }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
Tue Oct 15 08:19:41 2019
@@ -18,10 +18,12 @@
 package org.apache.jackrabbit.vault.fs.filter;
 
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.apache.jackrabbit.vault.fs.api.DumpContext;
 import org.apache.jackrabbit.vault.fs.api.PathFilter;
 import org.apache.jackrabbit.vault.fs.api.PathMapping;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 
 /**
  * The default path filter provides hierarchical filtering.
@@ -42,9 +44,10 @@ public class DefaultPathFilter implement
     /**
      * Creates a new default path filter
      * @param pattern the pattern
+     * @throws ConfigurationException in case an invalid regex pattern was given.
      * @see #setPattern
      */
-    public DefaultPathFilter(String pattern) {
+    public DefaultPathFilter(String pattern) throws ConfigurationException {
         setPattern(pattern);
     }
 
@@ -63,9 +66,14 @@ public class DefaultPathFilter implement
      * </pre>
      *
      * @param pattern the pattern.
+     * @throws ConfigurationException in case an invalid regex pattern was given.
      */
-    public void setPattern(String pattern) {
-        regex = Pattern.compile(pattern);
+    public void setPattern(String pattern) throws ConfigurationException {
+        try {
+            regex = Pattern.compile(pattern);
+        } catch (PatternSyntaxException e) {
+            throw new ConfigurationException("Invalid pattern given: '" + pattern + "'",
e);
+        }
     }
 
     /**
@@ -104,7 +112,12 @@ public class DefaultPathFilter implement
         if (!pattern.startsWith("/")) {
             return this;
         }
-        return new DefaultPathFilter(mapping.map(pattern));
+        try {
+            return new DefaultPathFilter(mapping.map(pattern));
+        } catch (ConfigurationException e) {
+            // should not happen as pattern is always valid
+            return this;
+        }
     }
 
     /**

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
Tue Oct 15 08:19:41 2019
@@ -42,6 +42,7 @@ import org.apache.jackrabbit.vault.fs.ap
 import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
 import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
 import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.config.MetaInf;

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrWorkspaceFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrWorkspaceFilter.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrWorkspaceFilter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrWorkspaceFilter.java
Tue Oct 15 08:19:41 2019
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.vault.fs.ap
 import org.apache.jackrabbit.vault.fs.api.ItemFilterSet;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
 
@@ -68,7 +69,12 @@ public class JcrWorkspaceFilter  {
                     int idx = rule.indexOf(':');
                     String type = idx > 0 ? rule.substring(0, idx) : "include";
                     String patt = idx > 0 ? rule.substring(idx + 1) : "";
-                    DefaultPathFilter pf = new DefaultPathFilter(patt);
+                    DefaultPathFilter pf;
+                    try {
+                        pf = new DefaultPathFilter(patt);
+                    } catch (ConfigurationException e) {
+                        throw new RepositoryException("Can not load filter from node " +
defNode.getPath(), e);
+                    }
                     if ("include".equals(type)) {
                         set.addInclude(pf);
                     } else {
@@ -80,7 +86,12 @@ public class JcrWorkspaceFilter  {
                     Node rule = rules.nextNode();
                     String type = rule.getProperty(JcrPackageDefinitionImpl.PN_TYPE).getString();
                     String pattern = rule.getProperty(JcrPackageDefinitionImpl.PN_PATTERN).getString();
-                    DefaultPathFilter pf = new DefaultPathFilter(pattern);
+                    DefaultPathFilter pf;
+                    try {
+                        pf = new DefaultPathFilter(pattern);
+                    } catch (ConfigurationException e) {
+                        throw new RepositoryException("Can not load filter from node " +
defNode.getPath(), e);
+                    }
                     if ("include".equals(type)) {
                         set.addInclude(pf);
                     } else {

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallState.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallState.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallState.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallState.java
Tue Oct 15 08:19:41 2019
@@ -40,6 +40,7 @@ import org.apache.jackrabbit.vault.fs.ap
 import org.apache.jackrabbit.vault.fs.api.PathFilter;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
 import org.apache.jackrabbit.vault.packaging.Dependency;
@@ -243,6 +244,8 @@ public class FSInstallState {
             throw new IOException("Unable to create configuration XML parser", e);
         } catch (SAXException e) {
             throw new IOException("Configuration file syntax error.", e);
+        } catch (ConfigurationException e) {
+            throw new IOException("Configuration file syntax error.", e);
         }
     }
 
@@ -268,7 +271,7 @@ public class FSInstallState {
         return PackageId.fromString(child.getAttribute(ATTR_PACKAGE_ID));
     }
 
-    private static WorkspaceFilter readWorkspaceFilter(Element child) {
+    private static WorkspaceFilter readWorkspaceFilter(Element child) throws ConfigurationException
{
         DefaultWorkspaceFilter wsfilter = new DefaultWorkspaceFilter();
         NodeList nl = child.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilterTest.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilterTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilterTest.java
Tue Oct 15 08:19:41 2019
@@ -17,19 +17,24 @@
 
 package org.apache.jackrabbit.vault.fs.filter;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.junit.Test;
 
 /**
  * {@code DefaultPathFilterTest}...
  */
-public class DefaultPathFilterTest extends TestCase {
+public class DefaultPathFilterTest {
 
-    public void testExact() {
+    @Test
+    public void testExact() throws ConfigurationException {
         test("/foo\\.bar", "/foo.bar", true);
         test("/foo\\.bar", "/foo_bar", false);
     }
 
-    public void testFiles() {
+    @Test
+    public void testFiles() throws ConfigurationException {
         test("/foo/bar\\.[^/]*$", "/foo/bar.txt", true);
         test("/foo/bar\\.[^/]*$", "/foo/bar.zip", true);
         test("/foo/bar\\.[^/]*$", "/foo/bar1.txt", false);
@@ -40,25 +45,33 @@ public class DefaultPathFilterTest exten
         test("^.*/bar\\.[^/]*$", "foobar.txt", false);
     }
 
-    public void testDirectChildren() {
+    @Test
+    public void testDirectChildren() throws ConfigurationException {
         test("/foo/[^/]*$", "/foo/bar", true);
         test("/foo/[^/]*$", "/foo/bar/readme", false);
     }
 
-    public void testDeepChildren() {
+    @Test
+    public void testDeepChildren() throws ConfigurationException {
         test("/foo/.*", "/foo/bar", true);
         test("/foo/.*", "/foo/bar/readme.txt", true);
         test("/foo/.*", "/bar/bar/readme.txt", false);
     }
-    
-    public void testSelfAndDeepChildren() {
+
+    @Test
+    public void testSelfAndDeepChildren() throws ConfigurationException {
         test("/foo(/.*)?", "/foo", true);
         test("/foo(/.*)?", "/foo/bar/readme.txt", true);
         test("/foo(/.*)?", "/foobar", false);
         test("/foo(/.*)?", "/foobar/foo", false);
     }
 
-    private void test(String pattern, String path, boolean result) {
+    @Test(expected = ConfigurationException.class)
+    public void testInvalidPattern() throws ConfigurationException {
+        new DefaultPathFilter("[");
+    }
+    
+    private void test(String pattern, String path, boolean result) throws ConfigurationException
{
         DefaultPathFilter f = new DefaultPathFilter(pattern);
         assertEquals("Pattern '" + pattern + "' matches '" + path + "'", result, f.matches(path));
     }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/FilterSetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/FilterSetTest.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/FilterSetTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/FilterSetTest.java
Tue Oct 15 08:19:41 2019
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.vault.fs.f
 import org.apache.jackrabbit.vault.fs.api.FilterSet;
 import org.apache.jackrabbit.vault.fs.api.ImportMode;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 
 import junit.framework.TestCase;
 
@@ -64,7 +65,7 @@ public class FilterSetTest extends TestC
     /**
      * Test if 2 filter sets are equal
      */
-    public void testEquals() {
+    public void testEquals() throws ConfigurationException {
         PathFilterSet f1 = new PathFilterSet("/foo");
         f1.addInclude(new DefaultPathFilter("/foo/bar(/.*)?"));
         f1.seal();
@@ -79,7 +80,7 @@ public class FilterSetTest extends TestC
     /**
      * Test if 2 filter sets are not equal if the filter differs in sign.
      */
-    public void testNotEquals() {
+    public void testNotEquals() throws ConfigurationException {
         PathFilterSet f1 = new PathFilterSet("/foo");
         f1.addInclude(new DefaultPathFilter("/foo/bar(/.*)?"));
         f1.seal();
@@ -94,7 +95,7 @@ public class FilterSetTest extends TestC
     /**
      * Test if 2 filter sets are not equal if the filter differs pattern
      */
-    public void testNotEquals2() {
+    public void testNotEquals2() throws ConfigurationException {
         PathFilterSet f1 = new PathFilterSet("/foo");
         f1.addInclude(new DefaultPathFilter("/foo/bar(/.*)?"));
         f1.seal();

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java
Tue Oct 15 08:19:41 2019
@@ -43,7 +43,7 @@ import org.junit.Test;
 public class WorkspaceFilterTest {
 
     @Test
-    public void testMatching() {
+    public void testMatching() throws ConfigurationException {
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         PathFilterSet set1 = new PathFilterSet("/foo");
         filter.add(set1);
@@ -77,7 +77,7 @@ public class WorkspaceFilterTest {
     }
 
     @Test
-    public void testMapping2() {
+    public void testMapping2() throws ConfigurationException {
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         PathFilterSet set1 = new PathFilterSet("/tmp/stage");
         set1.addInclude(new DefaultPathFilter("/tmp/stage/products(/.*)?"));
@@ -93,7 +93,7 @@ public class WorkspaceFilterTest {
     }
 
     @Test
-    public void testRelativePatterns() {
+    public void testRelativePatterns() throws ConfigurationException {
         PathFilterSet set1 = new PathFilterSet("/foo");
         set1.addInclude(new DefaultPathFilter("/foo/.*"));
         set1.addInclude(new DefaultPathFilter("/bar/.*"));
@@ -160,7 +160,7 @@ public class WorkspaceFilterTest {
     }
 
     @Test
-    public void testGeneratedSourceFromCode()  {
+    public void testGeneratedSourceFromCode() throws ConfigurationException  {
         String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<workspaceFilter version=\"1.0\">\n" +
                 "    <filter root=\"/tmp\">\n" +
@@ -181,7 +181,7 @@ public class WorkspaceFilterTest {
     }
 
     @Test
-    public void testGeneratedSourceFromCodeWithProps()  {
+    public void testGeneratedSourceFromCodeWithProps() throws ConfigurationException  {
         String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<workspaceFilter version=\"1.0\">\n" +
                 "    <filter root=\"/foo\"/>\n" +
@@ -248,4 +248,12 @@ public class WorkspaceFilterTest {
             previousSerialization = actual;
         }
     }
+
+    @Test(expected=ConfigurationException.class)
+    public void testInvalidPattern() throws IOException, ConfigurationException {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        try (InputStream input = getClass().getResourceAsStream("workspacefilters/invalid-pattern.xml"))
{
+            filter.load(input);
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestFilteredPropertyExport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestFilteredPropertyExport.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestFilteredPropertyExport.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestFilteredPropertyExport.java
Tue Oct 15 08:19:41 2019
@@ -89,7 +89,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyP1OnFoo_deprecated() throws IOException, RepositoryException,
PackageException {
+    public void filterPropertyP1OnFoo_deprecated() throws IOException, RepositoryException,
PackageException, ConfigurationException {
         PathFilterSet properties = new PathFilterSet("/tmp");
         properties.addExclude(new DefaultPathFilter("/tmp/foo/p1"));
 
@@ -112,7 +112,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyP1OnFoo() throws IOException, RepositoryException, PackageException
{
+    public void filterPropertyP1OnFoo() throws IOException, RepositoryException, PackageException,
ConfigurationException {
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         filter.add(new PathFilterSet("/tmp"));
 
@@ -135,7 +135,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyPxOnFoo_deprecated() throws IOException, RepositoryException,
PackageException {
+    public void filterPropertyPxOnFoo_deprecated() throws IOException, RepositoryException,
PackageException, ConfigurationException {
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         filter.add(new PathFilterSet("/tmp"));
 
@@ -157,7 +157,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyPxOnFoo() throws IOException, RepositoryException, PackageException
{
+    public void filterPropertyPxOnFoo() throws IOException, RepositoryException, PackageException,
ConfigurationException {
 
         PathFilterSet properties = new PathFilterSet("/tmp");
         properties.addExclude(new DefaultPathFilter("/tmp/foo/p.*"));
@@ -180,7 +180,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyWithTwoRoots() throws IOException, RepositoryException, PackageException
{
+    public void filterPropertyWithTwoRoots() throws IOException, RepositoryException, PackageException,
ConfigurationException {
         PathFilterSet properties = new PathFilterSet("/tmp");
         properties.addExclude(new DefaultPathFilter("/tmp/foo/p.*"));
 
@@ -203,7 +203,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterPropertyWithTwoRoots_deprecated() throws IOException, RepositoryException,
PackageException {
+    public void filterPropertyWithTwoRoots_deprecated() throws IOException, RepositoryException,
PackageException, ConfigurationException {
 
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         filter.add(new PathFilterSet("/foo"));
@@ -256,7 +256,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterRelativeProperties_deprecated() throws IOException, RepositoryException,
PackageException {
+    public void filterRelativeProperties_deprecated() throws IOException, RepositoryException,
PackageException, ConfigurationException {
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
         filter.add(new PathFilterSet("/tmp"));
 
@@ -281,7 +281,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterRelativeProperties() throws IOException, RepositoryException, PackageException
{
+    public void filterRelativeProperties() throws IOException, RepositoryException, PackageException,
ConfigurationException {
         PathFilterSet properties = new PathFilterSet("/tmp");
         properties.addExclude(new DefaultPathFilter(".*/p1"));
 
@@ -327,7 +327,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterRelativePropertiesShallowNoPropertyFilter() throws IOException, RepositoryException,
PackageException {
+    public void filterRelativePropertiesShallowNoPropertyFilter() throws IOException, RepositoryException,
PackageException, ConfigurationException {
         PathFilterSet nodes = new PathFilterSet("/tmp");
         nodes.addInclude(new DefaultPathFilter("/tmp"));
 
@@ -349,7 +349,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterRelativePropertiesShallowWithPropertyFilter() throws IOException, RepositoryException,
PackageException {
+    public void filterRelativePropertiesShallowWithPropertyFilter() throws IOException, RepositoryException,
PackageException, ConfigurationException {
         PathFilterSet props = new PathFilterSet("/tmp");
         props.addExclude(new DefaultPathFilter(".*/p1"));
 
@@ -373,7 +373,7 @@ public class TestFilteredPropertyExport
     }
 
     @Test
-    public void filterRelativePropertiesSingleSet_NotDeep_no_propertyFilter_addNodes() throws
IOException, RepositoryException, PackageException {
+    public void filterRelativePropertiesSingleSet_NotDeep_no_propertyFilter_addNodes() throws
IOException, RepositoryException, PackageException, ConfigurationException {
         PathFilterSet nodes = new PathFilterSet("/tmp");
 
         DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/invalid-pattern.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/invalid-pattern.xml?rev=1868470&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/invalid-pattern.xml
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/invalid-pattern.xml
Tue Oct 15 08:19:41 2019
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<workspaceFilter version="1.0">
+    <filter root="/bar" mode="merge" type="cleanup"/>
+    <filter root="/tmp">
+        <include pattern="[" />
+        <include pattern="/a/c.*" />
+        <include pattern="/a/.*" matchProperties="true" />
+    </filter>
+    <filter root="/var/foo/bar">
+        <exclude pattern="^.*/node1" />
+        <exclude pattern="^.*/prop1" matchProperties="true"/>
+    </filter>
+</workspaceFilter>

Modified: jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java
Tue Oct 15 08:19:41 2019
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.vault.davex
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
 import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
 import org.apache.jackrabbit.vault.util.RepositoryCopier;
@@ -222,7 +223,7 @@ public class RcpTask implements Runnable
         this.recursive = b;
     }
 
-    public void addExclude(String exclude) {
+    public void addExclude(String exclude) throws ConfigurationException {
         excludes.add(exclude);
         // could be done better
         DefaultWorkspaceFilter srcFilter = new DefaultWorkspaceFilter();

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationExecutor.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationExecutor.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationExecutor.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationExecutor.java
Tue Oct 15 08:19:41 2019
@@ -42,6 +42,7 @@ import org.apache.jackrabbit.vault.valid
 import org.apache.jackrabbit.vault.validation.spi.MetaInfPathValidator;
 import org.apache.jackrabbit.vault.validation.spi.NodePathValidator;
 import org.apache.jackrabbit.vault.validation.spi.PropertiesValidator;
+import org.apache.jackrabbit.vault.validation.spi.ValidationContext;
 import org.apache.jackrabbit.vault.validation.spi.ValidationMessage;
 import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
 import org.apache.jackrabbit.vault.validation.spi.Validator;
@@ -52,7 +53,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** 
- * Prrovides methods to call all registered validators. This instance is bound to the {@link
ValidationContext} being given in the 
+ * Provides methods to call all registered validators. This instance is bound to the {@link
ValidationContext} being given in the 
  * {@link ValidationExecutorFactory#createValidationExecutor(org.apache.jackrabbit.vault.validation.spi.ValidationContext,
boolean, boolean, Map)}.
  * This class is thread-safe (i.e. methods can be used from different threads on the same
instance). 
  * @see ValidationExecutorFactory

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationViolation.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationViolation.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationViolation.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/ValidationViolation.java
Tue Oct 15 08:19:41 2019
@@ -22,6 +22,7 @@ import java.util.LinkedList;
 
 import javax.annotation.CheckForNull;
 
+import org.apache.jackrabbit.vault.validation.spi.ValidatorFactory;
 import org.apache.jackrabbit.vault.validation.spi.ValidationMessage;
 import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
 

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/DocumentViewXmlValidator.java
Tue Oct 15 08:19:41 2019
@@ -22,6 +22,7 @@ import java.util.Collection;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.vault.util.DocViewNode;
 import org.osgi.annotation.versioning.ProviderType;
 

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/ValidatorFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/ValidatorFactory.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/ValidatorFactory.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/ValidatorFactory.java
Tue Oct 15 08:19:41 2019
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.vault.validation.spi;
 
+import java.util.ServiceLoader;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 

Modified: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java?rev=1868470&r1=1868469&r2=1868470&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java
Tue Oct 15 08:19:41 2019
@@ -27,6 +27,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.vault.fs.api.DumpContext;
 import org.apache.jackrabbit.vault.fs.api.PathFilter;
 import org.apache.jackrabbit.vault.fs.api.PathMapping;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.config.VaultSettings;
 import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
 import org.apache.jackrabbit.vault.util.PlatformNameFormat;
@@ -71,9 +72,7 @@ public class Ignored implements PathFilt
             ignored = new LinkedList<PathFilter>();
             try {
                 scan(scanRoot);
-            } catch (VltException e) {
-                log.error("Error while scanning for " + FILE_NAME, e);
-            } catch (IOException e) {
+            } catch (VltException|IOException|ConfigurationException e) {
                 log.error("Error while scanning for " + FILE_NAME, e);
             }
             log.info("scanned for .vltignore files below {} in {}ms", scanRoot, System.currentTimeMillis()
- now);
@@ -91,7 +90,7 @@ public class Ignored implements PathFilt
         return false;
     }
 
-    public Ignored scan(File dir) throws VltException, IOException {
+    public Ignored scan(File dir) throws VltException, IOException, ConfigurationException
{
         for (File file: dir.listFiles()) {
             String name = file.getName();
             if (settings != null && settings.isIgnored(name)) {
@@ -106,7 +105,7 @@ public class Ignored implements PathFilt
         return this;
     }
 
-    private void addIgnores(File dir, File file) throws VltException, IOException {
+    private void addIgnores(File dir, File file) throws VltException, IOException, ConfigurationException
{
         VltDirectory d = new VltDirectory(ctx, dir);
         String root = d.getAggregatePath();
         if (root == null) {
@@ -119,7 +118,7 @@ public class Ignored implements PathFilt
         }
     }
 
-    private void addIgnored(String root, String pattern) {
+    private void addIgnored(String root, String pattern) throws ConfigurationException {
         if (pattern.startsWith("#")) {
             return;
         }



Mime
View raw message