/** * Create a sibling counter that always returns '0' for the number of same name siblings. * * @return the counter that always returns 0; never null */ public static SiblingCounter noSiblings() { return constant(0); }
@Override public int countSiblingsNamed( Name childName ) { int count = counter.countSiblingsNamed(childName) + delta; return count > 0 ? count : 0; // never negative } };
SiblingCounter siblingCounter = SiblingCounter.alter(SiblingCounter.create(refs), -1); for (Name nodeName : mixinChildNodeNames) { int snsCount = siblingCounter.countSiblingsNamed(nodeName); if (snsCount == 0) continue; Iterator<ChildReference> iter = refs.iterator(nodeName);
Set<Name> mixins = node.getMixinTypes(cache); NodeTypes nodeTypes = session().nodeTypes(); final SiblingCounter siblingCounter = SiblingCounter.create(node, cache); int numExistingSns = siblingCounter.countSiblingsNamed(childName); String workspaceName = workspaceName(); String childPath = readable(session.pathFactory().create(path(), childName, numExistingSns + 1)); int numExistingSns = siblingCounter.countSiblingsNamed(childName); Path pathForChild = session.pathFactory().create(path(), childName, numExistingSns + 1); I18n msg = JcrI18n.unableToCreateNodeWithPrimaryTypeThatDoesNotExist; int numExistingSns = siblingCounter.countSiblingsNamed(childName); String childPath = readable(session.pathFactory().create(path(), childName, numExistingSns + 1)); I18n msg = JcrI18n.unableToCreateNodeWithNoDefaultPrimaryTypeOnChildNodeDefinition;
CachedNode persistentNode = workspaceCache.getNode(modifiedNode.getKey()); final ChildReferences persistedChildReferences = persistentNode.getChildReferences(workspaceCache); final SiblingCounter siblingCounter = SiblingCounter.create(persistedChildReferences);
@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))); }
@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); }
SiblingCounter siblingCounter = SiblingCounter.alter(SiblingCounter.create(refs), -1); for (Name nodeName : mixinChildNodeNames) { int snsCount = siblingCounter.countSiblingsNamed(nodeName); if (snsCount == 0) continue; Iterator<ChildReference> iter = refs.iterator(nodeName);
Set<Name> mixins = node.getMixinTypes(cache); NodeTypes nodeTypes = session().nodeTypes(); final SiblingCounter siblingCounter = SiblingCounter.create(node, cache); int numExistingSns = siblingCounter.countSiblingsNamed(childName); String workspaceName = workspaceName(); String childPath = readable(session.pathFactory().create(path(), childName, numExistingSns + 1)); int numExistingSns = siblingCounter.countSiblingsNamed(childName); Path pathForChild = session.pathFactory().create(path(), childName, numExistingSns + 1); I18n msg = JcrI18n.unableToCreateNodeWithPrimaryTypeThatDoesNotExist; int numExistingSns = siblingCounter.countSiblingsNamed(childName); String childPath = readable(session.pathFactory().create(path(), childName, numExistingSns + 1)); I18n msg = JcrI18n.unableToCreateNodeWithNoDefaultPrimaryTypeOnChildNodeDefinition;
CachedNode persistentNode = workspaceCache.getNode(modifiedNode.getKey()); final ChildReferences persistedChildReferences = persistentNode.getChildReferences(workspaceCache); final SiblingCounter siblingCounter = SiblingCounter.create(persistedChildReferences);
/** * Create a sibling counter that always returns '1' for the number of same name siblings. * * @return the counter that always returns 0; never null */ public static SiblingCounter oneSibling() { return constant(1); }
@Override public int countSiblingsNamed( Name childName ) { int count = counter.countSiblingsNamed(childName) + delta; return count > 0 ? count : 0; // never negative } };
SiblingCounter siblingCounter = SiblingCounter.create(node(), cache()); for (NodeIterator iter = getNodesInternal(); iter.hasNext();) { AbstractJcrNode child = (AbstractJcrNode)iter.nextNode();
/** * Create a sibling counter that always returns '1' for the number of same name siblings. * * @return the counter that always returns 0; never null */ public static SiblingCounter oneSibling() { return constant(1); }
if (siblingCounter.countSiblingsNamed(childName) > 0) {
SiblingCounter siblingCounter = SiblingCounter.create(node(), cache()); for (NodeIterator iter = getNodesInternal(); iter.hasNext();) { AbstractJcrNode child = (AbstractJcrNode)iter.nextNode();