public Iterator<NodeKey> keys() { return references.getAllKeys(); }
@Override public int countSiblingsNamed( Name childName ) { return childRefs.getChildCount(childName); } };
private ChildReference searchReferenceForSelf( WorkspaceCache cache, CachedNode currentParent ) { ChildReferences currentReferences = currentParent.getChildReferences(cache); return currentReferences.supportsGetChildReferenceByKey() ? currentReferences.getChild(key) : cache.getChildReference(getParentKey(cache), key); }
@Test public void shouldNavigateFromRootToSystemNode() { CachedNode node = cache.getNode(cache.getRootKey()); ChildReference systemRef = node.getChildReferences(cache).getChild(JcrLexicon.SYSTEM); assertThat(refs.size(), is(1L)); Iterator<ChildReference> iter = refs.iterator(); ChildReference namespaces = refs.getChild(ModeShapeLexicon.NAMESPACES); assertThat(namespaces.getKey().toString(), is("source1system-jcrnamespaces")); assertThat(namespaces.getName(), is(ModeShapeLexicon.NAMESPACES)); nanos = System.nanoTime(); assertThat(namespacesNode.getPath(cache), is(path("/jcr:system/mode:namespaces"))); assertThat(namespacesNode.getChildReferences(cache).isEmpty(), is(true)); print("Time (read): " + millis(Math.abs(System.nanoTime() - nanos)) + " ms");
ChildReference ref = persisted.getChild(key, context); if (ref == null) { if (appended != null) { int numSnsInPersisted = persisted.getChildCount(ref.getName()); if (numSnsInPersisted != 0) { NodeKey persistedChildKey = persisted.getChild(ref.getName(), i).getKey(); if (!key.equals(persistedChildKey) && removals.contains(persistedChildKey)) { numSnsInRemoved++;
@Override public Iterator<ChildReference> iterator() { return secondReferences.iterator(name); } };
private final CachedNode findLockedNodeAtOrBelow( CachedNode node, NodeCache cache ) { if (node.getChildReferences(cache).isEmpty()) { // It is a leaf node, so just check for a lock on the node ... if (isLocked(node.getKey())) return node; } // We assume that there are far fewer locks than there are descendants of the supplied path ... Path path = node.getPath(cache); for (ModeShapeLock lock : locksByNodeKey.values()) { CachedNode lockedNode = cache.getNode(lock.getLockedNodeKey()); if (lockedNode == null) continue; Path lockedPath = lockedNode.getPath(cache); if (lockedPath.isAtOrBelow(path)) return lockedNode; } return null; }
@Override public NodeIterator getNodes() throws RepositoryException { checkSession(); ChildReferences childReferences = node().getChildReferences(sessionCache()); if (childReferences.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; // if we don't require permission checking, we should use the child references directly since it may have precomputed the size return session.checkPermissionsWhenIteratingChildren() ? new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences.iterator()) : new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences); }
public void remove( IndexDefinition indexDefn ) { assert indexDefn != null; assert system != null; MutableCachedNode indexes = mutableIndexesNode(); final NodeKey providerKey = nodeKey(indexes.getKey(), indexDefn.getProviderName()); if (indexes.getChildReferences(system).hasChild(providerKey)) { // Find the provider node ... MutableCachedNode providerNode = system.mutable(providerKey); // And remove the index defn from the provider ... final NodeKey key = nodeKey(providerNode.getKey(), indexDefn); providerNode.removeChild(system, key); system.destroy(key); // If there are no more children under the provider, remove it, too... if (providerNode.getChildReferences(system).isEmpty()) { indexes.removeChild(system, providerKey); system.destroy(providerKey); } } }
public static ChildReferences union( ChildReferences first, ChildReferences second ) { long firstSize = first.size(); long secondSize = second.size(); if (firstSize == 0 && secondSize == 0) { return EMPTY_CHILD_REFERENCES; } else if (firstSize == 0) { return second; } else if (secondSize == 0) { return first; } return new ReferencesUnion(first, second); }
NodeKey systemNodeKey = getSystemNode(systemSession).getKey(); MutableCachedNode systemNode = systemSession.mutable(systemNodeKey); ChildReference federationNodeRef = systemNode.getChildReferences(systemSession).getChild(ModeShapeLexicon.FEDERATION); ChildReferences federationChildRefs = federationNode.getChildReferences(systemSession); int projectionsCount = federationChildRefs.getChildCount(ModeShapeLexicon.PROJECTION); ChildReference projectionRef = federationChildRefs.getChild(ModeShapeLexicon.PROJECTION, i); NodeKey projectionRefKey = projectionRef.getKey(); CachedNode storedProjection = systemSession.getNode(projectionRefKey);
@Override public Iterator<ChildReference> iterator() { return secondReferences.iterator(name); } };
private final CachedNode findLockedNodeAtOrBelow( CachedNode node, NodeCache cache ) { if (node.getChildReferences(cache).isEmpty()) { // It is a leaf node, so just check for a lock on the node ... if (isLocked(node.getKey())) return node; } // We assume that there are far fewer locks than there are descendants of the supplied path ... Path path = node.getPath(cache); for (ModeShapeLock lock : locksByNodeKey.values()) { CachedNode lockedNode = cache.getNode(lock.getLockedNodeKey()); if (lockedNode == null) continue; Path lockedPath = lockedNode.getPath(cache); if (lockedPath.isAtOrBelow(path)) return lockedNode; } return null; }
@Override public NodeIterator getNodes() throws RepositoryException { checkSession(); ChildReferences childReferences = node().getChildReferences(sessionCache()); if (childReferences.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; // if we don't require permission checking, we should use the child references directly since it may have precomputed the size return session.checkPermissionsWhenIteratingChildren() ? new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences.iterator()) : new JcrChildNodeIterator(new ChildNodeResolver(session, key()), childReferences); }