protected void doRemove()
throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
// Sometimes, a shareable and shared node is represented by a JcrNode rather than a JcrSharedNode. Therefore,
// the share-related logic needs to be done here ...
SessionCache cache = sessionCache();
NodeKey key = key();
MutableCachedNode parent = mutableParent();
if (!isShareable()) {
// It's not shareable, so we will always destroy the node immediately ...
parent.removeChild(cache, key);
cache.destroy(key);
return;
}
// It is shareable, so we need to check how many shares there are before we remove this node from its parent ...
JcrSharedNodeCache shareableNodeCache = session().shareableNodeCache();
SharedSet sharedSet = shareableNodeCache.getSharedSet(this);
if (sharedSet.getSize() <= 1) {
// There are no shares, so destroy the node and the shared set ...
parent.removeChild(cache, key);
cache.destroy(key);
shareableNodeCache.destroyed(key);
return;
}
// The node being removed is shared to at least two places, so we should remove it from the primary parent,