/** * Get the {@link SharedSet} for the given shareable node. * * @param shareableNode the shareable node * @return the SharedSet; never null */ public SharedSet getSharedSet( AbstractJcrNode shareableNode ) { NodeKey shareableNodeKey = shareableNode.key(); return sharedSets.computeIfAbsent(shareableNodeKey, key -> new SharedSet(shareableNode)); }
/** * Get the {@link SharedSet} for the given shareable node. * * @param shareableNode the shareable node * @return the SharedSet; never null */ public SharedSet getSharedSet( AbstractJcrNode shareableNode ) { NodeKey shareableNodeKey = shareableNode.key(); return sharedSets.computeIfAbsent(shareableNodeKey, key -> new SharedSet(shareableNode)); }
/** * Signal that the supplied node was removed from it's parent. This method will adjust the corresponding {@link SharedSet} * even if the removed node was the original shareable node. * * @param shareableNode the shareable node that was removed from its shared set * @throws RepositoryException if there is a problem */ public void removed( AbstractJcrNode shareableNode ) throws RepositoryException { NodeKey shareableNodeKey = shareableNode.key(); SharedSet sharedSet = getSharedSet(shareableNode); if (sharedSet.shareableNode == shareableNode) { // We're removing the original shareable node, so we need to recreate the SharedSet after // we figure out the new parent ... session().releaseCachedNode(shareableNode); AbstractJcrNode newShared = session().node(shareableNodeKey, null); SharedSet newSharedSet = new SharedSet(newShared); sharedSets.put(shareableNodeKey, newSharedSet); } else { assert shareableNode instanceof JcrSharedNode; sharedSet.remove((JcrSharedNode)shareableNode); } }
/** * Signal that the supplied node was removed from it's parent. This method will adjust the corresponding {@link SharedSet} * even if the removed node was the original shareable node. * * @param shareableNode the shareable node that was removed from its shared set * @throws RepositoryException if there is a problem */ public void removed( AbstractJcrNode shareableNode ) throws RepositoryException { NodeKey shareableNodeKey = shareableNode.key(); SharedSet sharedSet = getSharedSet(shareableNode); if (sharedSet.shareableNode == shareableNode) { // We're removing the original shareable node, so we need to recreate the SharedSet after // we figure out the new parent ... session().releaseCachedNode(shareableNode); AbstractJcrNode newShared = session().node(shareableNodeKey, null); SharedSet newSharedSet = new SharedSet(newShared); sharedSets.put(shareableNodeKey, newSharedSet); } else { assert shareableNode instanceof JcrSharedNode; sharedSet.remove((JcrSharedNode)shareableNode); } }