diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java index c982d4472d..8437405d49 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java @@ -16,14 +16,19 @@ */ package org.apache.jackrabbit.oak.plugins.nodetype.write; +import java.util.Set; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.jcr.nodetype.ConstraintViolationException; +import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.namepath.JcrNameParser; import org.apache.jackrabbit.oak.namepath.NameMapper; +import com.google.common.collect.Sets; + /** * Abstract base class for the template implementations in this package. * Keeps track of the Oak name of this template and provides utility methods @@ -178,11 +183,19 @@ abstract class NamedTemplate { protected String[] getOakNamesOrThrowConstraintViolation(@CheckForNull String[] jcrNames) throws ConstraintViolationException { if (jcrNames != null) { - String[] oakNames = new String[jcrNames.length]; + boolean hasNtBase = false; + Set oakNames = Sets.newHashSetWithExpectedSize(jcrNames.length); for (int i = 0; i < jcrNames.length; i++) { - oakNames[i] = getOakNameOrThrowConstraintViolation(jcrNames[i]); + String n = getOakNameOrThrowConstraintViolation(jcrNames[i]); + oakNames.add(n); + if (!hasNtBase && JcrConstants.NT_BASE.equals(n)) { + hasNtBase = true; + } + } + if (!hasNtBase) { + oakNames.add(JcrConstants.NT_BASE); } - return oakNames; + return oakNames.toArray(new String[] {}); } else { throw new ConstraintViolationException("Missing JCR names"); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java index 1d82fe0d9c..f4d139d0d5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java @@ -172,7 +172,6 @@ public class NodeTypeRegistryTest { } - @Ignore("OAK-6440") @Test public void registerNodeType() throws Exception { registerNodeType(root, "oak6440-1.cnd");