Avoid additional checks ...

This commit is contained in:
Paulo Gustavo Veiga 2012-11-16 22:37:29 -03:00
parent 7ba21f85bf
commit 58ed80d763
2 changed files with 6 additions and 6 deletions

View File

@ -26,8 +26,8 @@ public class SessionExpiredException
public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
private User lastUpdater;
public SessionExpiredException(@NotNull User lastUpdater) {
super("Map has been updated by " + (lastUpdater != null ? lastUpdater.getEmail() : ""), Severity.FATAL);
public SessionExpiredException(@NotNull String debugInfo, @NotNull User lastUpdater) {
super(debugInfo, Severity.FATAL);
this.lastUpdater = lastUpdater;
}

View File

@ -188,15 +188,15 @@ public class MindmapController extends BaseController {
if (lockInfo.getSession() == session) {
// Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check.
final User lastEditor = mindmap.getLastEditor();
// lockInfo.getPreviousTimestamp() == timestamp : In case the timestap is not returned. Give a second chance.
if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.identityEquality(user))) {
throw new SessionExpiredException(lastEditor);
boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor);
if (outdated && !editedBySameUser) {
throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + mindmap.getLastModificationTime().getTimeInMillis(), lastEditor);
}
} else if (outdated) {
throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + lockInfo.getTimestamp());
}
} else {
throw new SessionExpiredException(lockInfo.getUser());
throw new SessionExpiredException("Different Users.", lockInfo.getUser());
}
}