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



##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/CheckContentPackages.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
+import 
org.apache.sling.feature.analyser.task.impl.contentpackage.PackageValidator;
+import org.apache.sling.feature.scanner.ContentPackageDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This analyser checks for bundles and configurations in packages
+ */
+public class CheckContentPackages implements AnalyserTask {
+    Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    @Override
+    public String getName() {
+        return "Content Package xml syntax check";
+    }
+
+    @Override
+    public String getId() {
+        return "content-packages-syntax";
+    }
+
+    @Override
+    public void execute(final AnalyserTaskContext ctx)
+            throws Exception {
+
+        for (final ContentPackageDescriptor cp : 
ctx.getFeatureDescriptor().getDescriptors(ContentPackageDescriptor.class)) {
+            URL artifactFile = cp.getArtifactFile();
+            if (artifactFile ==  null) {
+                ctx.reportArtifactError(cp.getArtifact().getId(), "Content 
package " + cp.getName() + " is not resolved and can not be checked.");
+            } else {
+                checkPackageSyntax(ctx, cp, artifactFile);
+            }
+        }
+    }
+
+    private void checkPackageSyntax(final AnalyserTaskContext ctx, final 
ContentPackageDescriptor cp, URL artifactFile) {

Review comment:
       validatePackage

##########
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:
       Please make the validator settings configurable through setting the 
fourth parameter

##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/contentpackage/ArchiveValidationContextImpl.java
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.nio.file.Path;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.packaging.PackageInfo;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.validation.spi.ValidationContext;
+
+
+/**
+ * Implements a validation context based on a given {@link Archive}.
+ */
+public class ArchiveValidationContextImpl implements ValidationContext {

Review comment:
       I can put the ValidationContext implementation to the FileVault 
validation module and export them. That way there is no need to copy this from 
the maven plugin

##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/CheckContentPackages.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
+import 
org.apache.sling.feature.analyser.task.impl.contentpackage.PackageValidator;
+import org.apache.sling.feature.scanner.ContentPackageDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This analyser checks for bundles and configurations in packages
+ */
+public class CheckContentPackages implements AnalyserTask {
+    Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    @Override
+    public String getName() {
+        return "Content Package xml syntax check";
+    }
+
+    @Override
+    public String getId() {
+        return "content-packages-syntax";

Review comment:
       rather content-package-validation

##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/CheckContentPackages.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
+import 
org.apache.sling.feature.analyser.task.impl.contentpackage.PackageValidator;
+import org.apache.sling.feature.scanner.ContentPackageDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This analyser checks for bundles and configurations in packages
+ */
+public class CheckContentPackages implements AnalyserTask {
+    Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    @Override
+    public String getName() {
+        return "Content Package xml syntax check";

Review comment:
       If you use all validators it is much more than that: 
https://jackrabbit.apache.org/filevault/validation.html#Standard_Validators




-- 
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