You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2021/09/14 09:50:31 UTC

[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu opened a new pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

raducotescu opened a new pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8


   * added support to generate provided and required capabilities based on FileVault content packages by reading the `.content.xml` files


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-920179073


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![67.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '67.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [67.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710831036



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (org.apache.jackrabbit.vault.util.Constants.DOT_CONTENT_XML.equals(file.toString())) {
+                                fileProcessor.processVaultFile(entry, resourceType, providedCapabilities, requiredCapabilities);

Review comment:
       The filename -> resource type translation is different for content packages as it supports escaping: http://jackrabbit.apache.org/filevault/vaultfs.html#Filename_escaping. I guess we need to introduce a flag to say if we process bundles or content packages.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-921800999


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![78.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '78.2%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [78.2% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710196404



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";
+    public static final String SLING_RESOURCE_SUPER_TYPE = "sling:resourceSuperType";
+    public static final String SLING_REQUIRED_RESOURCE_TYPES = "sling:requiredResourceTypes";

Review comment:
       I will document the usage of this property in a usage example where we document how to use the BND plugin from this module with a FileVault content package.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919094245


   Are you expecting the FileVault Docview files inside the scripts folder for a bundle? That way they would end up in the bundle unnecessarily. Would it make sense to process a source folder inside another Maven module (with packaging content-package)? That would require an explicit Maven dependency as well...


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r709923541



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";
+    public static final String SLING_RESOURCE_SUPER_TYPE = "sling:resourceSuperType";

Review comment:
       https://sling.apache.org/apidocs/sling11/org/apache/sling/jcr/resource/api/JcrResourceConstants.html#SLING_RESOURCE_SUPER_TYPE_PROPERTY and dependency included with scope "provided"?




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710197306



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

Review comment:
       While I agree with you regarding the memory usage, the Sax parser would not bring a lot of improvements since the parsed documents will not be held in memory after we extract the values we're interested in.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-920978915


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [5 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![72.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '72.4%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [72.4% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919004604


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![67.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '67.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [67.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708320022



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       Same as above - in this case we're only interested in the `.content.xml` files from component folders, hence why I only look for `jcr:root`. Do we need to do something more?




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708367493



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       Even component definitions might be deeply contained in a docview called "foo.xml". Look at https://jackrabbit.apache.org/filevault/vaultfs.html#Full_coverage_aggregates




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710261328



##########
File path: pom.xml
##########
@@ -236,6 +236,18 @@
             <version>1.40.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
+            <version>2.20.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.resource</artifactId>
+            <version>3.0.22</version>

Review comment:
       I don’t think you need this at runtime as all constants are inlined. Scope provided should suffice.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] removed a comment on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-920179073


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![67.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '67.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [67.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r709886476



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (Constants.VAULT_CONTEXT_XML.equals(file.toString())) {

Review comment:
       I discussed with @kwin in private and we said that for a first release of this feature we could work only with Generic Aggregates, which use the `.content.xml` file for serialization. We can add support for Full Coverage Aggregates later, if needed.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919247141


   > Is that a dedicated m-jar-plug-in execution together with bnd-maven-plugin?
   
   That would be the idea.
   
   > This deserves a dedicated documentation page.
   
   Sure, we will have an example once I assemble everything together.
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] removed a comment on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919004604


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![67.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '67.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [67.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r709869399



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";
+    public static final String SLING_RESOURCE_SUPER_TYPE = "sling:resourceSuperType";

Review comment:
       I couldn't find a constant in Sling API for `sling:resourceSuperType`. In the whole Sling project I can only find 3 constants with this value, but none of them is in Sling API.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] sonarcloud[bot] removed a comment on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-920978915


   SonarCloud Quality Gate failed.&nbsp; &nbsp; ![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL) [5 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&resolved=false&types=CODE_SMELL)
   
   [![72.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '72.4%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list) [72.4% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-scriptingbundle-maven-plugin&pullRequest=8&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710146032



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);

Review comment:
       @kwin, it seems that the `parse` method unescapes the structures mentioned in the link you pasted.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708318899



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (Constants.VAULT_CONTEXT_XML.equals(file.toString())) {

Review comment:
       Do you have a link to this utility? Does it make sense in our context? We're only trying to figure out if we're in a component folder.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710194181



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";

Review comment:
       Addressed in https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8/commits/24d6b83c3aa2517f6a8d05415f3eb8976d6cbe85.

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);

Review comment:
       Addressed in https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8/commits/24d6b83c3aa2517f6a8d05415f3eb8976d6cbe85.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r709899376



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (Constants.VAULT_CONTEXT_XML.equals(file.toString())) {

Review comment:
       In addition, it seems that the `XmlAnalyzer` has some issues in our current test setup - it only reads the first 1024 characters to figure out the serialization type. However, if the file contains a copyright header, then the class will fail to correctly identify the serialization type.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r709886560



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       I discussed with @kwin in private and we said that for a first release of this feature we could work only with Generic Aggregates, which use the `.content.xml` file for serialization. We can add support for Full Coverage Aggregates later, if needed.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710189945



##########
File path: pom.xml
##########
@@ -54,7 +54,7 @@
     </properties>
 
     <prerequisites>
-        <maven>${mavenVersion}</maven>
+        <maven>${maven.version}</maven>

Review comment:
       There is no `mavenVersion` property in version 24 of the Apache Parent POM.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708367493



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       Even component definitions might be deeply contained in a docview called "foo.xml"




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708130483



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";

Review comment:
       There is a constant in FileVault

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);

Review comment:
       You need to consider namespaces defined in the xml and check against the fully qualified element name. Docview XMLs might use other url prefixes than "sling"

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (Constants.VAULT_CONTEXT_XML.equals(file.toString())) {

Review comment:
       Every docview file may be relevant, not only the ones named ".content.xml". You should check for extension .xml first and then you need to parse the first bytes to check if it is docview. Filevault provides a utility method for that.

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       Not sure this is really invalid. Usually jcr:root means node name comes from file name, every other value means the file name's value is not considered for the node name but only the given tag name.

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

Review comment:
       I would prefer a SaxParser as it requires less memory. 

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";
+    public static final String SLING_RESOURCE_SUPER_TYPE = "sling:resourceSuperType";
+    public static final String SLING_REQUIRED_RESOURCE_TYPES = "sling:requiredResourceTypes";

Review comment:
       This requires some documentation as this is not a standard attribute.

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);

Review comment:
       Values from docview need to be unescaped.

##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/Constants.java
##########
@@ -53,6 +53,10 @@ private Constants() {}
     public static final String BND_SCRIPT_ENGINE_MAPPINGS = "scriptEngineMappings";
     public static final String BND_SEARCH_PATHS = "searchPaths";
 
+    public static final String VAULT_CONTEXT_XML = ".content.xml";
+    public static final String SLING_RESOURCE_SUPER_TYPE = "sling:resourceSuperType";

Review comment:
       There is a constant in Sling API

##########
File path: pom.xml
##########
@@ -54,7 +54,7 @@
     </properties>
 
     <prerequisites>
-        <maven>${mavenVersion}</maven>
+        <maven>${maven.version}</maven>

Review comment:
       We should use the property name from ASF parent.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r710261328



##########
File path: pom.xml
##########
@@ -236,6 +236,18 @@
             <version>1.40.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
+            <version>2.20.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.resource</artifactId>
+            <version>3.0.22</version>

Review comment:
       I don’t think you need this at runtime as all constants are inclined. Scope provided should suffice.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919244673


   TBH I don't really get who should generate the bundle then. Is that a dedicated m-jar-plug-in execution together with bnd-maven-plugin? How do you make sure the bundle is attached as 2ndary artifact? How to embed this bundle in a content package? This deserves a dedicated documentation page.


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708378848



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       It seems that the component definition is described in https://jackrabbit.apache.org/filevault/vaultfs.html#Generic_aggregates. What am I missing?




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu merged pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu merged pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8


   


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708366498



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (Constants.VAULT_CONTEXT_XML.equals(file.toString())) {

Review comment:
       https://github.com/apache/jackrabbit-filevault/blob/master/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/XmlAnalyzer.java




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#issuecomment-919201767


   > Are you expecting the FileVault Docview files inside the scripts folder for a bundle? That way they would end up in the bundle unnecessarily. Would it make sense to process a source folder inside another Maven module (with packaging content-package)? That would require an explicit Maven dependency as well...
   
   No, the idea would be to generate a precompiled scripts bundle from a content package.


-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708138049



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);

Review comment:
       Values from docview need to be unescaped. In addition type information from values need to be removed (https://jackrabbit.apache.org/filevault/docview.html)
   




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] kwin commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
kwin commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r708380511



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/filevault/VaultContentXmlReader.java
##########
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.scriptingbundle.plugin.processor.filevault;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+import org.apache.sling.scriptingbundle.plugin.processor.Constants;
+import org.jetbrains.annotations.NotNull;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class VaultContentXmlReader {
+
+    private static final DocumentBuilderFactory documentBuilderFactory;
+
+    static {
+        try {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+            documentBuilderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            documentBuilderFactory.setExpandEntityReferences(false);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException("Cannot disable DTD features.", e);
+        }
+    }
+
+    private final Path path;
+    private final String resourceSuperType;
+    private final Set<String> requiredResourceTypes;
+
+    public VaultContentXmlReader(@NotNull Path path) throws IOException {
+        this.path = path;
+        this.requiredResourceTypes = new HashSet<>();
+        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
+            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+            Document document = documentBuilder.parse(new InputSource(reader));
+            Element documentElement = document.getDocumentElement();
+            if ("jcr:root".equals(documentElement.getTagName())) {
+                this.resourceSuperType = document.getDocumentElement().getAttribute(Constants.SLING_RESOURCE_SUPER_TYPE);
+                String requiredResourceTypesValue = document.getDocumentElement().getAttribute(Constants.SLING_REQUIRED_RESOURCE_TYPES);
+                if (requiredResourceTypesValue != null) {
+                    DocViewProperty requiredResourceTypesDocView = DocViewProperty.parse(Constants.SLING_REQUIRED_RESOURCE_TYPES,
+                            requiredResourceTypesValue);
+                    requiredResourceTypes.addAll(Arrays.asList(requiredResourceTypesDocView.values));
+                }
+            } else {
+                throw new IllegalArgumentException(String.format("Path %s does not seem to be a valid Vault .content.xml file.", path));

Review comment:
       Both generic and full aggregates are valid here. Although the exporter will generate a generic aggregate even packages containing full aggregates for one/all component definitions are valid and should be accepted!




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [sling-scriptingbundle-maven-plugin] raducotescu commented on a change in pull request #8: SLING-10808 - Generate scripting capabilities from Jackrabbit FileVault content packages

Posted by GitBox <gi...@apache.org>.
raducotescu commented on a change in pull request #8:
URL: https://github.com/apache/sling-scriptingbundle-maven-plugin/pull/8#discussion_r711053266



##########
File path: src/main/java/org/apache/sling/scriptingbundle/plugin/processor/ResourceTypeFolderAnalyser.java
##########
@@ -66,6 +66,8 @@ public Capabilities getCapabilities(@NotNull Path resourceTypeDirectory) {
                                 fileProcessor.processExtendsFile(resourceType, entry, providedCapabilities, requiredCapabilities);
                             } else if (Constants.REQUIRES_FILE.equals(file.toString())) {
                                 fileProcessor.processRequiresFile(entry, requiredCapabilities);
+                            } else if (org.apache.jackrabbit.vault.util.Constants.DOT_CONTENT_XML.equals(file.toString())) {
+                                fileProcessor.processVaultFile(entry, resourceType, providedCapabilities, requiredCapabilities);

Review comment:
       Thanks for this! Implemented in https://github.com/apache/sling-scriptingbundle-maven-plugin/commit/c972385.




-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org