jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1874873 - in /jackrabbit/commons/filevault-package-maven-plugin/trunk: ./ src/main/java/org/apache/jackrabbit/filevault/maven/packaging/
Date Fri, 06 Mar 2020 07:30:33 GMT
Author: kwin
Date: Fri Mar  6 07:30:33 2020
New Revision: 1874873

URL: http://svn.apache.org/viewvc?rev=1874873&view=rev
Log:
JCRVLT-415 call validator for empty folders as well

Modified:
    jackrabbit/commons/filevault-package-maven-plugin/trunk/pom.xml
    jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
    jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidatePackageMojo.java
    jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidationHelper.java

Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/pom.xml?rev=1874873&r1=1874872&r2=1874873&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/pom.xml (original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/pom.xml Fri Mar  6 07:30:33 2020
@@ -45,7 +45,7 @@
         <slf4j.version>1.7.5</slf4j.version>
         <jackrabbit.version>2.20.0</jackrabbit.version>
         <oak.version>1.20.0</oak.version>
-        <filevault.version>3.4.2</filevault.version>
+        <filevault.version>3.4.3-SNAPSHOT</filevault.version>
     </properties>
 
     <prerequisites>

Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java?rev=1874873&r1=1874872&r2=1874873&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
(original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
Fri Mar  6 07:30:33 2020
@@ -202,23 +202,46 @@ public class ValidateFilesMojo extends A
         scanner.scan();
         getLog().info("Scanning baseDir '" + baseDir + "'...");
         for (String relativeFile : scanner.getIncludedFiles()) {
-            File absoluteFile = new File(baseDir, relativeFile);
-            validationHelper.clearPreviousValidationMessages(buildContext, absoluteFile);
-            getLog().debug("Validating file '" + absoluteFile + "'...");
-            try (InputStream input = new FileInputStream(absoluteFile)) {
-                final Collection<ValidationViolation> messages;
-                if (isMetaInf) {
-                    messages = executor.validateMetaInf(input, Paths.get(relativeFile), baseDir.toPath());
-                } else {
-                    messages = executor.validateJcrRoot(input, Paths.get(relativeFile), baseDir.toPath());
-                }
-                validationHelper.printMessages(messages, getLog(), buildContext, project.getBasedir().toPath());
-            } catch (FileNotFoundException e) {
-                getLog().error("Could not find file " + absoluteFile, e);
-            } catch (IOException e) {
-                getLog().error("Could not validate file " + absoluteFile, e);
-            }
+            validateFile(executor, baseDir, isMetaInf, relativeFile);
         }
+        for (String relativeFile : scanner.getIncludedDirectories()) {
+            validateFolder(executor, baseDir, isMetaInf, relativeFile);
+        }
+    }
+
+
+    private void validateFile(ValidationExecutor executor, File baseDir, boolean isMetaInf,
String relativeFile) {
+        File absoluteFile = new File(baseDir, relativeFile);
+        validationHelper.clearPreviousValidationMessages(buildContext, absoluteFile);
+        getLog().debug("Validating file '" + absoluteFile + "'...");
+        try (InputStream input = new FileInputStream(absoluteFile)) {
+            validateInputStream(executor, input, baseDir, isMetaInf, relativeFile);
+        } catch (FileNotFoundException e) {
+            getLog().error("Could not find file " + absoluteFile, e);
+        } catch (IOException e) {
+            getLog().error("Could not validate file " + absoluteFile, e);
+        }
+    }
+    
+    private void validateFolder(ValidationExecutor executor, File baseDir, boolean isMetaInf,
String relativeFile) {
+        File absoluteFile = new File(baseDir, relativeFile);
+        validationHelper.clearPreviousValidationMessages(buildContext, absoluteFile);
+        getLog().debug("Validating folder '" + absoluteFile + "'...");
+        try {
+            validateInputStream(executor, null, baseDir, isMetaInf, relativeFile);
+        } catch (IOException e) {
+            getLog().error("Could not validate folder " + absoluteFile, e);
+        }
+    }
+    
+    private void validateInputStream(ValidationExecutor executor, InputStream input, File
baseDir, boolean isMetaInf, String relativeFile) throws IOException {
+        final Collection<ValidationViolation> messages;
+        if (isMetaInf) {
+            messages = executor.validateMetaInf(input, Paths.get(relativeFile), baseDir.toPath());
+        } else {
+            messages = executor.validateJcrRoot(input, Paths.get(relativeFile), baseDir.toPath());
+        }
+        validationHelper.printMessages(messages, getLog(), buildContext, project.getBasedir().toPath());
     }
 
     /**

Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidatePackageMojo.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidatePackageMojo.java?rev=1874873&r1=1874872&r2=1874873&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidatePackageMojo.java
(original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidatePackageMojo.java
Fri Mar  6 07:30:33 2020
@@ -41,6 +41,7 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.jetbrains.annotations.Nullable;
 import org.xml.sax.SAXException;
 
 
@@ -103,6 +104,7 @@ public class ValidatePackageMojo extends
             ValidationExecutor executor) throws IOException, SAXException, ParserConfigurationException
{
         for (Archive.Entry childEntry : entry.getChildren()) {
             if (childEntry.isDirectory()) {
+                validateInputStream(null, entryPath.resolve(childEntry.getName()), packagePath,
context, executor);
                 validateEntry(archive, childEntry, entryPath.resolve(childEntry.getName()),
packagePath, context, executor);
             } else {
                 try (InputStream input = archive.openInputStream(childEntry)) {
@@ -112,7 +114,7 @@ public class ValidatePackageMojo extends
         }
     }
 
-    private void validateInputStream(InputStream inputStream, Path entryPath, Path packagePath,
ArchiveValidationContextImpl context,
+    private void validateInputStream(@Nullable InputStream inputStream, Path entryPath, Path
packagePath, ArchiveValidationContextImpl context,
             ValidationExecutor executor) throws IOException, SAXException, ParserConfigurationException
{
         Collection<ValidationViolation> messages = new LinkedList<>();
         if (entryPath.startsWith(Constants.META_INF)) {
@@ -123,7 +125,7 @@ public class ValidatePackageMojo extends
             messages.addAll(executor.validateJcrRoot(inputStream, relativeJcrPath, packagePath.resolve(Constants.ROOT_DIR)));
             
             // in case this is a subpackage
-            if (entryPath.getFileName().toString().endsWith(VaultMojo.PACKAGE_EXT)) {
+            if (inputStream != null && entryPath.getFileName().toString().endsWith(VaultMojo.PACKAGE_EXT))
{
                 Path subPackagePath = context.getPackageRootPath().resolve(entryPath);
                 getLog().info("Start validating sub package '" + subPackagePath + "'...");
                 // can't use archive.getSubPackage because that holds the wrong metadata

Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidationHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidationHelper.java?rev=1874873&r1=1874872&r2=1874873&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidationHelper.java
(original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidationHelper.java
Fri Mar  6 07:30:33 2020
@@ -121,7 +121,7 @@ public class ValidationHelper {
         StringBuilder message = new StringBuilder("ValidationViolation: ");
         message.append("\"").append(getMessage(violation)).append("\"");
         if (violation.getFilePath() != null) {
-            message.append(", filePath=").append(baseDirectory.relativize(violation.getFilePath()));
+            message.append(", filePath=").append(baseDirectory.relativize(violation.getAbsoluteFilePath()));
         }
         if (violation.getNodePath() != null) {
             message.append(", nodePath=").append(violation.getNodePath());



Mime
View raw message