Keep fixing user issues.

This commit is contained in:
Paulo Gustavo Veiga 2012-11-14 20:33:42 -03:00
parent 16e59a0879
commit 596aeeebc4
7 changed files with 11 additions and 10 deletions

View File

@ -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 (that == null) return false;

View File

@ -112,7 +112,7 @@ public class Mindmap {
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
Collaboration result = null;
for (Collaboration collaboration : collaborations) {
if (collaboration.getCollaborator().equalCollab(collaborator)) {
if (collaboration.getCollaborator().identityEquality(collaborator)) {
result = collaboration;
break;
}

View File

@ -183,12 +183,13 @@ public class MindmapController extends BaseController {
}
final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
if (lockInfo.getUser().equalCollab(user)) {
if (lockInfo.getUser().identityEquality(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))) {
// 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);
}
} else if (outdated) {

View File

@ -124,7 +124,7 @@ public class RestUser {
}
RestUser restUser = (RestUser) o;
return this.getDelegated().equalCollab(restUser.getDelegated());
return this.getDelegated().identityEquality(restUser.getDelegated());
}
@Override

View File

@ -41,7 +41,7 @@ public abstract class BaseSecurityAdvice {
isAllowed = isAllowed(user, ((Integer) argument));
} else if (argument instanceof Collaborator) {
// Read operation find on the user are allowed ...
isAllowed = user.equalCollab((Collaborator) argument);
isAllowed = user.identityEquality((Collaborator) argument);
} else {
throw new IllegalArgumentException("Argument " + argument);
}

View File

@ -101,7 +101,7 @@ class LockManagerImpl implements LockManager {
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator) {
boolean result = false;
final LockInfo lockInfo = this.getLockInfo(mindmap);
if (lockInfo != null && lockInfo.getUser().equalCollab(collaborator)) {
if (lockInfo != null && lockInfo.getUser().identityEquality(collaborator)) {
result = true;
}
return result;

View File

@ -115,7 +115,7 @@ public class MindmapServiceImpl
final Set<Collaboration> collaborations = mindMap.getCollaborations();
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());
}
@ -126,7 +126,7 @@ public class MindmapServiceImpl
@Override
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
if (mindmap.getCreator().equalCollab(user)) {
if (mindmap.getCreator().identityEquality(user)) {
mindmapManager.removeMindmap(mindmap);
} else {
final Collaboration collaboration = mindmap.findCollaboration(user);
@ -265,7 +265,7 @@ public class MindmapServiceImpl
@Override
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.");
}
mindmapManager.updateCollaboration(collaboration);