if (!this.session.repository().lockingUsed()) {
//if locking hasn't been used at all, there's nothing to check
return null;
}
SessionCache sessionCache = session.cache();
NodeCache cache = sessionCache;
NodeKey nodeKey = node.key();
NodeKey key = nodeKey;
while (key != null) {
ModeShapeLock lock = lockManager.findLockFor(key);
if (lock != null && (lock.isDeep() || nodeKey.equals(lock.getLockedNodeKey()))) {
// There is a lock that applies to 'node', either because the lock is actually on 'node' or because
// an ancestor node is locked with a deep lock...
return lock;
}
// Otherwise, get the parent, but use the cache directly ...
CachedNode cachedNode = cache.getNode(key);
if (cachedNode == null) {
// The node has been removed, so get the node from the workspace cache ...
if (sessionCache == cache) {
cache = sessionCache.getWorkspace();
cachedNode = cache.getNode(key);
}
if (cachedNode == null) break;
}
key = cachedNode.getParentKey(cache);
}