Split rest authentication into two. For web apps integration url is /c/restful/
This commit is contained in:
@@ -174,31 +174,30 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException {
|
||||
throw new SessionExpiredException(user);
|
||||
|
||||
// // The lock was lost, reclaim as the ownership of it.
|
||||
// final LockManager lockManager = mindmapService.getLockManager();
|
||||
// final boolean lockLost = lockManager.isLocked(mindmap);
|
||||
// if (!lockLost) {
|
||||
// lockManager.lock(mindmap, user, session);
|
||||
// }
|
||||
//
|
||||
// final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
|
||||
// if (lockInfo.getCollaborator().equals(user)) {
|
||||
// final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp;
|
||||
// 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();
|
||||
// if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.equals(user))) {
|
||||
// throw new SessionExpiredException(lastEditor);
|
||||
// }
|
||||
// } else if (outdated) {
|
||||
// throw new MultipleSessionsOpenException("The map has been updated and not by you. Session lost.");
|
||||
// }
|
||||
// } else {
|
||||
// throw new SessionExpiredException(lockInfo.getCollaborator());
|
||||
//
|
||||
// }
|
||||
// The lock was lost, reclaim as the ownership of it.
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final boolean lockLost = lockManager.isLocked(mindmap);
|
||||
if (!lockLost) {
|
||||
lockManager.lock(mindmap, user, session);
|
||||
}
|
||||
|
||||
final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
|
||||
if (lockInfo.getUser().equals(user)) {
|
||||
final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp;
|
||||
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();
|
||||
if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.equals(user))) {
|
||||
throw new SessionExpiredException(lastEditor);
|
||||
}
|
||||
} else if (outdated) {
|
||||
throw new MultipleSessionsOpenException("The map has been updated and not by you. Session lost.");
|
||||
}
|
||||
} else {
|
||||
throw new SessionExpiredException(lockInfo.getUser());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,10 +20,8 @@ package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.LockInfo;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,9 +29,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
@XmlRootElement(name = "lock")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@@ -73,7 +68,7 @@ public class RestLockInfo {
|
||||
}
|
||||
|
||||
public boolean isLockedByMe() {
|
||||
return isLocked() && lockInfo != null && lockInfo.getCollaborator().equals(user);
|
||||
return isLocked() && lockInfo != null && lockInfo.getUser().equals(user);
|
||||
}
|
||||
|
||||
public void setLockedByMe(boolean lockedForMe) {
|
||||
|
||||
Reference in New Issue
Block a user