From 2861a7b5f90d126aa7cb039ac68bf868e821909c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 14 Nov 2012 20:00:46 -0300 Subject: [PATCH] Fix user comparator. --- .../com/wisemapping/model/Collaborator.java | 20 ++++++++++++++++ .../main/java/com/wisemapping/model/User.java | 24 ------------------- .../wisemapping/service/LockManagerImpl.java | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java index b7c53d59..bca422de 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java @@ -76,4 +76,24 @@ public class Collaborator implements Serializable { public void setCreationDate(Calendar creationDate) { this.creationDate = creationDate; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Collaborator that = (Collaborator) o; + + if (id != that.id) return false; + if (email != null ? !email.equals(that.email) : that.email != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (int) (id ^ (id >>> 32)); + result = 31 * result + (email != null ? email.hashCode() : 0); + return result; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index d15d86c5..29edfeb3 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -106,30 +106,6 @@ public class User this.allowSendEmail = allowSendEmail; } - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || !User.class.getClass().isInstance(o)) - return false; - - final User user = (User) o; - - final String email = getEmail(); - if (email != null ? !email.equals(user.getEmail()) : user.getEmail() != null) return false; - if (firstname != null ? !firstname.equals(user.firstname) : user.firstname != null) return false; - return !(lastname != null ? !lastname.equals(user.lastname) : user.lastname != null); - } - - - public int hashCode() { - int result; - result = (firstname != null ? firstname.hashCode() : 0); - result = 29 * result + (lastname != null ? lastname.hashCode() : 0); - result = 29 * result + (password != null ? password.hashCode() : 0); - result = 29 * result + (getEmail() != null ? getEmail().hashCode() : 0); - return result; - } - @Nullable public String getLocale() { return locale; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index c705abbc..a06c7d2f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -130,7 +130,7 @@ class LockManagerImpl implements LockManager { // Update timeout only... logger.debug("Update timestamp:" + mindmap.getId()); updateExpirationTimeout(mindmap, user); - result.setSession(session); + // result.setSession(session); } else { logger.debug("Lock map id:" + mindmap.getId()); result = new LockInfo(user, mindmap, session);