mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Avoid additional checks ...
This commit is contained in:
parent
7ba21f85bf
commit
58ed80d763
@ -26,8 +26,8 @@ public class SessionExpiredException
|
|||||||
public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||||
private User lastUpdater;
|
private User lastUpdater;
|
||||||
|
|
||||||
public SessionExpiredException(@NotNull User lastUpdater) {
|
public SessionExpiredException(@NotNull String debugInfo, @NotNull User lastUpdater) {
|
||||||
super("Map has been updated by " + (lastUpdater != null ? lastUpdater.getEmail() : ""), Severity.FATAL);
|
super(debugInfo, Severity.FATAL);
|
||||||
this.lastUpdater = lastUpdater;
|
this.lastUpdater = lastUpdater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,15 +188,15 @@ public class MindmapController extends BaseController {
|
|||||||
if (lockInfo.getSession() == session) {
|
if (lockInfo.getSession() == session) {
|
||||||
// Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check.
|
// Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check.
|
||||||
final User lastEditor = mindmap.getLastEditor();
|
final User lastEditor = mindmap.getLastEditor();
|
||||||
// lockInfo.getPreviousTimestamp() == timestamp : In case the timestap is not returned. Give a second chance.
|
boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor);
|
||||||
if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.identityEquality(user))) {
|
if (outdated && !editedBySameUser) {
|
||||||
throw new SessionExpiredException(lastEditor);
|
throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + mindmap.getLastModificationTime().getTimeInMillis(), lastEditor);
|
||||||
}
|
}
|
||||||
} else if (outdated) {
|
} else if (outdated) {
|
||||||
throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + lockInfo.getTimestamp());
|
throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + lockInfo.getTimestamp());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new SessionExpiredException(lockInfo.getUser());
|
throw new SessionExpiredException("Different Users.", lockInfo.getUser());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user