Collection<Lock> locks = locksByHandle_.get(handle);
if (exclusive && exclusiveLocks_.containsKey(key)) {
ExclusiveLock lock = exclusiveLocks_.get(key);
if (!lock.isLockOwner(session))
throw new LockedException("File is currently locked exclusively by session " + lock.getSession());
} else if (nonExclusiveLocks_.containsKey(key)) {
NonExclusiveLock lock = nonExclusiveLocks_.get(key);
if (exclusive && !lock.isLockOwner(session))
throw new LockedException("Cannot lock file exclusivley; there are currently " + lock.getSessions().size()
+ " sessions using it non-exclusivley");
lock.incrementLock(session);
} else if (exclusive) {
ExclusiveLock lock = new ExclusiveLock(resource, session, handle);
exclusiveLocks_.put(key, lock);