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



##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/CheckContentPackages.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.impl.util.ValidatorSettingsImpl;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.jackrabbit.vault.validation.spi.ValidatorSettings;
+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 analyzer checks for bundles and configurations in packages
+ */
+public class CheckContentPackages implements AnalyserTask {
+    // Comma separated list of validator ids to disable
+    static final String DISABLED_VALIDATORS = "disabled_validators";
+    static final String MAX_REPORT_LEVEL = "max_report_level";
+    private Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    @Override
+    public String getName() {
+        return "Content Package validation";
+    }
+
+    @Override
+    public String getId() {
+        return "content-packages";
+    }
+
+    @Override
+    public void execute(final AnalyserTaskContext ctx) throws Exception {
+        Map<String, ValidatorSettings> validatorSettings = new HashMap<>();
+        String disabledValidators = 
ctx.getConfiguration().get(DISABLED_VALIDATORS);
+        disableValidators(validatorSettings, disabledValidators);
+        String maxReportLevelSt = ctx.getConfiguration().get(MAX_REPORT_LEVEL);
+        ValidationMessageSeverity maxReportLevel = maxReportLevelSt == null ? 
ValidationMessageSeverity.WARN : 
ValidationMessageSeverity.valueOf(maxReportLevelSt); 
+        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 {
+                validatePackage(ctx, cp, artifactFile, validatorSettings, 
maxReportLevel);
+            }
+        }
+    }
+
+    private void disableValidators(Map<String, ValidatorSettings> 
validatorSettings,

Review comment:
       Makes sense. I wanted to be prepared for additional config to be 
present, but there is none at the moment.

##########
File path: 
src/main/java/org/apache/sling/feature/analyser/task/impl/CheckContentPackages.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jackrabbit.vault.validation.ValidationViolation;
+import org.apache.jackrabbit.vault.validation.impl.util.ValidatorSettingsImpl;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.apache.jackrabbit.vault.validation.spi.ValidatorSettings;
+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 analyzer checks for bundles and configurations in packages
+ */
+public class CheckContentPackages implements AnalyserTask {
+    // Comma separated list of validator ids to disable
+    static final String DISABLED_VALIDATORS = "disabled_validators";

Review comment:
       I will change it




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