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/10/12 04:40:33 UTC

[GitHub] [sling-org-apache-sling-feature-cpconverter] niekraaijmakers opened a new pull request #114: SLING-10770 - add node type support for sling initial content

niekraaijmakers opened a new pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114


   Add custom node type support for sling initial content


-- 
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-org-apache-sling-feature-cpconverter] anchela merged pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
anchela merged pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114


   


-- 
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-org-apache-sling-feature-cpconverter] sonarcloud[bot] commented on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-941099977


   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; ![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL)
   
   [![94.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png '94.1%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_coverage&view=list) [94.1% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter] anchela commented on a change in pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
anchela commented on a change in pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#discussion_r726834096



##########
File path: src/main/java/org/apache/sling/feature/cpconverter/vltpkg/JcrNamespaceRegistry.java
##########
@@ -16,89 +16,92 @@
  */
 package org.apache.sling.feature.cpconverter.vltpkg;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeManagerProvider;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.jetbrains.annotations.NotNull;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 
 /** Simple namespace registry backed by a map */
 public class JcrNamespaceRegistry implements NamespaceRegistry, NamespaceResolver {
 
-    private final Map<String, String> prefixUriMapping;
-    private final Collection<String> registeredCndSystemIds;
-    
-    public JcrNamespaceRegistry() {
-        prefixUriMapping = new HashMap<>();
-        prefixUriMapping.put(PREFIX_JCR, NAMESPACE_JCR);
-        prefixUriMapping.put(PREFIX_MIX, NAMESPACE_MIX);
-        prefixUriMapping.put(PREFIX_NT, NAMESPACE_NT);
-        prefixUriMapping.put(PREFIX_XML, NAMESPACE_XML);
-        // referencing from org.apache.sling.jcr.resource.api.JcrResourceConstants.SLING_NAMESPACE_URI would require an additional dependency
-        prefixUriMapping.put("sling", "http://sling.apache.org/jcr/sling/1.0");
-        registeredCndSystemIds = new ArrayList<>();
+    protected final Logger logger = LoggerFactory.getLogger(getClass());

Review comment:
       @niekraaijmakers maybe i am just blind..... but i don't see the logger being used. if that's the case i would suggest to remove it. if it is used, i think making the field private would be better.

##########
File path: src/main/java/org/apache/sling/feature/cpconverter/vltpkg/JcrNamespaceRegistry.java
##########
@@ -16,89 +16,92 @@
  */
 package org.apache.sling.feature.cpconverter.vltpkg;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeManagerProvider;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.jetbrains.annotations.NotNull;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 
 /** Simple namespace registry backed by a map */
 public class JcrNamespaceRegistry implements NamespaceRegistry, NamespaceResolver {
 
-    private final Map<String, String> prefixUriMapping;
-    private final Collection<String> registeredCndSystemIds;
-    
-    public JcrNamespaceRegistry() {
-        prefixUriMapping = new HashMap<>();
-        prefixUriMapping.put(PREFIX_JCR, NAMESPACE_JCR);
-        prefixUriMapping.put(PREFIX_MIX, NAMESPACE_MIX);
-        prefixUriMapping.put(PREFIX_NT, NAMESPACE_NT);
-        prefixUriMapping.put(PREFIX_XML, NAMESPACE_XML);
-        // referencing from org.apache.sling.jcr.resource.api.JcrResourceConstants.SLING_NAMESPACE_URI would require an additional dependency
-        prefixUriMapping.put("sling", "http://sling.apache.org/jcr/sling/1.0");
-        registeredCndSystemIds = new ArrayList<>();
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+    private final Collection<String> registeredCndSystemIds = new ArrayList<>();
+    private final NodeTypeManagerProvider ntManagerProvider = new NodeTypeManagerProvider();
+    private final NodeTypeManager ntManager;
+
+    public JcrNamespaceRegistry() throws RepositoryException, ParseException, IOException {
+        ntManager = ntManagerProvider.getNodeTypeManager();

Review comment:
       why assigning the 'ntManagerProvider' direct and the 'ntManager' here? nothing wrong about it just curious.

##########
File path: src/main/java/org/apache/sling/feature/cpconverter/vltpkg/JcrNamespaceRegistry.java
##########
@@ -16,89 +16,92 @@
  */
 package org.apache.sling.feature.cpconverter.vltpkg;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeManagerProvider;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.jetbrains.annotations.NotNull;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 
 /** Simple namespace registry backed by a map */
 public class JcrNamespaceRegistry implements NamespaceRegistry, NamespaceResolver {
 
-    private final Map<String, String> prefixUriMapping;
-    private final Collection<String> registeredCndSystemIds;
-    
-    public JcrNamespaceRegistry() {
-        prefixUriMapping = new HashMap<>();
-        prefixUriMapping.put(PREFIX_JCR, NAMESPACE_JCR);
-        prefixUriMapping.put(PREFIX_MIX, NAMESPACE_MIX);
-        prefixUriMapping.put(PREFIX_NT, NAMESPACE_NT);
-        prefixUriMapping.put(PREFIX_XML, NAMESPACE_XML);
-        // referencing from org.apache.sling.jcr.resource.api.JcrResourceConstants.SLING_NAMESPACE_URI would require an additional dependency
-        prefixUriMapping.put("sling", "http://sling.apache.org/jcr/sling/1.0");
-        registeredCndSystemIds = new ArrayList<>();
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+    private final Collection<String> registeredCndSystemIds = new ArrayList<>();
+    private final NodeTypeManagerProvider ntManagerProvider = new NodeTypeManagerProvider();
+    private final NodeTypeManager ntManager;
+
+    public JcrNamespaceRegistry() throws RepositoryException, ParseException, IOException {
+        ntManager = ntManagerProvider.getNodeTypeManager();
+        ntManagerProvider.registerNamespace(PREFIX_XML, NAMESPACE_XML);
     }
 
     public void registerCnd(Reader reader, String systemId) throws ParseException, RepositoryException, IOException {
-        throw new IllegalStateException("Not implemented");
-        /*
-        TODO: SLING-10770, implement CND support
-            NodeTypeManager ntManager = null;
-            ValueFactory valueFactory = null;
-            CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
-            registeredCndSystemIds.add(systemId);
-         */
+        ValueFactory valueFactory = new SimpleValueFactory();
+        CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
+        registeredCndSystemIds.add(systemId);
     }
 
     @Override
     public void registerNamespace(String prefix, String uri)
             throws RepositoryException {
-        String oldUri = prefixUriMapping.putIfAbsent(prefix, uri);
-        if (oldUri != null && !oldUri.equals(uri)) {
-            throw new RepositoryException("Prefix " + prefix + " already used for another uri!");
-        }
+        ntManagerProvider.registerNamespace(prefix, uri);
     }
 
     @Override
     public void unregisterNamespace(String prefix)
             throws RepositoryException {
-        throw new UnsupportedOperationException("Unregistering namespaces is unsupported");
+        ntManagerProvider.unregisterNamespace(prefix);
     }
 
     @Override
     public String[] getPrefixes() throws RepositoryException {
-        return prefixUriMapping.keySet().toArray(new String[0]);
+        String[] stringArray = getPrefixStringArray();

Review comment:
       i don't think this is required.
   actually my IDE complains about calling `toArray` with a array of defined size. i would rather pass `new String[0]` instead as it is done in other parts of the converter.

##########
File path: src/main/java/org/apache/sling/feature/cpconverter/vltpkg/JcrNamespaceRegistry.java
##########
@@ -16,89 +16,92 @@
  */
 package org.apache.sling.feature.cpconverter.vltpkg;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeManagerProvider;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.jetbrains.annotations.NotNull;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 
 /** Simple namespace registry backed by a map */
 public class JcrNamespaceRegistry implements NamespaceRegistry, NamespaceResolver {
 
-    private final Map<String, String> prefixUriMapping;
-    private final Collection<String> registeredCndSystemIds;
-    
-    public JcrNamespaceRegistry() {
-        prefixUriMapping = new HashMap<>();
-        prefixUriMapping.put(PREFIX_JCR, NAMESPACE_JCR);
-        prefixUriMapping.put(PREFIX_MIX, NAMESPACE_MIX);
-        prefixUriMapping.put(PREFIX_NT, NAMESPACE_NT);
-        prefixUriMapping.put(PREFIX_XML, NAMESPACE_XML);
-        // referencing from org.apache.sling.jcr.resource.api.JcrResourceConstants.SLING_NAMESPACE_URI would require an additional dependency
-        prefixUriMapping.put("sling", "http://sling.apache.org/jcr/sling/1.0");
-        registeredCndSystemIds = new ArrayList<>();
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+    private final Collection<String> registeredCndSystemIds = new ArrayList<>();
+    private final NodeTypeManagerProvider ntManagerProvider = new NodeTypeManagerProvider();
+    private final NodeTypeManager ntManager;
+
+    public JcrNamespaceRegistry() throws RepositoryException, ParseException, IOException {
+        ntManager = ntManagerProvider.getNodeTypeManager();
+        ntManagerProvider.registerNamespace(PREFIX_XML, NAMESPACE_XML);
     }
 
     public void registerCnd(Reader reader, String systemId) throws ParseException, RepositoryException, IOException {
-        throw new IllegalStateException("Not implemented");
-        /*
-        TODO: SLING-10770, implement CND support
-            NodeTypeManager ntManager = null;
-            ValueFactory valueFactory = null;
-            CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
-            registeredCndSystemIds.add(systemId);
-         */
+        ValueFactory valueFactory = new SimpleValueFactory();
+        CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
+        registeredCndSystemIds.add(systemId);
     }
 
     @Override
     public void registerNamespace(String prefix, String uri)
             throws RepositoryException {
-        String oldUri = prefixUriMapping.putIfAbsent(prefix, uri);
-        if (oldUri != null && !oldUri.equals(uri)) {
-            throw new RepositoryException("Prefix " + prefix + " already used for another uri!");
-        }
+        ntManagerProvider.registerNamespace(prefix, uri);
     }
 
     @Override
     public void unregisterNamespace(String prefix)
             throws RepositoryException {
-        throw new UnsupportedOperationException("Unregistering namespaces is unsupported");
+        ntManagerProvider.unregisterNamespace(prefix);
     }
 
     @Override
     public String[] getPrefixes() throws RepositoryException {
-        return prefixUriMapping.keySet().toArray(new String[0]);
+        String[] stringArray = getPrefixStringArray();
+        return ntManagerProvider.getRegisteredNamespaces().keySet().toArray(stringArray);
     }
 
     @Override
     public String[] getURIs() throws RepositoryException {
-        return prefixUriMapping.values().toArray(new String[0]);
+        String[] stringArray = getPrefixStringArray();

Review comment:
       same as above
   

##########
File path: src/main/java/org/apache/sling/feature/cpconverter/vltpkg/JcrNamespaceRegistry.java
##########
@@ -16,89 +16,92 @@
  */
 package org.apache.sling.feature.cpconverter.vltpkg;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeManagerProvider;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.jetbrains.annotations.NotNull;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
 
 /** Simple namespace registry backed by a map */
 public class JcrNamespaceRegistry implements NamespaceRegistry, NamespaceResolver {
 
-    private final Map<String, String> prefixUriMapping;
-    private final Collection<String> registeredCndSystemIds;
-    
-    public JcrNamespaceRegistry() {
-        prefixUriMapping = new HashMap<>();
-        prefixUriMapping.put(PREFIX_JCR, NAMESPACE_JCR);
-        prefixUriMapping.put(PREFIX_MIX, NAMESPACE_MIX);
-        prefixUriMapping.put(PREFIX_NT, NAMESPACE_NT);
-        prefixUriMapping.put(PREFIX_XML, NAMESPACE_XML);
-        // referencing from org.apache.sling.jcr.resource.api.JcrResourceConstants.SLING_NAMESPACE_URI would require an additional dependency
-        prefixUriMapping.put("sling", "http://sling.apache.org/jcr/sling/1.0");
-        registeredCndSystemIds = new ArrayList<>();
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+    private final Collection<String> registeredCndSystemIds = new ArrayList<>();
+    private final NodeTypeManagerProvider ntManagerProvider = new NodeTypeManagerProvider();
+    private final NodeTypeManager ntManager;
+
+    public JcrNamespaceRegistry() throws RepositoryException, ParseException, IOException {
+        ntManager = ntManagerProvider.getNodeTypeManager();
+        ntManagerProvider.registerNamespace(PREFIX_XML, NAMESPACE_XML);
     }
 
     public void registerCnd(Reader reader, String systemId) throws ParseException, RepositoryException, IOException {
-        throw new IllegalStateException("Not implemented");
-        /*
-        TODO: SLING-10770, implement CND support
-            NodeTypeManager ntManager = null;
-            ValueFactory valueFactory = null;
-            CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
-            registeredCndSystemIds.add(systemId);
-         */
+        ValueFactory valueFactory = new SimpleValueFactory();
+        CndImporter.registerNodeTypes(reader, systemId, ntManager, this, valueFactory, false);
+        registeredCndSystemIds.add(systemId);
     }
 
     @Override
     public void registerNamespace(String prefix, String uri)
             throws RepositoryException {
-        String oldUri = prefixUriMapping.putIfAbsent(prefix, uri);
-        if (oldUri != null && !oldUri.equals(uri)) {
-            throw new RepositoryException("Prefix " + prefix + " already used for another uri!");
-        }
+        ntManagerProvider.registerNamespace(prefix, uri);
     }
 
     @Override
     public void unregisterNamespace(String prefix)
             throws RepositoryException {
-        throw new UnsupportedOperationException("Unregistering namespaces is unsupported");
+        ntManagerProvider.unregisterNamespace(prefix);
     }
 
     @Override
     public String[] getPrefixes() throws RepositoryException {
-        return prefixUriMapping.keySet().toArray(new String[0]);
+        String[] stringArray = getPrefixStringArray();
+        return ntManagerProvider.getRegisteredNamespaces().keySet().toArray(stringArray);
     }
 
     @Override
     public String[] getURIs() throws RepositoryException {
-        return prefixUriMapping.values().toArray(new String[0]);
+        String[] stringArray = getPrefixStringArray();
+        return ntManagerProvider.getRegisteredNamespaces().values().toArray(stringArray);
     }
 
     @Override
     public String getURI(String prefix) throws NamespaceException {
-        String uri = prefixUriMapping.get(prefix);
-        if (uri == null) {
-            throw new NamespaceException("No registered URI found for prefix " + prefix);
+        try {
+            return ntManagerProvider.getURI(prefix);
+        } catch (RepositoryException e) {
+            throw new NamespaceException(e);
         }
-        return uri;
     }
 
     @Override
     public String getPrefix(String uri) throws NamespaceException {
-        throw new UnsupportedOperationException("This lookup direction is unsupported");
+        try {
+            return ntManagerProvider.getPrefix(uri);
+        } catch (RepositoryException e) {
+            throw new NamespaceException(e);
+        }
     }
 
     public @NotNull Collection<String> getRegisteredCndSystemIds() {
         return registeredCndSystemIds;
     }
+
+    @NotNull
+    private String[] getPrefixStringArray() throws RepositoryException {

Review comment:
       see above. IMHO this method is not 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-org-apache-sling-feature-cpconverter] sonarcloud[bot] removed a comment on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-941065577


   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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL)
   
   [![58.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/50-16px.png '58.8%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_coverage&view=list) [58.8% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter] anchela commented on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
anchela commented on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-941040191


   @niekraaijmakers , applied the patch to my local checkout to see what causes the test failure and spotted 2 more minor things, i would suggest you fix:
   - unused import for logger/loggerfactory in JcrNamespaceRegistry
   - there is a TODO and a warning related to SLING-10770 on line 308..... can you drop that as well?:
   ```
    // TODO: SLING-10770, remove this warning when support for CND files is added - see JcrNamespaceRegistry#registerCnd
               logger.warn("Unable to check for CND files for sling inital content - Not implemented!");
   ```
               


-- 
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-org-apache-sling-feature-cpconverter] anchela commented on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
anchela commented on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-940957800


   @niekraaijmakers , just noticed that there was a test failing (but not the one you created afaik): 
   
   ```
   [ERROR] Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.343 s <<< FAILURE! - in org.apache.sling.feature.cpconverter.handlers.BundleEntryHandleSlingInitialContentTest
   [ERROR] org.apache.sling.feature.cpconverter.handlers.BundleEntryHandleSlingInitialContentTest.testSlingInitialContent  Time elapsed: 0.092 s  <<< ERROR!
   java.io.IOException: Can not convert SLING-INF/app-root/components/global/include/mediaFormatSelection.json to enhanced DocView format
   	at org.apache.sling.feature.cpconverter.handlers.BundleEntryHandler.extractSlingInitialContent(BundleEntryHandler.java:303)
   	at org.apache.sling.feature.cpconverter.handlers.BundleEntryHandler.extractSlingInitialContent(BundleEntryHandler.java:247)
   	at org.apache.sling.feature.cpconverter.handlers.BundleEntryHandler.processBundleInputStream(BundleEntryHandler.java:191)
   	at org.apache.sling.feature.cpconverter.handlers.BundleEntryHandler.handle(BundleEntryHandler.java:179)
   	at org.apache.sling.feature.cpconverter.handlers.BundleEntryHandleSlingInitialContentTest.testSlingInitialContent(BundleEntryHandleSlingInitialContentTest.java:83)
   ```
   do you happen to know what causes this?


-- 
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-org-apache-sling-feature-cpconverter] anchela commented on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
anchela commented on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-941107473


   thanks @niekraaijmakers  for the patch!


-- 
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-org-apache-sling-feature-cpconverter] sonarcloud[bot] commented on pull request #114: SLING-10770 - add node type support for sling initial content

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #114:
URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/114#issuecomment-941065577


   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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&resolved=false&types=CODE_SMELL)
   
   [![58.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/50-16px.png '58.8%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_coverage&view=list) [58.8% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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-org-apache-sling-feature-cpconverter&pullRequest=114&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&pullRequest=114&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