mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
Keep fixing user issues.
This commit is contained in:
parent
16e59a0879
commit
596aeeebc4
@ -97,7 +97,7 @@ public class Collaborator implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean equalCollab(@Nullable Collaborator that) {
|
public boolean identityEquality(@Nullable Collaborator that) {
|
||||||
if (this == that) return true;
|
if (this == that) return true;
|
||||||
if (that == null) return false;
|
if (that == null) return false;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class Mindmap {
|
|||||||
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
|
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
|
||||||
Collaboration result = null;
|
Collaboration result = null;
|
||||||
for (Collaboration collaboration : collaborations) {
|
for (Collaboration collaboration : collaborations) {
|
||||||
if (collaboration.getCollaborator().equalCollab(collaborator)) {
|
if (collaboration.getCollaborator().identityEquality(collaborator)) {
|
||||||
result = collaboration;
|
result = collaboration;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -183,12 +183,13 @@ public class MindmapController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
|
final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
|
||||||
if (lockInfo.getUser().equalCollab(user)) {
|
if (lockInfo.getUser().identityEquality(user)) {
|
||||||
final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp;
|
final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp;
|
||||||
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();
|
||||||
if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.equals(user))) {
|
// 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);
|
throw new SessionExpiredException(lastEditor);
|
||||||
}
|
}
|
||||||
} else if (outdated) {
|
} else if (outdated) {
|
||||||
|
@ -124,7 +124,7 @@ public class RestUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RestUser restUser = (RestUser) o;
|
RestUser restUser = (RestUser) o;
|
||||||
return this.getDelegated().equalCollab(restUser.getDelegated());
|
return this.getDelegated().identityEquality(restUser.getDelegated());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ public abstract class BaseSecurityAdvice {
|
|||||||
isAllowed = isAllowed(user, ((Integer) argument));
|
isAllowed = isAllowed(user, ((Integer) argument));
|
||||||
} else if (argument instanceof Collaborator) {
|
} else if (argument instanceof Collaborator) {
|
||||||
// Read operation find on the user are allowed ...
|
// Read operation find on the user are allowed ...
|
||||||
isAllowed = user.equalCollab((Collaborator) argument);
|
isAllowed = user.identityEquality((Collaborator) argument);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Argument " + argument);
|
throw new IllegalArgumentException("Argument " + argument);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ class LockManagerImpl implements LockManager {
|
|||||||
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator) {
|
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
final LockInfo lockInfo = this.getLockInfo(mindmap);
|
final LockInfo lockInfo = this.getLockInfo(mindmap);
|
||||||
if (lockInfo != null && lockInfo.getUser().equalCollab(collaborator)) {
|
if (lockInfo != null && lockInfo.getUser().identityEquality(collaborator)) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -115,7 +115,7 @@ public class MindmapServiceImpl
|
|||||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||||
|
|
||||||
final User creator = mindMap.getCreator();
|
final User creator = mindMap.getCreator();
|
||||||
if (creator.equalCollab(collaboration.getCollaborator())) {
|
if (creator.identityEquality(collaboration.getCollaborator())) {
|
||||||
throw new CollaborationException("User is the creator and must have ownership permissions.Creator Email:" + mindMap.getCreator().getEmail() + ",Collaborator:" + collaboration.getCollaborator().getEmail());
|
throw new CollaborationException("User is the creator and must have ownership permissions.Creator Email:" + mindMap.getCreator().getEmail() + ",Collaborator:" + collaboration.getCollaborator().getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class MindmapServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
|
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
|
||||||
if (mindmap.getCreator().equalCollab(user)) {
|
if (mindmap.getCreator().identityEquality(user)) {
|
||||||
mindmapManager.removeMindmap(mindmap);
|
mindmapManager.removeMindmap(mindmap);
|
||||||
} else {
|
} else {
|
||||||
final Collaboration collaboration = mindmap.findCollaboration(user);
|
final Collaboration collaboration = mindmap.findCollaboration(user);
|
||||||
@ -265,7 +265,7 @@ public class MindmapServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException {
|
public void updateCollaboration(@NotNull Collaborator collaborator, @NotNull Collaboration collaboration) throws WiseMappingException {
|
||||||
if (collaborator.equalCollab(collaboration.getCollaborator())) {
|
if (collaborator.identityEquality(collaboration.getCollaborator())) {
|
||||||
throw new WiseMappingException("No enough permissions for this operation.");
|
throw new WiseMappingException("No enough permissions for this operation.");
|
||||||
}
|
}
|
||||||
mindmapManager.updateCollaboration(collaboration);
|
mindmapManager.updateCollaboration(collaboration);
|
||||||
|
Loading…
Reference in New Issue
Block a user