cschneider commented on a change in pull request #33:
URL: 
https://github.com/apache/sling-org-apache-sling-feature-analyser/pull/33#discussion_r735316553



##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/contentpackage/PackageValidator.java
##########
@@ -0,0 +1,164 @@
+/*
+ * 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.sling.feature.analyser.task.impl.contentpackage;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.ZipArchive;
+import org.apache.jackrabbit.vault.util.Constants;
+import org.apache.jackrabbit.vault.validation.ValidationExecutor;
+import org.apache.jackrabbit.vault.validation.ValidationExecutorFactory;
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.jackrabbit.vault.validation.spi.Validator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Validate a package using filevault validation API.
+ * This class contains code from filevault package maven plugin. 
+ */
+public class PackageValidator {
+    private Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    private final ValidationExecutorFactory validationExecutorFactory;
+
+    private final URI artifactURI;
+
+    private final Collection<ValidationViolation> messages;
+
+    private ArchiveValidationContextImpl context;
+
+    private ValidationExecutor executor;
+    
+    public PackageValidator(URI artifactURI) {
+        this.artifactURI = artifactURI;
+        validationExecutorFactory = new ValidationExecutorFactory(
+                this.getClass().getClassLoader());
+        messages = new LinkedList<>();
+    }
+
+    public Collection<ValidationViolation> validate() {
+        Path artifactPath = Paths.get(artifactURI);
+        try (Archive archive = new ZipArchive(new File(artifactURI))) {
+            archive.open(true);
+            context = new ArchiveValidationContextImpl(archive, artifactPath);
+            executor = 
validationExecutorFactory.createValidationExecutor(context, false, false,

Review comment:
       It looks like generic configuration would be very complicated. What 
configuration should I allow?
   I guess blacklisting validators would make sense. Anything else?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to