return !definition.isMandatory(); return !definition.isMandatory();
return !definition.isMandatory(); return !definition.isMandatory();
JcrNodeDefinition with( ExecutionContext context ) { return new JcrNodeDefinition(context, this.nodeTypeManager, this.declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
JcrNodeDefinition with( RepositoryNodeTypeManager nodeTypeManager ) { return new JcrNodeDefinition(this.context, nodeTypeManager, this.declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
JcrNodeDefinition with( ExecutionContext context ) { return new JcrNodeDefinition(context, this.nodeTypeManager, this.declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
JcrNodeDefinition with( RepositoryNodeTypeManager nodeTypeManager ) { return new JcrNodeDefinition(this.context, nodeTypeManager, this.declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
boolean mixinWithNoChildNodeDefinitions = nodeType.isMixin() && allChildNodeDefinitions.isEmpty(); for (JcrNodeDefinition childDefn : allChildNodeDefinitions) { if (childDefn.isMandatory() && !childDefn.isProtected()) { mandatoryChildrenNodeTypes.put(name, childDefn); fullyDefined = false;
boolean mixinWithNoChildNodeDefinitions = nodeType.isMixin() && allChildNodeDefinitions.isEmpty(); for (JcrNodeDefinition childDefn : allChildNodeDefinitions) { if (childDefn.isMandatory() && !childDefn.isProtected()) { mandatoryChildrenNodeTypes.put(name, childDefn); fullyDefined = false;
/** * Creates a new <code>JcrNodeDefinition</code> that is identical to the current object, but with the given * <code>declaringNodeType</code>. Provided to support immutable pattern for this class. * * @param declaringNodeType the declaring node type for the new <code>JcrNodeDefinition</code> * @return a new <code>JcrNodeDefinition</code> that is identical to the current object, but with the given * <code>declaringNodeType</code>. */ JcrNodeDefinition with( JcrNodeType declaringNodeType ) { return new JcrNodeDefinition(this.context, declaringNodeType.nodeTypeManager(), declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
/** * Creates a new <code>JcrNodeDefinition</code> that is identical to the current object, but with the given * <code>declaringNodeType</code>. Provided to support immutable pattern for this class. * * @param declaringNodeType the declaring node type for the new <code>JcrNodeDefinition</code> * @return a new <code>JcrNodeDefinition</code> that is identical to the current object, but with the given * <code>declaringNodeType</code>. */ JcrNodeDefinition with( JcrNodeType declaringNodeType ) { return new JcrNodeDefinition(this.context, declaringNodeType.nodeTypeManager(), declaringNodeType, key(), name, getOnParentVersion(), isAutoCreated(), isMandatory(), isProtected(), allowsSameNameSiblings(), defaultPrimaryTypeName, requiredPrimaryTypeNames); }
OnParentVersionAction.nameFromValue(childNodeDef.getOnParentVersion()))); props.add(propertyFactory.create(JcrLexicon.AUTO_CREATED, childNodeDef.isAutoCreated())); props.add(propertyFactory.create(JcrLexicon.MANDATORY, childNodeDef.isMandatory())); props.add(propertyFactory.create(JcrLexicon.PROTECTED, childNodeDef.isProtected()));
return !definition.isMandatory(); return !definition.isMandatory();
OnParentVersionAction.nameFromValue(childNodeDef.getOnParentVersion()))); props.add(propertyFactory.create(JcrLexicon.AUTO_CREATED, childNodeDef.isAutoCreated())); props.add(propertyFactory.create(JcrLexicon.MANDATORY, childNodeDef.isMandatory())); props.add(propertyFactory.create(JcrLexicon.PROTECTED, childNodeDef.isProtected()));
return !definition.isMandatory(); return !definition.isMandatory();
private static void compareNodeTemplateToNodeDefinition( JcrNodeDefinitionTemplate template, JcrNodeDefinition definition ) { assertThat(definition, is(notNullValue())); assertThat(definition.getDeclaringNodeType(), is(notNullValue())); // Had to match on name to even get to the definition // assertThat(template.getName(), is(definition.getName())); assertThat(template.getOnParentVersion(), is(definition.getOnParentVersion())); assertThat(template.isAutoCreated(), is(definition.isAutoCreated())); assertThat(template.isMandatory(), is(definition.isMandatory())); assertThat(template.isProtected(), is(definition.isProtected())); assertThat(template.getDefaultPrimaryTypeName(), is(definition.getDefaultPrimaryTypeName())); assertThat(template.allowsSameNameSiblings(), is(definition.allowsSameNameSiblings())); // assertThat(template.getRequiredPrimaryTypeNames(), is(definition.getRequiredPrimaryTypeNames())); }
@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 (childNodeDefinition.isMandatory() && residual) { throw new InvalidNodeTypeDefinitionException( JcrI18n.residualNodeDefinitionsCannotBeMandatory.text(childNodeDefinition.getName())); if (childNodeFromAncestor.isMandatory() && !childNodeDefinition.isMandatory()) { throw new InvalidNodeTypeDefinitionException( JcrI18n.cannotMakeMandatoryDefinitionOptional.text(childNodeFromAncestor.getDeclaringNodeType()
if (childNodeDefinition.isMandatory() && residual) { throw new InvalidNodeTypeDefinitionException( JcrI18n.residualNodeDefinitionsCannotBeMandatory.text(childNodeDefinition.getName())); if (childNodeFromAncestor.isMandatory() && !childNodeDefinition.isMandatory()) { throw new InvalidNodeTypeDefinitionException( JcrI18n.cannotMakeMandatoryDefinitionOptional.text(childNodeFromAncestor.getDeclaringNodeType()