Fix unlock issues.

This commit is contained in:
Paulo Gustavo Veiga
2013-04-07 12:27:45 -03:00
parent 31fb342ef1
commit a230dd104c
4 changed files with 63 additions and 10 deletions

View File

@@ -79,6 +79,17 @@ class LockManagerImpl implements LockManager {
return result;
}
@Override
public void unlockAll(@NotNull final User user) throws LockException, AccessDeniedSecurityException {
final Set<Integer> mapIds = lockInfoByMapId.keySet();
for (final Integer mapId : mapIds) {
final LockInfo lockInfo = lockInfoByMapId.get(mapId);
if (lockInfo.getUser().identityEquality(user)) {
unlock(mapId);
}
}
}
@Override
public void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException {
if (isLocked(mindmap) && !isLockedBy(mindmap, user)) {
@@ -93,6 +104,8 @@ class LockManagerImpl implements LockManager {
}
private void unlock(int mapId) {
System.out.println("Unlocking:"+mapId);
logger.debug("Unlock map id:" + mapId);
lockInfoByMapId.remove(mapId);
}
@@ -108,12 +121,6 @@ class LockManagerImpl implements LockManager {
}
@Override
@NotNull
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
return this.lock(mindmap, user, System.nanoTime());
}
@Override
public long generateSession() {
return System.nanoTime();
@@ -135,7 +142,7 @@ class LockManagerImpl implements LockManager {
// Update timeout only...
logger.debug("Update timestamp:" + mindmap.getId());
updateExpirationTimeout(mindmap, user);
// result.setSession(session);
// result.setSession(session);
} else {
logger.debug("Lock map id:" + mindmap.getId());
result = new LockInfo(user, mindmap, session);