diff --git a/scm-core/src/main/java/sonia/scm/group/Group.java b/scm-core/src/main/java/sonia/scm/group/Group.java index 4b288516a6..66cdd6b355 100644 --- a/scm-core/src/main/java/sonia/scm/group/Group.java +++ b/scm-core/src/main/java/sonia/scm/group/Group.java @@ -263,22 +263,22 @@ public class Group implements ModelObject, Iterable { int hash = 7; - hash = 29 * hash + ((this.creationDate != null) + hash = 73 * hash + ((this.creationDate != null) ? this.creationDate.hashCode() : 0); - hash = 29 * hash + ((this.description != null) + hash = 73 * hash + ((this.description != null) ? this.description.hashCode() : 0); - hash = 29 * hash + ((this.lastModified != null) + hash = 73 * hash + ((this.lastModified != null) ? this.lastModified.hashCode() : 0); - hash = 29 * hash + ((this.members != null) + hash = 73 * hash + ((this.members != null) ? this.members.hashCode() : 0); - hash = 29 * hash + ((this.name != null) + hash = 73 * hash + ((this.name != null) ? this.name.hashCode() : 0); - hash = 29 * hash + ((this.type != null) + hash = 73 * hash + ((this.type != null) ? this.type.hashCode() : 0); @@ -371,6 +371,7 @@ public class Group implements ModelObject, Iterable * * @return */ + @Override public Long getLastModified() { return lastModified; diff --git a/scm-core/src/main/java/sonia/scm/repository/Permission.java b/scm-core/src/main/java/sonia/scm/repository/Permission.java index a446717cb9..73e6baabc3 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Permission.java +++ b/scm-core/src/main/java/sonia/scm/repository/Permission.java @@ -100,6 +100,75 @@ public class Permission implements Serializable this.groupPermission = groupPermission; } + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final Permission other = (Permission) obj; + + if (this.groupPermission != other.groupPermission) + { + return false; + } + + if ((this.name == null) + ? (other.name != null) + : !this.name.equals(other.name)) + { + return false; + } + + if (this.type != other.type) + { + return false; + } + + return true; + } + + /** + * Method description + * + * + * @return + */ + @Override + public int hashCode() + { + int hash = 7; + + hash = 97 * hash + (this.groupPermission + ? 1 + : 0); + hash = 97 * hash + ((this.name != null) + ? this.name.hashCode() + : 0); + hash = 97 * hash + ((this.type != null) + ? this.type.hashCode() + : 0); + + return hash; + } + //~--- get methods ---------------------------------------------------------- /** diff --git a/scm-core/src/main/java/sonia/scm/repository/Repository.java b/scm-core/src/main/java/sonia/scm/repository/Repository.java index 58b37da8cd..165027a635 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Repository.java +++ b/scm-core/src/main/java/sonia/scm/repository/Repository.java @@ -157,6 +157,145 @@ public class Repository implements ModelObject repository.setUrl(url); } + /** + * Method description + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final Repository other = (Repository) obj; + + if ((this.contact == null) + ? (other.contact != null) + : !this.contact.equals(other.contact)) + { + return false; + } + + if ((this.creationDate != other.creationDate) + && ((this.creationDate == null) + ||!this.creationDate.equals(other.creationDate))) + { + return false; + } + + if ((this.description == null) + ? (other.description != null) + : !this.description.equals(other.description)) + { + return false; + } + + if ((this.id == null) + ? (other.id != null) + : !this.id.equals(other.id)) + { + return false; + } + + if ((this.lastModified != other.lastModified) + && ((this.lastModified == null) + ||!this.lastModified.equals(other.lastModified))) + { + return false; + } + + if ((this.name == null) + ? (other.name != null) + : !this.name.equals(other.name)) + { + return false; + } + + if ((this.permissions != other.permissions) + && ((this.permissions == null) + ||!this.permissions.equals(other.permissions))) + { + return false; + } + + if (this.publicReadable != other.publicReadable) + { + return false; + } + + if ((this.type == null) + ? (other.type != null) + : !this.type.equals(other.type)) + { + return false; + } + + if ((this.url == null) + ? (other.url != null) + : !this.url.equals(other.url)) + { + return false; + } + + return true; + } + + /** + * Method description + * + * + * @return + */ + @Override + public int hashCode() + { + int hash = 7; + + hash = 61 * hash + ((this.contact != null) + ? this.contact.hashCode() + : 0); + hash = 61 * hash + ((this.creationDate != null) + ? this.creationDate.hashCode() + : 0); + hash = 61 * hash + ((this.description != null) + ? this.description.hashCode() + : 0); + hash = 61 * hash + ((this.id != null) + ? this.id.hashCode() + : 0); + hash = 61 * hash + ((this.lastModified != null) + ? this.lastModified.hashCode() + : 0); + hash = 61 * hash + ((this.name != null) + ? this.name.hashCode() + : 0); + hash = 61 * hash + ((this.permissions != null) + ? this.permissions.hashCode() + : 0); + hash = 61 * hash + (this.publicReadable + ? 1 + : 0); + hash = 61 * hash + ((this.type != null) + ? this.type.hashCode() + : 0); + hash = 61 * hash + ((this.url != null) + ? this.url.hashCode() + : 0); + + return hash; + } + /** * Method description * diff --git a/scm-core/src/main/java/sonia/scm/user/User.java b/scm-core/src/main/java/sonia/scm/user/User.java index e48a7ba3c0..bdd070f71c 100644 --- a/scm-core/src/main/java/sonia/scm/user/User.java +++ b/scm-core/src/main/java/sonia/scm/user/User.java @@ -210,6 +210,18 @@ public class User implements Principal, ModelObject final User other = (User) obj; + if (this.admin != other.admin) + { + return false; + } + + if ((this.creationDate != other.creationDate) + && ((this.creationDate == null) + ||!this.creationDate.equals(other.creationDate))) + { + return false; + } + if ((this.displayName == null) ? (other.displayName != null) : !this.displayName.equals(other.displayName)) @@ -217,6 +229,13 @@ public class User implements Principal, ModelObject return false; } + if ((this.lastModified != other.lastModified) + && ((this.lastModified == null) + ||!this.lastModified.equals(other.lastModified))) + { + return false; + } + if ((this.mail == null) ? (other.mail != null) : !this.mail.equals(other.mail)) @@ -257,21 +276,30 @@ public class User implements Principal, ModelObject @Override public int hashCode() { - int hash = 7; + int hash = 3; - hash = 79 * hash + ((this.displayName != null) + hash = 37 * hash + (this.admin + ? 1 + : 0); + hash = 37 * hash + ((this.creationDate != null) + ? this.creationDate.hashCode() + : 0); + hash = 37 * hash + ((this.displayName != null) ? this.displayName.hashCode() : 0); - hash = 79 * hash + ((this.mail != null) + hash = 37 * hash + ((this.lastModified != null) + ? this.lastModified.hashCode() + : 0); + hash = 37 * hash + ((this.mail != null) ? this.mail.hashCode() : 0); - hash = 79 * hash + ((this.name != null) + hash = 37 * hash + ((this.name != null) ? this.name.hashCode() : 0); - hash = 79 * hash + ((this.password != null) + hash = 37 * hash + ((this.password != null) ? this.password.hashCode() : 0); - hash = 79 * hash + ((this.type != null) + hash = 37 * hash + ((this.type != null) ? this.type.hashCode() : 0); diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java index 290c08b077..d10abc8145 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java @@ -245,7 +245,7 @@ public abstract class AbstractManagerResource * * @return */ - private Response createCacheResponse(Request request, T item) + private Response createCacheResponse(Request request, + LastModifiedAware timeItem, I item) { Response.ResponseBuilder builder = null; - Date lastModified = getLastModified(item); + Date lastModified = getLastModified(timeItem); EntityTag e = new EntityTag(Integer.toString(item.hashCode())); if (lastModified != null) @@ -430,35 +433,6 @@ public abstract class AbstractManagerResource items) - { - Response.ResponseBuilder builder = null; - Date lastModified = getLastModified(manager); - - if (lastModified != null) - { - builder = request.evaluatePreconditions(lastModified); - } - - if (builder == null) - { - builder = Response.ok(items).lastModified(lastModified); - } - - addCacheControl(builder); - - return builder.build(); - } - //~--- get methods ---------------------------------------------------------- /** @@ -485,7 +459,7 @@ public abstract class AbstractManagerResource