JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, null, true, siblingCounter); if (childNodeDefinition != null) { childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryType, true, siblingCounter); if (childNodeDefinition == null) {
JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, null, true, siblingCounter); if (childNodeDefinition != null) { childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryType, true, siblingCounter); if (childNodeDefinition == null) {
JcrNodeDefinition match = childDefns.findBestDefinitionForChild(JcrNodeType.RESIDUAL_NAME, child.getPrimaryNodeType().getInternalName(), skipProtected, siblingCounter);
JcrNodeDefinition match = childDefns.findBestDefinitionForChild(JcrNodeType.RESIDUAL_NAME, child.getPrimaryNodeType().getInternalName(), skipProtected, siblingCounter);
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(mixinType.getInternalName(), null); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, childPrimaryType, skipProtected, siblingCounter); if (childDefn == null) {
JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(childName, childPrimaryNodeTypeName, skipProtected, siblingCounter); if (childDefn == null) {
JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(childName, childPrimaryNodeTypeName, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(mixinType.getInternalName(), null); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, childPrimaryType, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(primaryType, mixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, newPrimaryTypeName, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(primaryType, mixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, newPrimaryTypeName, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = false; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = false; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); if (childDefn == null) {
boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins); JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected, siblingCounter); if (childDefn == null) {
@Override public boolean canAddChildNode( String childNodeName, String primaryNodeTypeName ) { CheckArg.isNotNull(childNodeName, "childNodeName"); CheckArg.isNotNull(primaryNodeTypeName, "primaryNodeTypeName"); Name childName = context.getValueFactories().getNameFactory().create(childNodeName); Name childPrimaryTypeName = context.getValueFactories().getNameFactory().create(primaryNodeTypeName); NodeTypes nodeTypes = nodeTypes(); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(this.name, null); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryTypeName, skipProtected, SiblingCounter.constant(0)); if (childNodeDefinition == null) { // We found no valid child node definition ... return false; } if (RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName())) { // the TCK expects that for residual children definitions, this returns true return true; } if (childPrimaryTypeName != null) { // The child's primary node type name was given, so make sure that it is not abstract or a mixin. // If it were not for the residual item check (previous `if`), then we could do this at the top of the method. // But it has to go here. JcrNodeType childType = nodeTypes.getNodeType(childPrimaryTypeName); if (childType.isAbstract() || childType.isMixin()) return false; } return true; }
@Override public boolean canAddChildNode( String childNodeName, String primaryNodeTypeName ) { CheckArg.isNotNull(childNodeName, "childNodeName"); CheckArg.isNotNull(primaryNodeTypeName, "primaryNodeTypeName"); Name childName = context.getValueFactories().getNameFactory().create(childNodeName); Name childPrimaryTypeName = context.getValueFactories().getNameFactory().create(primaryNodeTypeName); NodeTypes nodeTypes = nodeTypes(); boolean skipProtected = true; NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(this.name, null); JcrNodeDefinition childNodeDefinition = childDefns.findBestDefinitionForChild(childName, childPrimaryTypeName, skipProtected, SiblingCounter.constant(0)); if (childNodeDefinition == null) { // We found no valid child node definition ... return false; } if (RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName())) { // the TCK expects that for residual children definitions, this returns true return true; } if (childPrimaryTypeName != null) { // The child's primary node type name was given, so make sure that it is not abstract or a mixin. // If it were not for the residual item check (previous `if`), then we could do this at the top of the method. // But it has to go here. JcrNodeType childType = nodeTypes.getNodeType(childPrimaryTypeName); if (childType.isAbstract() || childType.isMixin()) return false; } return true; }
@Test @FixFor( "MODE-1916" ) public void shouldFindPublicChildNodeDefinitionsWhenBothPublicAndProtectedAreDefined() throws Exception { InputStream cndStream = getClass().getResourceAsStream("/cnd/protectedDefinitions.cnd"); assertThat(cndStream, is(notNullValue())); nodeTypeManager().registerNodeTypes(cndStream, true); Name parking = new BasicName(null, "parking"); Name level = new BasicName(null, "level"); Set<Name> garage = Collections.<Name>singleton(new BasicName(null, "garage")); JcrNodeDefinition def = repoTypeManager.getNodeTypes().findChildNodeDefinitions(parking, garage) .findBestDefinitionForChild(level, level, true, SiblingCounter.noSiblings()); assertNotNull(def); Name car = new BasicName(null, "car"); def = repoTypeManager.getNodeTypes().findChildNodeDefinitions(parking, garage) .findBestDefinitionForChild(car, car, true, SiblingCounter.noSiblings()); assertNotNull(def); }
@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; }
@Test public void shouldAllowMultipleSiblingsDefinitionIfOneSibling() throws Exception { NamespaceRegistry registry = context.getNamespaceRegistry(); // There's no definition for this node or for a * child node that does not allow SNS JcrNodeDefinition def = repoTypeManager.getNodeTypes() .findChildNodeDefinitions(JcrNtLexicon.NODE_TYPE, null) .findBestDefinitionForChild(JcrLexicon.PROPERTY_DEFINITION, JcrNtLexicon.PROPERTY_DEFINITION, false, SiblingCounter.oneSibling()); assertThat(def, is(notNullValue())); assertThat(def.getName(), is(JcrLexicon.PROPERTY_DEFINITION.getString(registry))); }
@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; }