summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/wicket/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/gitblit/wicket/models')
-rw-r--r--src/com/gitblit/wicket/models/PathModel.java33
-rw-r--r--src/com/gitblit/wicket/models/RefModel.java28
-rw-r--r--src/com/gitblit/wicket/models/RepositoryModel.java4
-rw-r--r--src/com/gitblit/wicket/models/TicketModel.java32
-rw-r--r--src/com/gitblit/wicket/models/UserModel.java33
5 files changed, 84 insertions, 46 deletions
diff --git a/src/com/gitblit/wicket/models/PathModel.java b/src/com/gitblit/wicket/models/PathModel.java
index b9a47bf1..2edc96c9 100644
--- a/src/com/gitblit/wicket/models/PathModel.java
+++ b/src/com/gitblit/wicket/models/PathModel.java
@@ -49,12 +49,26 @@ public class PathModel implements Serializable, Comparable<PathModel> {
if (basePath.lastIndexOf('/') > -1) {
parentPath = basePath.substring(0, basePath.lastIndexOf('/'));
}
- PathModel model = new PathModel("..", parentPath, 0, 0040000, commitId);
+ PathModel model = new PathModel("..", parentPath, 0, 40000, commitId);
model.isParentPath = true;
return model;
}
@Override
+ public int hashCode() {
+ return commitId.hashCode() + path.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PathModel) {
+ PathModel other = (PathModel) o;
+ return this.path.equals(other.path);
+ }
+ return super.equals(o);
+ }
+
+ @Override
public int compareTo(PathModel o) {
boolean isTree = isTree();
boolean otherTree = o.isTree();
@@ -69,14 +83,25 @@ public class PathModel implements Serializable, Comparable<PathModel> {
}
public static class PathChangeModel extends PathModel {
-
+
private static final long serialVersionUID = 1L;
-
+
public final ChangeType changeType;
- public PathChangeModel(String name, String path, long size, int mode, String commitId, ChangeType type) {
+ public PathChangeModel(String name, String path, long size, int mode, String commitId,
+ ChangeType type) {
super(name, path, size, mode, commitId);
this.changeType = type;
}
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
}
}
diff --git a/src/com/gitblit/wicket/models/RefModel.java b/src/com/gitblit/wicket/models/RefModel.java
index ab445931..e0831f5a 100644
--- a/src/com/gitblit/wicket/models/RefModel.java
+++ b/src/com/gitblit/wicket/models/RefModel.java
@@ -27,9 +27,9 @@ import com.gitblit.utils.JGitUtils;
public class RefModel implements Serializable, Comparable<RefModel> {
private static final long serialVersionUID = 1L;
- final String displayName;
- transient Ref ref;
- final RevCommit commit;
+ public final String displayName;
+ public final RevCommit commit;
+ public transient Ref ref;
public RefModel(String displayName, Ref ref, RevCommit commit) {
this.displayName = displayName;
@@ -41,18 +41,10 @@ public class RefModel implements Serializable, Comparable<RefModel> {
return JGitUtils.getCommitDate(commit);
}
- public String getDisplayName() {
- return displayName;
- }
-
public String getName() {
return ref.getName();
}
- public RevCommit getCommit() {
- return commit;
- }
-
public ObjectId getCommitId() {
return commit.getId();
}
@@ -71,6 +63,20 @@ public class RefModel implements Serializable, Comparable<RefModel> {
}
@Override
+ public int hashCode() {
+ return getCommitId().hashCode() + getName().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof RefModel) {
+ RefModel other = (RefModel) o;
+ return getName().equals(other.getName());
+ }
+ return super.equals(o);
+ }
+
+ @Override
public int compareTo(RefModel o) {
return getDate().compareTo(o.getDate());
}
diff --git a/src/com/gitblit/wicket/models/RepositoryModel.java b/src/com/gitblit/wicket/models/RepositoryModel.java
index b12f4a9d..575e64a5 100644
--- a/src/com/gitblit/wicket/models/RepositoryModel.java
+++ b/src/com/gitblit/wicket/models/RepositoryModel.java
@@ -23,6 +23,8 @@ import com.gitblit.Constants.AccessRestrictionType;
public class RepositoryModel implements Serializable {
private static final long serialVersionUID = 1L;
+
+ // field names are reflectively mapped in EditRepository page
public String name;
public String description;
public String owner;
@@ -49,7 +51,7 @@ public class RepositoryModel implements Serializable {
this.lastChange = lastchange;
this.accessRestriction = AccessRestrictionType.NONE;
}
-
+
@Override
public String toString() {
return name;
diff --git a/src/com/gitblit/wicket/models/TicketModel.java b/src/com/gitblit/wicket/models/TicketModel.java
index b5cd6894..b661c19a 100644
--- a/src/com/gitblit/wicket/models/TicketModel.java
+++ b/src/com/gitblit/wicket/models/TicketModel.java
@@ -51,7 +51,7 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
String[] chunks = name.split("_");
if (chunks.length == 3) {
- date = new Date(Long.parseLong(chunks[0]) * 1000l);
+ date = new Date(Long.parseLong(chunks[0]) * 1000L);
title = chunks[1].replace('-', ' ');
}
}
@@ -71,18 +71,46 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
public Comment(String filename, String content) throws ParseException {
String[] chunks = filename.split("_", -1);
- this.date = new Date(Long.parseLong(chunks[1]) * 1000l);
+ this.date = new Date(Long.parseLong(chunks[1]) * 1000L);
this.author = chunks[2];
this.text = content;
}
@Override
+ public int hashCode() {
+ return text.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Comment) {
+ Comment other = (Comment) o;
+ return text.equals(other.text);
+ }
+ return super.equals(o);
+ }
+
+ @Override
public int compareTo(Comment o) {
return date.compareTo(o.date);
}
}
@Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TicketModel) {
+ TicketModel other = (TicketModel) o;
+ return id.equals(other.id);
+ }
+ return super.equals(o);
+ }
+
+ @Override
public int compareTo(TicketModel o) {
return date.compareTo(o.date);
}
diff --git a/src/com/gitblit/wicket/models/UserModel.java b/src/com/gitblit/wicket/models/UserModel.java
index e60b4dac..1181ee15 100644
--- a/src/com/gitblit/wicket/models/UserModel.java
+++ b/src/com/gitblit/wicket/models/UserModel.java
@@ -23,35 +23,16 @@ public class UserModel implements Serializable {
private static final long serialVersionUID = 1L;
- private String username;
- private String password;
- private boolean canAdmin = false;
- private List<String> repositories = new ArrayList<String>();
+ // field names are reflectively mapped in EditUser page
+ public String username;
+ public String password;
+ public boolean canAdmin;
+ public final List<String> repositories = new ArrayList<String>();
public UserModel(String username) {
this.username = username;
}
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public void canAdmin(boolean value) {
- canAdmin = value;
- }
-
- public boolean canAdmin() {
- return canAdmin;
- }
-
public boolean canAccessRepository(String repositoryName) {
return canAdmin || repositories.contains(repositoryName);
}
@@ -65,10 +46,6 @@ public class UserModel implements Serializable {
repositories.add(name.toLowerCase());
}
- public List<String> getRepositories() {
- return repositories;
- }
-
@Override
public String toString() {
return username;