jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1870707 - in /jackrabbit/commons/filevault/trunk/vault-validation/src: main/java/org/apache/jackrabbit/vault/validation/spi/impl/ test/java/org/apache/jackrabbit/vault/validation/spi/impl/
Date Mon, 02 Dec 2019 12:42:13 GMT
Author: kwin
Date: Mon Dec  2 12:42:13 2019
New Revision: 1870707

URL: http://svn.apache.org/viewvc?rev=1870707&view=rev
Log:
JCRVLT-345 call nested validators also in sub packages

Modified:
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidator.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorFactory.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedPropertiesValidatorFactory.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/DocumentViewParserValidatorFactory.java
    jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorTest.java

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidator.java?rev=1870707&r1=1870706&r2=1870707&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidator.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidator.java
Mon Dec  2 12:42:13 2019
@@ -82,6 +82,7 @@ public final class AdvancedFilterValidat
     
     static final Path FILTER_XML_PATH = Paths.get(Constants.VAULT_DIR, Constants.FILTER_XML);
 
+    private final boolean isSubPackage;
     private final Collection<String> validRoots;
     private final ValidationMessageSeverity defaultSeverity;
     private final ValidationMessageSeverity severityForUncoveredAncestorNode;
@@ -93,7 +94,8 @@ public final class AdvancedFilterValidat
     private final Collection<String> danglingNodePaths;
     private final Map<PathFilterSet, List<Entry<PathFilter>>> orphanedFilterSets;
 
-    public AdvancedFilterValidator(@Nonnull ValidationMessageSeverity defaultSeverity, @Nonnull
ValidationMessageSeverity severityForUncoveredAncestorNodes, @Nonnull ValidationMessageSeverity
severityForUncoveredFilterRootAncestors, @Nonnull ValidationMessageSeverity severityForOrphanedFilterEntries,
@Nonnull Collection<PackageInfo> dependenciesMetaInfo, @Nonnull WorkspaceFilter filter,
@Nonnull Collection<String> validRoots) {
+    public AdvancedFilterValidator(@Nonnull ValidationMessageSeverity defaultSeverity, @Nonnull
ValidationMessageSeverity severityForUncoveredAncestorNodes, @Nonnull ValidationMessageSeverity
severityForUncoveredFilterRootAncestors, @Nonnull ValidationMessageSeverity severityForOrphanedFilterEntries,
boolean isSubPackage, @Nonnull Collection<PackageInfo> dependenciesMetaInfo, @Nonnull
WorkspaceFilter filter, @Nonnull Collection<String> validRoots) {
+        this.isSubPackage = isSubPackage;
         this.filterValidators = new HashMap<>();
         this.defaultSeverity = defaultSeverity;
         this.severityForUncoveredAncestorNode = severityForUncoveredAncestorNodes;
@@ -112,11 +114,13 @@ public final class AdvancedFilterValidat
             }
         }
         this.orphanedFilterSets = new LinkedHashMap<>();
-        for (PathFilterSet pathFilter : filter.getFilterSets()) {
-            if (!PathFilterSet.TYPE_CLEANUP.equals(pathFilter.getType())) {
-                List<Entry<PathFilter>> entries = pathFilter.getEntries().stream().filter(Entry<PathFilter>::isInclude).collect(Collectors.toList());
-                // add all includes to a new list
-                this.orphanedFilterSets.put(pathFilter, entries);
+        if (!isSubPackage) {
+            for (PathFilterSet pathFilter : filter.getFilterSets()) {
+                if (!PathFilterSet.TYPE_CLEANUP.equals(pathFilter.getType())) {
+                    List<Entry<PathFilter>> entries = pathFilter.getEntries().stream().filter(Entry<PathFilter>::isInclude).collect(Collectors.toList());
+                    // add all includes to a new list
+                    this.orphanedFilterSets.put(pathFilter, entries);
+                }
             }
         }
     }
@@ -156,6 +160,9 @@ public final class AdvancedFilterValidat
 
     @Override
     public Collection<ValidationMessage> validate(WorkspaceFilter filter) {
+        if (isSubPackage) {
+            return null; // not relevant for sub packages
+        }
         Collection<ValidationMessage> messages = new LinkedList<>();
         messages.addAll(validatePathFilterSets(filter.getFilterSets(), true));
         messages.addAll(validatePathFilterSets(filter.getPropertyFilterSets(), false));
@@ -204,7 +211,7 @@ public final class AdvancedFilterValidat
         return messages;
     }
 
-    public Collection<ValidationMessage> validatePathFilterSets(Collection<PathFilterSet>
pathFilterSets, boolean checkRoots) {
+    private Collection<ValidationMessage> validatePathFilterSets(Collection<PathFilterSet>
pathFilterSets, boolean checkRoots) {
         Collection<ValidationMessage> messages = new LinkedList<>();
         for (PathFilterSet pathFilterSet : pathFilterSets) {
             // check for validity of root path
@@ -318,6 +325,9 @@ public final class AdvancedFilterValidat
 
     @Override
     public Collection<ValidationMessage> validate(String nodePath) {
+        if (isSubPackage) {
+            return null; // not relevant for sub packages
+        }
         // remove from orphaned list
         removeFromOrphanedFilterEntries(nodePath);
         

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorFactory.java?rev=1870707&r1=1870706&r2=1870707&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorFactory.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorFactory.java
Mon Dec  2 12:42:13 2019
@@ -92,12 +92,13 @@ public final class AdvancedFilterValidat
         } else {
             validRoots.addAll(DEFAULT_VALID_ROOTS);
         }
-        return new AdvancedFilterValidator(settings.getDefaultSeverity(), severityForUncoveredAncestorNode,
severityForUncoveredFilterRootAncestors, severityForOrphanedFilterRules, context.getDependenciesMetaInfo(),
context.getFilter(), validRoots);
+        return new AdvancedFilterValidator(settings.getDefaultSeverity(), severityForUncoveredAncestorNode,
severityForUncoveredFilterRootAncestors, severityForOrphanedFilterRules, context.getContainerValidationContext()
!= null, context.getDependenciesMetaInfo(), context.getFilter(), validRoots);
     }
 
     @Override
     public boolean shouldValidateSubpackages() {
-        return false;
+        // necessary to call nested validators which should be called for subpackages
+        return true;
     }
 
     @Override

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedPropertiesValidatorFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedPropertiesValidatorFactory.java?rev=1870707&r1=1870706&r2=1870707&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedPropertiesValidatorFactory.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedPropertiesValidatorFactory.java
Mon Dec  2 12:42:13 2019
@@ -32,7 +32,8 @@ public final class AdvancedPropertiesVal
 
     @Override
     public boolean shouldValidateSubpackages() {
-        return false;
+        // necessary to call nested validators which should be called for subpackages
+        return true;
     }
 
     @Override

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/DocumentViewParserValidatorFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/DocumentViewParserValidatorFactory.java?rev=1870707&r1=1870706&r2=1870707&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/DocumentViewParserValidatorFactory.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/DocumentViewParserValidatorFactory.java
Mon Dec  2 12:42:13 2019
@@ -47,7 +47,7 @@ public class DocumentViewParserValidator
 
     @Override
     public boolean shouldValidateSubpackages() {
-        return false;
+        return true;
     }
 
     @Override

Modified: jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorTest.java?rev=1870707&r1=1870706&r2=1870707&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/AdvancedFilterValidatorTest.java
Mon Dec  2 12:42:13 2019
@@ -103,6 +103,7 @@ public class AdvancedFilterValidatorTest
                     AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                     ValidationMessageSeverity.ERROR,
                     ValidationMessageSeverity.ERROR,
+                    false,
                     dependenciesMetaInfo,
                     filter, // this is per test
                     validRoots);
@@ -137,6 +138,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -158,6 +160,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -181,6 +184,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -199,6 +203,7 @@ public class AdvancedFilterValidatorTest
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -215,6 +220,7 @@ public class AdvancedFilterValidatorTest
                 ValidationMessageSeverity.WARN,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 Collections.emptyList());
@@ -241,6 +247,7 @@ public class AdvancedFilterValidatorTest
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -265,6 +272,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -292,6 +300,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.INFO,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -311,6 +320,7 @@ public class AdvancedFilterValidatorTest
                     AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                     ValidationMessageSeverity.ERROR,
                     ValidationMessageSeverity.ERROR,
+                    false,
                     dependenciesMetaInfo,
                     filter,
                     validRoots);
@@ -336,6 +346,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);
@@ -382,6 +393,7 @@ public class AdvancedFilterValidatorTest
                 AdvancedFilterValidatorFactory.DEFAULT_SEVERITY_FOR_UNCOVERED_ANCESTOR_NODES,
                 ValidationMessageSeverity.ERROR,
                 ValidationMessageSeverity.ERROR,
+                false,
                 dependenciesMetaInfo,
                 filter, // this is per test
                 validRoots);



Mime
View raw message