if (!childNames.contains(childName)) { JcrNodeType childPrimaryType = defn.getDefaultPrimaryType(); addChildNode(childName, childPrimaryType.getInternalName(), null, false, false);
if (!childNames.contains(childName)) { JcrNodeType childPrimaryType = defn.getDefaultPrimaryType(); addChildNode(childName, childPrimaryType.getInternalName(), null, false, false);
@Override public boolean canAddChildNode( String childNodeName ) { CheckArg.isNotNull(childNodeName, "childNodeName"); Name childName = context.getValueFactories().getNameFactory().create(childNodeName); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes().findChildNodeDefinitions(this.name, null); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, null, skipProtected, SiblingCounter.constant(0)); // No primary node type was given, which means the child node definition (if found) must have a default type ... return childNodeDefinition != null && childNodeDefinition.getDefaultPrimaryType() != null; }
@Override public boolean canAddChildNode( String childNodeName ) { CheckArg.isNotNull(childNodeName, "childNodeName"); Name childName = context.getValueFactories().getNameFactory().create(childNodeName); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes().findChildNodeDefinitions(this.name, null); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, null, skipProtected, SiblingCounter.constant(0)); // No primary node type was given, which means the child node definition (if found) must have a default type ... return childNodeDefinition != null && childNodeDefinition.getDefaultPrimaryType() != null; }
NodeType defaultPrimaryType = childNode.getDefaultPrimaryType(); if (defaultPrimaryType != null && name.equals(defaultPrimaryType.getName())) { throw new InvalidNodeTypeDefinitionException(
NodeType defaultPrimaryType = childNode.getDefaultPrimaryType(); if (defaultPrimaryType != null && name.equals(defaultPrimaryType.getName())) { throw new InvalidNodeTypeDefinitionException(
@Test public void shouldRegisterValidTypesFromCndFile() throws Exception { nodeTypeManager.registerNodeTypes(resourceAsUrl("cnd/validType.cnd"), true); NodeType nodeType = assertNodeType("modetest:testType"); assertThat(nodeType, is(notNullValue())); assertThat(nodeType.isMixin(), is(true)); assertThat(nodeType.hasOrderableChildNodes(), is(true)); assertThat(nodeType.getDeclaredSupertypes().length, is(2)); assertThat(nodeType.getDeclaredChildNodeDefinitions().length, is(1)); JcrNodeDefinition childNode = (JcrNodeDefinition)nodeType.getDeclaredChildNodeDefinitions()[0]; assertThat(childNode.getName(), is("modetest:namespace")); assertThat(childNode.getDefaultPrimaryType().getName(), is("mode:namespace")); assertThat(childNode.getRequiredPrimaryTypes().length, is(1)); assertThat(childNode.getRequiredPrimaryTypes()[0].getName(), is("mode:namespace")); assertThat(childNode.allowsSameNameSiblings(), is(false)); assertThat(childNode.isMandatory(), is(false)); assertThat(nodeType.getDeclaredPropertyDefinitions().length, is(1)); JcrPropertyDefinition property = (JcrPropertyDefinition)nodeType.getDeclaredPropertyDefinitions()[0]; assertThat(property.getName(), is("*")); assertThat(property.getRequiredType(), is(PropertyType.STRING)); assertThat(property.getValueConstraints().length, is(3)); assertThat(property.getValueConstraints()[0], is("foo")); assertThat(property.getValueConstraints()[1], is("bar")); assertThat(property.getValueConstraints()[2], is("baz")); assertThat(property.getDefaultValues().length, is(1)); assertThat(property.getDefaultValues()[0].getString(), is("foo")); }
if (refs == null) refs = node.getChildReferences(cache); if (refs.getChildCount(nodeName) == 0) { JcrNodeType defaultPrimaryType = nodeDefn.getDefaultPrimaryType(); assert defaultPrimaryType != null; Name primaryType = defaultPrimaryType.getInternalName();
if (refs == null) refs = node.getChildReferences(cache); if (refs.getChildCount(nodeName) == 0) { JcrNodeType defaultPrimaryType = nodeDefn.getDefaultPrimaryType(); assert defaultPrimaryType != null; Name primaryType = defaultPrimaryType.getInternalName();
if (childPrimaryNodeTypeName == null && childDefn.getDefaultPrimaryType() == null) {
if (childPrimaryNodeTypeName == null && childDefn.getDefaultPrimaryType() == null) {
childPrimaryNodeTypeName = childDefn.getDefaultPrimaryType().getInternalName();
childPrimaryNodeTypeName = childDefn.getDefaultPrimaryType().getInternalName();