/** * Find all of the {@link javax.jcr.Node}s that make up the shared set. * * @return the iterator over the nodes in the node set; never null, but possibly empty if this is not shareable, or of * size 1 if the node is shareable but hasn't been shared * @throws RepositoryException if there is a problem finding the nodes in the set */ public NodeIterator getSharedNodes() throws RepositoryException { // Obtain the set of keys for all parents ... final SessionCache cache = session().cache(); Set<NodeKey> additionalParents = shareableNode.node().getAdditionalParentKeys(cache); // Obtain the Node objects for each of these ... final NodeKey key = shareableNode.key(); final String workspaceKey = key.getWorkspaceKey(); Collection<AbstractJcrNode> sharedNodes = new ArrayList<AbstractJcrNode>(additionalParents.size() + 1); sharedNodes.add(shareableNode); // add the shareable node for (NodeKey parentKey : additionalParents) { if (!workspaceKey.equals(parentKey.getWorkspaceKey())) { // The parent node has to be in this workspace ... continue; } if (session.nodeExists(parentKey)) { sharedNodes.add(getOrCreateSharedNode(parentKey)); } } // Return an iterator ... return new JcrNodeListIterator(sharedNodes.iterator(), sharedNodes.size()); } }
/** * Find all of the {@link javax.jcr.Node}s that make up the shared set. * * @return the iterator over the nodes in the node set; never null, but possibly empty if this is not shareable, or of * size 1 if the node is shareable but hasn't been shared * @throws RepositoryException if there is a problem finding the nodes in the set */ public NodeIterator getSharedNodes() throws RepositoryException { // Obtain the set of keys for all parents ... final SessionCache cache = session().cache(); Set<NodeKey> additionalParents = shareableNode.node().getAdditionalParentKeys(cache); // Obtain the Node objects for each of these ... final NodeKey key = shareableNode.key(); final String workspaceKey = key.getWorkspaceKey(); Collection<AbstractJcrNode> sharedNodes = new ArrayList<AbstractJcrNode>(additionalParents.size() + 1); sharedNodes.add(shareableNode); // add the shareable node for (NodeKey parentKey : additionalParents) { if (!workspaceKey.equals(parentKey.getWorkspaceKey())) { // The parent node has to be in this workspace ... continue; } if (session.nodeExists(parentKey)) { sharedNodes.add(getOrCreateSharedNode(parentKey)); } } // Return an iterator ... return new JcrNodeListIterator(sharedNodes.iterator(), sharedNodes.size()); } }
/** * Get the number of shared nodes within this shared set. * * @return the number of shared nodes; always 1 or more * @throws RepositoryException if there's a problem getting the size */ public int getSize() throws RepositoryException { final SessionCache cache = session().cache(); Set<NodeKey> additionalParents = shareableNode.node().getAdditionalParentKeys(cache); return additionalParents.size() + 1; }
/** * Get the number of shared nodes within this shared set. * * @return the number of shared nodes; always 1 or more * @throws RepositoryException if there's a problem getting the size */ public int getSize() throws RepositoryException { final SessionCache cache = session().cache(); Set<NodeKey> additionalParents = shareableNode.node().getAdditionalParentKeys(cache); return additionalParents.size() + 1; }
protected JcrSharedNode( SharedSet sharedSet, NodeKey parentKey ) { super(sharedSet.session(), sharedSet.key()); this.parentKey = parentKey; this.sharedSet = sharedSet; assert this.parentKey != null; assert this.sharedSet != null; }
protected JcrSharedNode( SharedSet sharedSet, NodeKey parentKey ) { super(sharedSet.session(), sharedSet.key()); this.parentKey = parentKey; this.sharedSet = sharedSet; assert this.parentKey != null; assert this.sharedSet != null; }