* @throws RepositoryException if another error occurs
*/
AbstractLockInfo internalLock(NodeImpl node, boolean isDeep, boolean isSessionScoped)
throws LockException, RepositoryException {
SessionImpl session = (SessionImpl) node.getSession();
LockInfo info = new LockInfo(new LockToken(node.getNodeId()),
isSessionScoped, isDeep, session.getUserID());
acquire();
try {
// check whether node is already locked
Path path = getPath(node.getId());
PathMap.Element element = lockMap.map(path, false);
LockInfo other = (LockInfo) element.get();
if (other != null) {
if (element.hasPath(path)) {
throw new LockException("Node already locked: " + node.safeGetJCRPath());
} else if (other.deep) {
throw new LockException("Parent node has deep lock.");
}
}
if (info.deep && element.hasPath(path)
&& element.getChildrenCount() > 0) {
throw new LockException("Some child node is locked.");
}
// create lock token
info.setLockHolder(session);
info.setLive(true);
session.addListener(info);
session.addLockToken(info.lockToken.toString(), false);
lockMap.put(path, info);
if (!info.sessionScoped) {
save();
}