The Unified and Autonomous Development Platform
midwork
robin shine5c32d64708fd
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.javaindex e46a385a16..a35b8692c1 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java@@ -30,8 +30,7 @@ import com.pmease.gitplex.core.manager.AccountManager;import com.pmease.gitplex.core.manager.TeamAuthorizationManager;import com.pmease.gitplex.core.manager.AuxiliaryManager;import com.pmease.gitplex.core.manager.BranchWatchManager;-import com.pmease.gitplex.core.manager.CommentManager;-import com.pmease.gitplex.core.manager.CommentReplyManager;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;import com.pmease.gitplex.core.manager.ConfigManager;import com.pmease.gitplex.core.manager.DataManager;import com.pmease.gitplex.core.manager.DepotManager;@@ -54,8 +53,7 @@ import com.pmease.gitplex.core.manager.impl.DefaultAccountManager;import com.pmease.gitplex.core.manager.impl.DefaultTeamAuthorizationManager;import com.pmease.gitplex.core.manager.impl.DefaultAuxiliaryManager;import com.pmease.gitplex.core.manager.impl.DefaultBranchWatchManager;-import com.pmease.gitplex.core.manager.impl.DefaultCommentManager;-import com.pmease.gitplex.core.manager.impl.DefaultCommentReplyManager;+import com.pmease.gitplex.core.manager.impl.DefaultPullRequestCommentManager;import com.pmease.gitplex.core.manager.impl.DefaultConfigManager;import com.pmease.gitplex.core.manager.impl.DefaultDataManager;import com.pmease.gitplex.core.manager.impl.DefaultDepotManager;@@ -153,8 +151,7 @@ public class CoreModule extends AbstractPluginModule {bind(StorageManager.class).to(DefaultStorageManager.class);bind(ConfigManager.class).to(DefaultConfigManager.class);bind(DataManager.class).to(DefaultDataManager.class);- bind(CommentManager.class).to(DefaultCommentManager.class);- bind(CommentReplyManager.class).to(DefaultCommentReplyManager.class);+ bind(PullRequestCommentManager.class).to(DefaultPullRequestCommentManager.class);bind(PullRequestManager.class).to(DefaultPullRequestManager.class);bind(PullRequestUpdateManager.class).to(DefaultPullRequestUpdateManager.class);bind(DepotManager.class).to(DefaultDepotManager.class);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.javaindex 67e97b3f0e..67de4b0ac3 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java@@ -139,12 +139,8 @@ public class Account extends AbstractUser implements ProtectedObject {@OneToMany(mappedBy="user")@OnDelete(action=OnDeleteAction.CASCADE)- private Collection<Comment> requestComments = new ArrayList<>();+ private Collection<CodeComment> requestComments = new ArrayList<>();- @OneToMany(mappedBy="user")- @OnDelete(action=OnDeleteAction.CASCADE)- private Collection<CommentReply> requestCommentReplies = new ArrayList<>();-@OneToMany(mappedBy="user")@OnDelete(action=OnDeleteAction.CASCADE)private Collection<BranchWatch> branchWatches = new ArrayList<>();@@ -334,23 +330,14 @@ public class Account extends AbstractUser implements ProtectedObject {this.closedRequests = closedRequests;}- public Collection<Comment> getRequestComments() {+ public Collection<CodeComment> getRequestComments() {return requestComments;}- public void setRequestComments(Collection<Comment> requestComments) {+ public void setRequestComments(Collection<CodeComment> requestComments) {this.requestComments = requestComments;}- public Collection<CommentReply> getRequestCommentReplies() {- return requestCommentReplies;- }-- public void setRequestCommentReplies(- Collection<CommentReply> requestCommentReplies) {- this.requestCommentReplies = requestCommentReplies;- }-public Collection<BranchWatch> getBranchWatches() {return branchWatches;}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.javanew file mode 100644index 0000000000..5f71264b1a--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java@@ -0,0 +1,148 @@+package com.pmease.gitplex.core.entity;++import java.util.Date;++import javax.annotation.Nullable;+import javax.persistence.Column;+import javax.persistence.Embedded;+import javax.persistence.Entity;+import javax.persistence.FetchType;+import javax.persistence.Lob;+import javax.persistence.ManyToOne;+import javax.persistence.Version;++import org.hibernate.annotations.DynamicUpdate;+import org.hibernate.annotations.OptimisticLock;++import com.google.common.base.Preconditions;+import com.pmease.commons.git.BlobIdent;+import com.pmease.commons.hibernate.AbstractEntity;+import com.pmease.commons.hibernate.dao.Dao;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.entity.component.CommentPosition;++/*+ * @DynamicUpdate annotation here along with various @OptimisticLock annotations+ * on certain fields tell Hibernate not to perform version check on those fields+ * which can be updated from background thread.+ */+@Entity+@DynamicUpdate+public class CodeComment extends AbstractEntity {++ private static final long serialVersionUID = 1L;++ public static final int DIFF_CONTEXT_SIZE = 3;++ @Version+ private long version;++ @ManyToOne(fetch=FetchType.LAZY)+ private Depot depot;++ @ManyToOne(fetch=FetchType.LAZY)+ private Account user;++ @Lob+ @Column(nullable=false, length=65535)+ private String content;++ @Column(nullable=false)+ private Date date = new Date();++ @OptimisticLock(excluded=true)+ @Embedded+ private CommentPosition position;++ /**+ * @return the depot+ */+ public Depot getDepot() {+ return depot;+ }++ /**+ * @param depot the depot to set+ */+ public void setDepot(Depot depot) {+ this.depot = depot;+ }++ @Nullable+ public Account getUser() {+ return user;+ }++ public void setUser(@Nullable Account user) {+ this.user = user;+ }++ public long getVersion() {+ return version;+ }++ public String getContent() {+ return content;+ }++ public void setContent(String content) {+ this.content = content;+ }++ public Date getDate() {+ return date;+ }++ public void delete() {+ GitPlex.getInstance(Dao.class).remove(this);+ }++ public CommentPosition getPosition() {+ return position;+ }++ public void setPosition(CommentPosition position) {+ this.position = position;+ }++ public BlobIdent getBlobIdent() {+ return Preconditions.checkNotNull(position).getBlobIdent();+ }++ public void setBlobIdent(BlobIdent blobIdent) {+ if (position == null)+ position = new CommentPosition();+ position.setBlobIdent(blobIdent);+ }++ public BlobIdent getCompareWith() {+ return Preconditions.checkNotNull(position).getCompareWith();+ }++ public void setCompareWith(BlobIdent compareWith) {+ if (position == null)+ position = new CommentPosition();+ position.setCompareWith(compareWith);+ }++ public int getBeginLine() {+ return Preconditions.checkNotNull(position).getBeginLine();+ }++ public void setBeginLine(int beginLine) {+ if (position == null)+ position = new CommentPosition();+ position.setBeginLine(beginLine);+ }++ public int getEndLine() {+ return Preconditions.checkNotNull(position).getEndLine();+ }++ public void setEndLine(int endLine) {+ if (position == null)+ position = new CommentPosition();+ position.setEndLine(endLine);+ }++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Comment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Comment.javadeleted file mode 100644index d37a57aea7..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Comment.java+++ /dev/null@@ -1,210 +0,0 @@-package com.pmease.gitplex.core.entity;--import java.util.ArrayList;-import java.util.Collection;-import java.util.Date;-import java.util.List;--import javax.annotation.Nullable;-import javax.persistence.Column;-import javax.persistence.Embedded;-import javax.persistence.Entity;-import javax.persistence.FetchType;-import javax.persistence.JoinColumn;-import javax.persistence.Lob;-import javax.persistence.ManyToOne;-import javax.persistence.OneToMany;-import javax.persistence.Version;--import org.hibernate.annotations.DynamicUpdate;-import org.hibernate.annotations.OnDelete;-import org.hibernate.annotations.OnDeleteAction;-import org.hibernate.annotations.OptimisticLock;--import com.google.common.base.Preconditions;-import com.pmease.commons.git.BlobIdent;-import com.pmease.commons.hibernate.AbstractEntity;-import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.util.Pair;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.component.InlineInfo;-import com.pmease.gitplex.core.manager.CommentReplyManager;-import com.pmease.gitplex.core.manager.PullRequestManager;-import com.pmease.gitplex.core.manager.AccountManager;--/*- * @DynamicUpdate annotation here along with various @OptimisticLock annotations- * on certain fields tell Hibernate not to perform version check on those fields- * which can be updated from background thread.- */-@Entity-@DynamicUpdate-public class Comment extends AbstractEntity {-- private static final long serialVersionUID = 1L;-- public static final int DIFF_CONTEXT_SIZE = 3;-- @Version- private long version;-- @ManyToOne(fetch=FetchType.LAZY)- @JoinColumn(nullable=false)- private PullRequest request;-- @ManyToOne(fetch=FetchType.LAZY)- private Account user;-- @Lob- @Column(nullable=false, length=65535)- private String content;-- @Column(nullable=false)- private Date date = new Date();-- @OneToMany(mappedBy="comment")- @OnDelete(action=OnDeleteAction.CASCADE)- private Collection<CommentReply> replies = new ArrayList<>();-- @OptimisticLock(excluded=true)- @Embedded- private InlineInfo inlineInfo;-- private transient Pair<String, String> oldAndNew;-- public PullRequest getRequest() {- return request;- }-- public void setRequest(PullRequest request) {- this.request = request;- }-- @Nullable- public Account getUser() {- return user;- }-- public void setUser(@Nullable Account user) {- this.user = user;- }-- public long getVersion() {- return version;- }-- public String getContent() {- return content;- }-- public void setContent(String content) {- this.content = content;- }-- public Date getDate() {- return date;- }-- public Depot getDepot() {- return request.getTargetDepot();- }-- public void delete() {- GitPlex.getInstance(Dao.class).remove(this);- }-- public Collection<CommentReply> getReplies() {- return request.getCommentReplies(this);- }-- public CommentReply addReply(String content) {- Account user = GitPlex.getInstance(AccountManager.class).getCurrent();- Preconditions.checkNotNull(user);- CommentReply reply = new CommentReply();- reply.setUser(user);- reply.setContent(content);- reply.setComment(this);- GitPlex.getInstance(CommentReplyManager.class).save(reply);- return reply;- }-- private Pair<String, String> getOldAndNew() {- String rev = getBlobIdent().revision;- if (oldAndNew == null) {- List<String> commitHashes = getRequest().getCommentables();- String compareRev = getCompareWith().revision;- int index = commitHashes.indexOf(rev);- int compareIndex = commitHashes.indexOf(compareRev);- Preconditions.checkState(index != -1 && compareIndex != -1);- if (index <= compareIndex)- oldAndNew = new Pair<>(rev, compareRev);- else- oldAndNew = new Pair<>(compareRev, rev);- }- return oldAndNew;- }-- public InlineInfo getInlineInfo() {- return inlineInfo;- }-- public void setInlineInfo(InlineInfo inlineInfo) {- this.inlineInfo = inlineInfo;- oldAndNew = null;- }-- public String getOldCommitHash() {- return getOldAndNew().getFirst();- }-- public String getNewCommitHash() {- return getOldAndNew().getSecond();- }-- public BlobIdent getBlobIdent() {- return Preconditions.checkNotNull(inlineInfo).getBlobIdent();- }-- public void setBlobIdent(BlobIdent blobIdent) {- if (inlineInfo == null)- inlineInfo = new InlineInfo();- inlineInfo.setBlobIdent(blobIdent);- oldAndNew = null;- }-- public BlobIdent getCompareWith() {- return Preconditions.checkNotNull(inlineInfo).getCompareWith();- }-- public void setCompareWith(BlobIdent compareWith) {- if (inlineInfo == null)- inlineInfo = new InlineInfo();- inlineInfo.setCompareWith(compareWith);- oldAndNew = null;- }-- public int getBeginLine() {- return Preconditions.checkNotNull(inlineInfo).getBeginLine();- }-- public void setBeginLine(int beginLine) {- if (inlineInfo == null)- inlineInfo = new InlineInfo();- inlineInfo.setBeginLine(beginLine);- }-- public int getEndLine() {- return Preconditions.checkNotNull(inlineInfo).getEndLine();- }-- public void setEndLine(int endLine) {- if (inlineInfo == null)- inlineInfo = new InlineInfo();- inlineInfo.setEndLine(endLine);- }-- public Date getLastVisitDate() {- return GitPlex.getInstance(PullRequestManager.class).getLastVisitDate(getRequest());- }--}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.javaindex 11a72aca64..826e6e7319 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java@@ -41,7 +41,6 @@ import com.pmease.commons.git.Git;import com.pmease.commons.git.GitUtils;import com.pmease.commons.hibernate.AbstractEntity;import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.commons.jackson.ExternalView;import com.pmease.commons.util.LockUtils;import com.pmease.gitplex.core.GitPlex;@@ -236,7 +235,7 @@ public class PullRequest extends AbstractEntity {@OneToMany(mappedBy="request")@OnDelete(action=OnDeleteAction.CASCADE)- private Collection<Comment> comments = new ArrayList<>();+ private Collection<PullRequestComment> comments = new ArrayList<>();@OneToMany(mappedBy="request")@OnDelete(action=OnDeleteAction.CASCADE)@@ -266,8 +265,6 @@ public class PullRequest extends AbstractEntity {private transient Collection<Commit> mergedCommits;- private transient Collection<CommentReply> commentReplies;-private transient List<Review> reviews;/**@@ -465,11 +462,11 @@ public class PullRequest extends AbstractEntity {this.referenced = referenced;}- public Collection<Comment> getComments() {+ public Collection<PullRequestComment> getComments() {return comments;}- public void setComments(Collection<Comment> comments) {+ public void setComments(Collection<PullRequestComment> comments) {this.comments = comments;}@@ -858,32 +855,6 @@ public class PullRequest extends AbstractEntity {return mergedCommits;}- private Collection<CommentReply> getCommentReplies() {- if (commentReplies == null) {- EntityCriteria<CommentReply> criteria = EntityCriteria.of(CommentReply.class);- criteria.createCriteria("comment").add(Restrictions.eq("request", this));- commentReplies = GitPlex.getInstance(Dao.class).query(criteria);- }- return commentReplies;- }-- /**- * This method is here for performance consideration. Often we need to load replies of- * different comments in a pull request. And we optimize it to load all replies at once- * for all comments in a pull request to reduce SQL queries.- *- * @param comment- * @return- */- public Collection<CommentReply> getCommentReplies(Comment comment) {- List<CommentReply> replies = new ArrayList<>();- for (CommentReply reply: getCommentReplies()) {- if (reply.getComment().equals(comment))- replies.add(reply);- }- return replies;- }-public List<Review> getReviews() {if (reviews == null) {if (!isNew())diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.javasimilarity index 60%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CommentReply.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.javaindex ff373c6984..2b2cf48e46 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CommentReply.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.java@@ -6,54 +6,64 @@ import javax.annotation.Nullable;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.FetchType;-import javax.persistence.JoinColumn;import javax.persistence.Lob;import javax.persistence.ManyToOne;import javax.persistence.Version;+import org.hibernate.annotations.DynamicUpdate;+import com.pmease.commons.hibernate.AbstractEntity;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;+/*+ * @DynamicUpdate annotation here along with various @OptimisticLock annotations+ * on certain fields tell Hibernate not to perform version check on those fields+ * which can be updated from background thread.+ */@Entity-public class CommentReply extends AbstractEntity {-+@DynamicUpdate+public class PullRequestComment extends AbstractEntity {+private static final long serialVersionUID = 1L;+ public static final int DIFF_CONTEXT_SIZE = 3;+@Versionprivate long version;@ManyToOne(fetch=FetchType.LAZY)- private Account user;+ private PullRequest request;- @Column(nullable=false)- private Date date = new Date();+ @ManyToOne(fetch=FetchType.LAZY)+ private Account user;@Lob@Column(nullable=false, length=65535)private String content;- private String contextCommit;+ @Column(nullable=false)+ private Date date = new Date();++ public PullRequest getRequest() {+ return request;+ }- public long getVersion() {- return version;+ public void setRequest(PullRequest request) {+ this.request = request;}- @ManyToOne(fetch=FetchType.LAZY)- @JoinColumn(nullable=false)- private Comment comment;-@Nullablepublic Account getUser() {return user;}- public void setUser(Account user) {+ public void setUser(@Nullable Account user) {this.user = user;}- public Date getDate() {- return date;+ public long getVersion() {+ return version;}public String getContent() {@@ -64,30 +74,16 @@ public class CommentReply extends AbstractEntity {this.content = content;}- public void delete() {- GitPlex.getInstance(Dao.class).remove(this);- }-- public Comment getComment() {- return comment;- }-- public void setComment(Comment comment) {- this.comment = comment;+ public Date getDate() {+ return date;}- /**- * @return the contextCommit- */- public String getContextCommit() {- return contextCommit;+ public Depot getDepot() {+ return request.getTargetDepot();}- /**- * @param contextCommit the contextCommit to set- */- public void setContextCommit(String contextCommit) {- this.contextCommit = contextCommit;+ public void delete() {+ GitPlex.getInstance(Dao.class).remove(this);}}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/InlineInfo.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPosition.javasimilarity index 93%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/InlineInfo.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPosition.javaindex 3bac255bd6..50d7c16132 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/InlineInfo.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/CommentPosition.java@@ -11,7 +11,7 @@ import javax.persistence.Embedded;import com.pmease.commons.git.BlobIdent;@Embeddable-public class InlineInfo implements Serializable {+public class CommentPosition implements Serializable {private static final long serialVersionUID = 1L;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentPersistListener.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentPersistListener.javaindex ac2ac735c3..5dbf1003c8 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentPersistListener.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentPersistListener.java@@ -15,11 +15,11 @@ import com.pmease.commons.hibernate.PersistListener;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.commons.markdown.MarkdownManager;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestReference;import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.manager.AccountManager;import com.pmease.gitplex.core.util.markdown.MentionParser;import com.pmease.gitplex.core.util.markdown.PullRequestParser;@@ -53,8 +53,8 @@ public class CommentPersistListener implements PersistListener {@Overridepublic boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,String[] propertyNames, Type[] types) throws CallbackException {- if (entity instanceof Comment) {- Comment comment = (Comment) entity;+ if (entity instanceof PullRequestComment) {+ PullRequestComment comment = (PullRequestComment) entity;for (int i=0; i<propertyNames.length; i++) {if (propertyNames[i].equals("content")) {String content = (String) currentState[i];@@ -69,7 +69,7 @@ public class CommentPersistListener implements PersistListener {mentions.removeAll(mentionParser.parseMentions(prevHtml));for (Account user: mentions) {for (PullRequestListener listener: pullRequestListeners)- listener.onMentioned((Comment) entity, user);+ listener.onMentioned((PullRequestComment) entity, user);}Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);@@ -86,8 +86,8 @@ public class CommentPersistListener implements PersistListener {@Overridepublic boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)throws CallbackException {- if (entity instanceof Comment) {- Comment comment = (Comment) entity;+ if (entity instanceof PullRequestComment) {+ PullRequestComment comment = (PullRequestComment) entity;for (int i=0; i<propertyNames.length; i++) {if (propertyNames[i].equals("content")) {String content = (String) state[i];@@ -95,7 +95,7 @@ public class CommentPersistListener implements PersistListener {Collection<Account> mentions = new MentionParser().parseMentions(html);for (Account user: mentions) {for (PullRequestListener listener: pullRequestListeners)- listener.onMentioned((Comment) entity, user);+ listener.onMentioned((PullRequestComment) entity, user);}Collection<PullRequest> requests = new PullRequestParser().parseRequests(html);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentReplyPersistListener.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentReplyPersistListener.javadeleted file mode 100644index d60d718b26..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/persistlistener/CommentReplyPersistListener.java+++ /dev/null@@ -1,126 +0,0 @@-package com.pmease.gitplex.core.entity.persistlistener;--import java.io.Serializable;-import java.util.Collection;-import java.util.Set;--import javax.inject.Inject;-import javax.inject.Singleton;--import org.hibernate.CallbackException;-import org.hibernate.criterion.Restrictions;-import org.hibernate.type.Type;--import com.pmease.commons.hibernate.PersistListener;-import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.hibernate.dao.EntityCriteria;-import com.pmease.commons.markdown.MarkdownManager;-import com.pmease.gitplex.core.entity.CommentReply;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.PullRequestReference;-import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.manager.AccountManager;-import com.pmease.gitplex.core.util.markdown.MentionParser;-import com.pmease.gitplex.core.util.markdown.PullRequestParser;--@Singleton-public class CommentReplyPersistListener implements PersistListener {-- private final MarkdownManager markdownManager;-- private final Set<PullRequestListener> pullRequestListeners;-- private final Dao dao;-- private final AccountManager userManager;-- @Inject- public CommentReplyPersistListener(MarkdownManager markdownManager,- Set<PullRequestListener> pullRequestListeners, Dao dao, AccountManager userManager) {- this.markdownManager = markdownManager;- this.pullRequestListeners = pullRequestListeners;- this.dao = dao;- this.userManager = userManager;- }-- @Override- public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)- throws CallbackException {- return false;- }-- @Override- public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,- String[] propertyNames, Type[] types) throws CallbackException {- if (entity instanceof CommentReply) {- CommentReply reply = (CommentReply) entity;- for (int i=0; i<propertyNames.length; i++) {- if (propertyNames[i].equals("content")) {- String content = (String) currentState[i];- String prevContent = (String) previousState[i];- if (!content.equals(prevContent)) {- MentionParser parser = new MentionParser();- String html = markdownManager.parse(content);- Collection<Account> mentions = parser.parseMentions(html);- mentions.removeAll(parser.parseMentions(markdownManager.parse(prevContent)));- for (Account user: mentions) {- for (PullRequestListener listener: pullRequestListeners)- listener.onMentioned((CommentReply) entity, user);- }-- for (PullRequest request: new PullRequestParser().parseRequests(html))- saveReference(request, reply.getComment().getRequest());- }- break;- }- }- }- return false;- }-- @Override- public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)- throws CallbackException {- if (entity instanceof CommentReply) {- CommentReply reply = (CommentReply) entity;- for (int i=0; i<propertyNames.length; i++) {- if (propertyNames[i].equals("content")) {- String content = (String) state[i];- String html = markdownManager.parse(content);- Collection<Account> mentions = new MentionParser().parseMentions(html);- for (Account user: mentions) {- for (PullRequestListener listener: pullRequestListeners)- listener.onMentioned((CommentReply) entity, user);- }-- for (PullRequest request: new PullRequestParser().parseRequests(html))- saveReference(request, reply.getComment().getRequest());- break;- }- }- }- return false;- }-- private void saveReference(PullRequest referenced, PullRequest referencedBy) {- if (!referenced.equals(referencedBy)) {- EntityCriteria<PullRequestReference> criteria = EntityCriteria.of(PullRequestReference.class);- criteria.add(Restrictions.eq("referenced", referenced));- criteria.add(Restrictions.eq("referencedBy", referencedBy));- if (dao.find(criteria) == null) {- PullRequestReference reference = new PullRequestReference();- reference.setReferencedBy(referencedBy);- reference.setReferenced(referenced);- reference.setUser(userManager.getCurrent());- dao.persist(reference);- }- }- }-- @Override- public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)- throws CallbackException {- }--}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/listener/PullRequestListener.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/listener/PullRequestListener.javaindex d9e869c426..14ebfaf513 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/listener/PullRequestListener.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/listener/PullRequestListener.java@@ -3,13 +3,12 @@ package com.pmease.gitplex.core.listener;import javax.annotation.Nullable;import com.pmease.commons.loader.ExtensionPoint;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.Review;import com.pmease.gitplex.core.entity.ReviewInvitation;-import com.pmease.gitplex.core.entity.Account;@ExtensionPointpublic interface PullRequestListener {@@ -22,14 +21,10 @@ public interface PullRequestListener {void onMentioned(PullRequest request, Account user);- void onMentioned(Comment comment, Account user);+ void onMentioned(PullRequestComment comment, Account user);- void onMentioned(CommentReply reply, Account user);+ void onCommented(PullRequestComment comment);- void onCommented(Comment comment);-- void onCommentReplied(CommentReply reply);-void onReviewed(Review review, @Nullable String comment);void onAssigned(PullRequest request);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentManager.javadeleted file mode 100644index a969fde9b3..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentManager.java+++ /dev/null@@ -1,10 +0,0 @@-package com.pmease.gitplex.core.manager;--import com.pmease.commons.hibernate.dao.EntityDao;-import com.pmease.gitplex.core.entity.Comment;--public interface CommentManager extends EntityDao<Comment> {-- void save(Comment comment, boolean notify);--}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentReplyManager.javadeleted file mode 100644index 8efd589e15..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/CommentReplyManager.java+++ /dev/null@@ -1,14 +0,0 @@-package com.pmease.gitplex.core.manager;--import java.util.Collection;--import com.pmease.commons.hibernate.dao.EntityDao;-import com.pmease.gitplex.core.entity.CommentReply;-import com.pmease.gitplex.core.entity.PullRequest;--public interface CommentReplyManager extends EntityDao<CommentReply> {-- void save(CommentReply reply);-- Collection<CommentReply> findBy(PullRequest request);-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.javanew file mode 100644index 0000000000..b38a670138--- /dev/null+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestCommentManager.java@@ -0,0 +1,10 @@+package com.pmease.gitplex.core.manager;++import com.pmease.commons.hibernate.dao.EntityDao;+import com.pmease.gitplex.core.entity.PullRequestComment;++public interface PullRequestCommentManager extends EntityDao<PullRequestComment> {++ void save(PullRequestComment comment, boolean notify);++}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.javaindex e6d34793c1..cef0a57c4f 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java@@ -1,7 +1,6 @@package com.pmease.gitplex.core.manager;import java.util.Collection;-import java.util.Date;import java.util.List;import javax.annotation.Nullable;@@ -76,16 +75,6 @@ public interface PullRequestManager extends EntityDao<PullRequest> {void restoreSourceBranch(PullRequest request);- /**- * Get last visit date of specified pull request for current user.- *- * @return- * last visit date of specified pull request for current user, or <tt>null</tt>- * if current user is anonymous or has never visited the pull request- */- @Nullable- Date getLastVisitDate(PullRequest request);-void checkSanity();int countOpen(Depot depot);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/UrlManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/UrlManager.javaindex b7ccf5ca9f..506b2c23a3 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/UrlManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/UrlManager.java@@ -1,10 +1,9 @@package com.pmease.gitplex.core.manager;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.entity.PullRequestComment;public interface UrlManager {@@ -14,7 +13,5 @@ public interface UrlManager {String urlFor(PullRequest request);- String urlFor(Comment comment);-- String urlFor(CommentReply reply);+ String urlFor(PullRequestComment comment);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentReplyManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentReplyManager.javadeleted file mode 100644index 34657ab2d1..0000000000--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentReplyManager.java+++ /dev/null@@ -1,50 +0,0 @@-package com.pmease.gitplex.core.manager.impl;--import java.util.Collection;-import java.util.Set;--import javax.inject.Inject;-import javax.inject.Singleton;--import org.hibernate.criterion.Restrictions;--import com.pmease.commons.hibernate.Sessional;-import com.pmease.commons.hibernate.Transactional;-import com.pmease.commons.hibernate.dao.AbstractEntityDao;-import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.hibernate.dao.EntityCriteria;-import com.pmease.gitplex.core.entity.CommentReply;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.manager.CommentReplyManager;--@Singleton-public class DefaultCommentReplyManager extends AbstractEntityDao<CommentReply> implements CommentReplyManager {-- private final Set<PullRequestListener> pullRequestListeners;-- @Inject- public DefaultCommentReplyManager(Dao dao, Set<PullRequestListener> pullRequestListeners) {- super(dao);-- this.pullRequestListeners = pullRequestListeners;- }-- @Transactional- @Override- public void save(CommentReply reply) {- persist(reply);-- for (PullRequestListener listener: pullRequestListeners)- listener.onCommentReplied(reply);- }-- @Sessional- @Override- public Collection<CommentReply> findBy(PullRequest request) {- EntityCriteria<CommentReply> criteria = EntityCriteria.of(CommentReply.class);- criteria.createCriteria("comment").add(Restrictions.eq("request", request));- return query(criteria);- }--}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.javaindex a7b08cf1bd..5733d8c659 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultNotificationManager.java@@ -19,10 +19,9 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.commons.markdown.MarkdownManager;import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;import com.pmease.gitplex.core.entity.Notification;import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.Review;import com.pmease.gitplex.core.entity.ReviewInvitation;@@ -75,13 +74,9 @@ public class DefaultNotificationManager extends AbstractEntityDao<Notification>}@Override- public void onCommented(Comment comment) {+ public void onCommented(PullRequestComment comment) {}- @Override- public void onCommentReplied(CommentReply reply) {- }-@Transactional@Overridepublic void onReviewed(Review review, String comment) {@@ -209,7 +204,7 @@ public class DefaultNotificationManager extends AbstractEntityDao<Notification>@Transactional@Override- public void onMentioned(Comment comment, Account user) {+ public void onMentioned(PullRequestComment comment, Account user) {String subject = String.format("You are mentioned in comment of pull request #%d (%s)",comment.getRequest().getId(), comment.getRequest().getTitle());String url = urlManager.urlFor(comment);@@ -222,21 +217,6 @@ public class DefaultNotificationManager extends AbstractEntityDao<Notification>mailManager.sendMail(Sets.newHashSet(user), subject, decorateMail(user, body));}- @Transactional- @Override- public void onMentioned(CommentReply reply, Account user) {- String subject = String.format("You are mentioned in comment of pull request #%d (%s)",- reply.getComment().getRequest().getId(), reply.getComment().getRequest().getTitle());- String url = urlManager.urlFor(reply);- String body = String.format("%s."- + "<p style='margin: 16px 0; padding-left: 16px; border-left: 4px solid #CCC;'>%s"- + "<p style='margin: 16px 0;'>"- + "For details, please visit <a href='%s'>%s</a>",- subject, markdownManager.escape(reply.getContent()), url, url);-- mailManager.sendMail(Sets.newHashSet(user), subject, decorateMail(user, body));- }-@Transactional@Overridepublic void onReopened(PullRequest request, Account user, String comment) {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.javasimilarity index 59%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentManager.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.javaindex f0340179e8..0527b59b23 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java@@ -8,17 +8,18 @@ import javax.inject.Singleton;import com.pmease.commons.hibernate.Transactional;import com.pmease.commons.hibernate.dao.AbstractEntityDao;import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.manager.CommentManager;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;@Singleton-public class DefaultCommentManager extends AbstractEntityDao<Comment> implements CommentManager {+public class DefaultPullRequestCommentManager extends AbstractEntityDao<PullRequestComment>+ implements PullRequestCommentManager {private final Set<PullRequestListener> pullRequestListeners;@Inject- public DefaultCommentManager(Dao dao, Set<PullRequestListener> pullRequestListeners) {+ public DefaultPullRequestCommentManager(Dao dao, Set<PullRequestListener> pullRequestListeners) {super(dao);this.pullRequestListeners = pullRequestListeners;@@ -26,7 +27,7 @@ public class DefaultCommentManager extends AbstractEntityDao<Comment> implements@Transactional@Override- public void save(Comment comment, boolean notify) {+ public void save(PullRequestComment comment, boolean notify) {persist(comment);if (notify) {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.javaindex b0ee71f6c8..0ea236ddb7 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java@@ -51,13 +51,12 @@ import com.pmease.commons.util.concurrent.PrioritizedRunnable;import com.pmease.commons.util.match.PatternMatcher;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequest.IntegrationStrategy;import com.pmease.gitplex.core.entity.PullRequestActivity;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;-import com.pmease.gitplex.core.entity.PullRequestVisit;import com.pmease.gitplex.core.entity.ReviewInvitation;import com.pmease.gitplex.core.entity.component.CloseInfo;import com.pmease.gitplex.core.entity.component.DepotAndBranch;@@ -68,8 +67,8 @@ import com.pmease.gitplex.core.listener.LifecycleListener;import com.pmease.gitplex.core.listener.PullRequestListener;import com.pmease.gitplex.core.listener.RefListener;import com.pmease.gitplex.core.manager.AccountManager;-import com.pmease.gitplex.core.manager.CommentManager;import com.pmease.gitplex.core.manager.NotificationManager;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.core.manager.PullRequestUpdateManager;import com.pmease.gitplex.core.manager.ReviewInvitationManager;@@ -93,7 +92,7 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> imprivate final PullRequestUpdateManager pullRequestUpdateManager;- private final CommentManager commentManager;+ private final PullRequestCommentManager commentManager;private final AccountManager userManager;@@ -113,7 +112,7 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> impublic DefaultPullRequestManager(Dao dao,PullRequestUpdateManager pullRequestUpdateManager, StorageManager storageManager,ReviewInvitationManager reviewInvitationManager, AccountManager userManager,- NotificationManager notificationManager, CommentManager commentManager,+ NotificationManager notificationManager, PullRequestCommentManager commentManager,MarkdownManager markdownManager, WorkManager workManager,UnitOfWork unitOfWork, Set<PullRequestListener> pullRequestListeners) {super(dao);@@ -202,7 +201,7 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> impersist(activity);if (comment != null) {- Comment requestComment = new Comment();+ PullRequestComment requestComment = new PullRequestComment();requestComment.setContent(comment);requestComment.setRequest(request);requestComment.setUser(user);@@ -230,7 +229,7 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> impersist(activity);if (comment != null) {- Comment requestComment = new Comment();+ PullRequestComment requestComment = new PullRequestComment();requestComment.setContent(comment);requestComment.setRequest(request);requestComment.setUser(user);@@ -311,7 +310,7 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> impersist(activity);if (comment != null) {- Comment requestComment = new Comment();+ PullRequestComment requestComment = new PullRequestComment();requestComment.setContent(comment);requestComment.setRequest(request);requestComment.setUser(user);@@ -649,20 +648,6 @@ public class DefaultPullRequestManager extends AbstractEntityDao<PullRequest> im}- @Override- public Date getLastVisitDate(PullRequest request) {- Account user = userManager.getCurrent();- if (user != null) {- PullRequestVisit visit = request.getVisit(user);- if (visit != null)- return visit.getDate();- else- return null;- } else {- return null;- }- }-@Overridepublic void systemStarted() {}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.javaindex 96b3b56b3d..f436165a54 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestUpdateManager.java@@ -12,7 +12,7 @@ import com.pmease.commons.util.FileUtils;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.manager.CommentManager;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;import com.pmease.gitplex.core.manager.PullRequestUpdateManager;import com.pmease.gitplex.core.manager.StorageManager;@@ -25,7 +25,7 @@ public class DefaultPullRequestUpdateManager extends AbstractEntityDao<PullReque@Injectpublic DefaultPullRequestUpdateManager(Dao dao, StorageManager storageManager,- Set<PullRequestListener> pullRequestListeners, CommentManager commentManager) {+ Set<PullRequestListener> pullRequestListeners, PullRequestCommentManager commentManager) {super(dao);this.storageManager = storageManager;diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.javaindex 8e1a84dabb..f68200d27c 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestWatchManager.java@@ -29,10 +29,9 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.util.Pair;import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.BranchWatch;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequest.Event;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.PullRequestVisit;import com.pmease.gitplex.core.entity.PullRequestWatch;@@ -128,20 +127,12 @@ public class DefaultPullRequestWatchManager extends AbstractEntityDao<PullReques@Transactional@Override- public void onCommented(Comment comment) {+ public void onCommented(PullRequestComment comment) {watch(comment.getRequest(), comment.getUser(),"You are set to watch this pull request as you've commented.");notify(comment.getRequest(), Sets.newHashSet(comment.getUser()), COMMENTED);}- @Transactional- @Override- public void onCommentReplied(CommentReply reply) {- watch(reply.getComment().getRequest(), reply.getUser(),- "You are set to watch this pull request as you've commented.");- notify(reply.getComment().getRequest(), Sets.newHashSet(reply.getUser()), COMMENTED);- }-@Transactional@Overridepublic void onReviewed(Review review, String comment) {@@ -262,13 +253,8 @@ public class DefaultPullRequestWatchManager extends AbstractEntityDao<PullReques}@Override- public void onMentioned(Comment comment, Account user) {+ public void onMentioned(PullRequestComment comment, Account user) {watch(comment.getRequest(), user, "You are set to watch this pull request as you are mentioned.");}- @Override- public void onMentioned(CommentReply reply, Account user) {- watch(reply.getComment().getRequest(), user, "You are set to watch this pull request as you are mentioned.");- }-}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.javaindex a9a46883e3..7fd4aaa4f1 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultReviewManager.java@@ -18,15 +18,15 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.hibernate.dao.EntityCriteria;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequestActivity;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.Review;import com.pmease.gitplex.core.entity.Review.Result;import com.pmease.gitplex.core.listener.PullRequestListener;import com.pmease.gitplex.core.manager.AccountManager;-import com.pmease.gitplex.core.manager.CommentManager;+import com.pmease.gitplex.core.manager.PullRequestCommentManager;import com.pmease.gitplex.core.manager.PullRequestManager;import com.pmease.gitplex.core.manager.ReviewManager;@@ -35,7 +35,7 @@ public class DefaultReviewManager extends AbstractEntityDao<Review> implements Rprivate final PullRequestManager pullRequestManager;- private final CommentManager commentManager;+ private final PullRequestCommentManager commentManager;private final UnitOfWork unitOfWork;@@ -43,7 +43,7 @@ public class DefaultReviewManager extends AbstractEntityDao<Review> implements R@Injectpublic DefaultReviewManager(Dao dao,- PullRequestManager pullRequestManager, CommentManager commentManager,+ PullRequestManager pullRequestManager, PullRequestCommentManager commentManager,UnitOfWork unitOfWork, Set<PullRequestListener> pullRequestListeners) {super(dao);@@ -84,7 +84,7 @@ public class DefaultReviewManager extends AbstractEntityDao<Review> implements Rpersist(activity);if (comment != null) {- Comment requestComment = new Comment();+ PullRequestComment requestComment = new PullRequestComment();requestComment.setRequest(request);requestComment.setUser(reviewer);requestComment.setContent(comment);diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.javaindex 92394c102d..7a0f34f6aa 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java@@ -8,7 +8,7 @@ import org.eclipse.jgit.lib.ObjectId;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.Review;@@ -51,7 +51,7 @@ public class SecurityUtils extends org.apache.shiro.SecurityUtils {}}- public static boolean canModify(Comment comment) {+ public static boolean canModify(CodeComment comment) {Account currentUser = getAccount();if (currentUser == null) {return false;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/WebUrlManager.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/WebUrlManager.javaindex 2934648563..f78ac7db37 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/WebUrlManager.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/WebUrlManager.java@@ -3,11 +3,10 @@ package com.pmease.gitplex.web;import javax.inject.Inject;import javax.inject.Singleton;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.Account;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.manager.ConfigManager;import com.pmease.gitplex.core.manager.UrlManager;@@ -37,13 +36,8 @@ public class WebUrlManager implements UrlManager {}@Override- public String urlFor(Comment comment) {+ public String urlFor(PullRequestComment comment) {return urlFor(comment.getRequest()) + "#comment" + comment.getId();}- @Override- public String urlFor(CommentReply reply) {- return urlFor(reply.getComment().getRequest()) + "#reply" + reply.getId();- }-}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.htmldeleted file mode 100644index 81c0c397c9..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.html+++ /dev/null@@ -1,61 +0,0 @@-<wicket:panel>- <a wicket:id="anchor"></a>- <div class="comment">- <div wicket:id="head" class="head activity-summary clearfix">- <div class="pull-left">- <span wicket:id="user" class="user"></span> <span wicket:id="action"></span> <span wicket:id="age"></span>- </div>- <div class="operations pull-right">- <a wicket:id="edit" title="Edit comment"><span class="fa fa-pencil"></span></a>- <a wicket:id="delete" title="Delete comment"><span class="fa fa-times"></span></a>- <span wicket:id="additionalOperations"></span>- <a wicket:id="permalink" title="Permalink"><i class="fa fa-link"></i></a>- </div>- </div>- <div wicket:id="body" class="body"></div>- <div class="replies">- <table>- <tbody>- <tr wicket:id="replies" class="reply">- <td wicket:id="avatar" class="avatar">- <div wicket:id="avatar"></div>- </td>- <td class="detail">- <a wicket:id="anchor"></a>- <div wicket:id="head" class="head activity-summary clearfix">- <div class="pull-left">- <span wicket:id="user" class="user"></span> replied <span wicket:id="age"></span>- </div>- <div class="operations pull-right">- <a wicket:id="edit" title="Edit reply"><span class="fa fa-pencil"></span></a>- <a wicket:id="delete" title="Delete reply"><span class="fa fa-times"></span></a>- <span wicket:id="additionalOperations"></span>- <a wicket:id="permalink" title="Permalink"><i class="fa fa-link"></i></a>- </div>- </div>- <div wicket:id="body" class="body"></div>- </td>- </tr>- </tbody>- </table>- <div wicket:id="addReply" class="add-reply"><div wicket:id="content"></div></div>- </div>- </div>- <wicket:fragment wicket:id="viewFrag">- <div wicket:id="feedback" class="feedback"></div>- <div wicket:id="comment"></div>- </wicket:fragment>- <wicket:fragment wicket:id="editFrag">- <form wicket:id="form" class="leave-confirm">- <div wicket:id="feedback" class="feedback"></div>- <textarea wicket:id="input" rows="5" class="form-control focusable"></textarea>- <div class="actions">- <button wicket:id="save" class="btn btn-sm btn-primary dirty-aware">Save</button>- <button wicket:id="cancel" class="btn btn-sm btn-default">Cancel</button>- </div>- </form>- </wicket:fragment>- <wicket:fragment wicket:id="addFrag">- <a wicket:id="addReply"><i class="fa fa-mail-reply"></i> Add reply</a>- </wicket:fragment>-</wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.javadeleted file mode 100644index e5c462cf46..0000000000--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java+++ /dev/null@@ -1,652 +0,0 @@-package com.pmease.gitplex.web.component.comment;--import java.util.ArrayList;-import java.util.Date;-import java.util.List;-import java.util.concurrent.atomic.AtomicLong;--import org.apache.wicket.AttributeModifier;-import org.apache.wicket.Component;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;-import org.apache.wicket.ajax.markup.html.AjaxLink;-import org.apache.wicket.ajax.markup.html.form.AjaxButton;-import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;-import org.apache.wicket.event.Broadcast;-import org.apache.wicket.event.IEvent;-import org.apache.wicket.markup.head.CssHeaderItem;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.html.WebMarkupContainer;-import org.apache.wicket.markup.html.basic.Label;-import org.apache.wicket.markup.html.form.Form;-import org.apache.wicket.markup.html.panel.Fragment;-import org.apache.wicket.markup.html.panel.GenericPanel;-import org.apache.wicket.markup.repeater.RepeatingView;-import org.apache.wicket.model.AbstractReadOnlyModel;-import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;-import org.apache.wicket.model.Model;-import org.apache.wicket.request.cycle.RequestCycle;-import org.apache.wicket.request.resource.CssResourceReference;-import org.hibernate.StaleObjectStateException;--import com.google.common.base.Preconditions;-import com.pmease.commons.hibernate.dao.Dao;-import com.pmease.commons.loader.InheritableThreadLocalData;-import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;-import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;-import com.pmease.commons.wicket.component.markdownviewer.MarkdownViewer;-import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior.PageId;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;-import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.manager.AccountManager;-import com.pmease.gitplex.core.manager.CommentManager;-import com.pmease.gitplex.core.manager.CommentReplyManager;-import com.pmease.gitplex.core.security.SecurityUtils;-import com.pmease.gitplex.web.component.AccountLink;-import com.pmease.gitplex.web.component.avatar.AvatarLink;-import com.pmease.gitplex.web.component.comment.event.CommentRemoved;-import com.pmease.gitplex.web.component.comment.event.CommentResized;-import com.pmease.gitplex.web.util.DateUtils;-import com.pmease.gitplex.web.websocket.PullRequestChanged;--import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;--@SuppressWarnings("serial")-public class CommentPanel extends GenericPanel<Comment> {-- private static final String HEAD_ID = "head";-- private static final String BODY_ID = "body";-- private static final String CONTENT_ID = "content";-- private static final String ADD_REPLY_ID = "addReply";-- private static final String FORM_ID = "form";-- private RepeatingView repliesView;-- private final IModel<List<CommentReply>> repliesModel = new LoadableDetachableModel<List<CommentReply>>() {-- @Override- protected List<CommentReply> load() {- List<CommentReply> replies = new ArrayList<>(getComment().getReplies());- replies.sort((reply1, reply2) -> reply1.getDate().compareTo(reply2.getDate()));- return replies;- }-- };-- public CommentPanel(String id, IModel<Comment> commentModel) {- super(id, commentModel);- }-- private Comment getComment() {- return getModelObject();- }-- private Fragment renderComment() {- final Fragment fragment = new Fragment(BODY_ID, "viewFrag", this);-- final NotificationPanel feedback = new NotificationPanel("feedback", fragment);- feedback.setOutputMarkupPlaceholderTag(true);- fragment.add(feedback);- final AtomicLong lastVersionRef = new AtomicLong(getComment().getVersion());- fragment.add(new MarkdownViewer("comment", new IModel<String>() {-- @Override- public void detach() {- }-- @Override- public String getObject() {- return getComment().getContent();- }-- @Override- public void setObject(String object) {- AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);- Preconditions.checkNotNull(target);- Comment comment = getComment();- try {- if (comment.getVersion() != lastVersionRef.get())- throw new StaleObjectStateException(Comment.class.getName(), comment.getId());- comment.setContent(object);- GitPlex.getInstance(CommentManager.class).save(comment, false);- target.add(feedback); // clear the feedback- } catch (StaleObjectStateException e) {- fragment.warn("Some one changed the content you are editing. The content has now been "- + "reloaded, please try again.");- target.add(fragment);- }- lastVersionRef.set(comment.getVersion());- }-- }, SecurityUtils.canModify(getComment())));-- fragment.setOutputMarkupId(true);- return fragment;- }-- private Fragment renderReply(CommentReply reply) {- final Fragment fragment = new Fragment(BODY_ID, "viewFrag", this);-- final Long replyId = reply.getId();- final NotificationPanel feedback = new NotificationPanel("feedback", fragment);- feedback.setOutputMarkupPlaceholderTag(true);- fragment.add(feedback);- final AtomicLong lastVersionRef = new AtomicLong(reply.getVersion());- fragment.add(new MarkdownViewer("comment", new IModel<String>() {-- @Override- public void detach() {- }-- @Override- public String getObject() {- return GitPlex.getInstance(Dao.class).load(CommentReply.class, replyId).getContent();- }-- @Override- public void setObject(String object) {- AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);- Preconditions.checkNotNull(target);- CommentReply reply = GitPlex.getInstance(Dao.class).load(CommentReply.class, replyId);- try {- if (reply.getVersion() != lastVersionRef.get())- throw new StaleObjectStateException(CommentReply.class.getName(), reply.getId());- reply.setContent(object);- GitPlex.getInstance(CommentReplyManager.class).save(reply);- target.add(feedback); // clear the feedback- } catch (StaleObjectStateException e) {- fragment.warn("Some one changed the content you are editing. The content has now been "- + "reloaded, please try again.");- target.add(fragment);- }- lastVersionRef.set(reply.getVersion());- }-- }, SecurityUtils.canModify(getComment())));-- fragment.setOutputMarkupId(true);- return fragment;- }-- @Override- protected void onInitialize() {- super.onInitialize();-- String anchorName = "gp-comment" + getComment().getId();- add(new WebMarkupContainer("anchor").add(AttributeModifier.replace("name", anchorName)));-- final WebMarkupContainer head = new WebMarkupContainer(HEAD_ID);- head.setOutputMarkupId(true);- add(head);-- head.add(new AccountLink("user", getComment().getUser()));- head.add(newActionComponent("action"));- head.add(new Label("age", DateUtils.formatAge(getComment().getDate())));-- head.add(new AjaxLink<Void>("edit") {-- @Override- public void onClick(AjaxRequestTarget target) {- Fragment fragment = new Fragment(BODY_ID, "editFrag", CommentPanel.this);-- final Form<?> form = new Form<Void>(FORM_ID);- form.setOutputMarkupId(true);- fragment.add(form);- final NotificationPanel feedback = new NotificationPanel("feedback", form);- feedback.setOutputMarkupPlaceholderTag(true);- form.add(feedback);- final CommentInput input = new CommentInput("input", new AbstractReadOnlyModel<PullRequest>() {-- @Override- public PullRequest getObject() {- return getComment().getRequest();- }-- }, Model.of(getComment().getContent()));- input.setRequired(true);- form.add(input);-- final long lastVersion = getComment().getVersion();- form.add(new AjaxButton("save") {-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- Comment comment = getComment();- try {- if (comment.getVersion() != lastVersion)- throw new StaleObjectStateException(Comment.class.getName(), comment.getId());- comment.setContent(input.getModelObject());- GitPlex.getInstance(CommentManager.class).save(comment, false);-- Fragment fragment = renderComment();- CommentPanel.this.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- } catch (StaleObjectStateException e) {- error("Some one changed the content you are editing. Reload the page and try again.");- target.add(feedback);- }- }-- @Override- protected void onError(AjaxRequestTarget target, Form<?> form) {- super.onError(target, form);- target.add(feedback);- }-- });-- form.add(new AjaxLink<Void>("cancel") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));- }-- @Override- public void onClick(AjaxRequestTarget target) {- Fragment fragment = renderComment();- CommentPanel.this.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- });-- fragment.setOutputMarkupId(true);- CommentPanel.this.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- @Override- protected void onConfigure() {- super.onConfigure();-- setVisible(SecurityUtils.canModify(getComment()) && CommentPanel.this.get(BODY_ID).get(FORM_ID) == null);- }-- });-- head.add(new AjaxLink<Void>("delete") {-- @Override- public void onClick(AjaxRequestTarget target) {- getComment().delete();- send(CommentPanel.this, Broadcast.BUBBLE, new CommentRemoved(target, getComment()));- }-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmListener("Deleting this comment will also delete all its replies. Do you really want to continue?"));- }-- @Override- protected void onConfigure() {- super.onConfigure();-- setVisible(SecurityUtils.canModify(getComment()));- }-- });-- head.add(newAdditionalCommentOperations("additionalOperations", new AbstractReadOnlyModel<Comment>() {-- @Override- public Comment getObject() {- return getComment();- }-- }));-- head.add(new WebMarkupContainer("permalink").add(AttributeAppender.append("href", "#"+anchorName)));-- add(renderComment());-- add(newAddReply());-- setOutputMarkupId(true);- }-- @Override- public void onEvent(IEvent<?> event) {- super.onEvent(event);-- if (event.getPayload() instanceof PullRequestChanged) {- PullRequestChanged pullRequestChanged = (PullRequestChanged) event.getPayload();- if (pullRequestChanged.getEvent() == PullRequest.Event.COMMENT_REPLIED) {- IPartialPageRequestHandler target = pullRequestChanged.getPartialPageRequestHandler();- List<CommentReply> replies = repliesModel.getObject();- Date lastReplyDate;- if (repliesView.size() != 0) {- @SuppressWarnings("deprecation")- Component lastReplyRow = repliesView.get(repliesView.size()-1);- lastReplyDate = ((CommentReply)lastReplyRow.getDefaultModelObject()).getDate();- } else {- lastReplyDate = getComment().getDate();- }- for (CommentReply reply: replies) {- if (reply.getDate().after(lastReplyDate)) {- Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);- repliesView.add(newReplyRow);- String script = String.format("$('#%s>.comment>.replies>table>tbody').append(\"<tr id='%s' class='reply'></tr>\");",- getMarkupId(), newReplyRow.getMarkupId());- target.prependJavaScript(script);- target.add(newReplyRow);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }- }- }- }- }-- private Component newAddReply() {- WebMarkupContainer addReplyRow = new WebMarkupContainer(ADD_REPLY_ID);- addReplyRow.setOutputMarkupId(true);- addReplyRow.setVisible(GitPlex.getInstance(AccountManager.class).getCurrent() != null);-- Fragment fragment = new Fragment(CONTENT_ID, "addFrag", this);- fragment.add(new AjaxLink<Void>(ADD_REPLY_ID) {-- @Override- public void onClick(AjaxRequestTarget target) {- final WebMarkupContainer row = new WebMarkupContainer(ADD_REPLY_ID);-- row.setOutputMarkupId(true);-- Fragment fragment = new Fragment(CONTENT_ID, "editFrag", CommentPanel.this);- row.add(fragment);-- final Form<?> form = new Form<Void>(FORM_ID);- final NotificationPanel feedback = new NotificationPanel("feedback", form);- feedback.setOutputMarkupPlaceholderTag(true);- form.add(feedback);- fragment.add(form);- form.setOutputMarkupId(true);- final CommentInput input = new CommentInput("input", new AbstractReadOnlyModel<PullRequest>() {-- @Override- public PullRequest getObject() {- return getComment().getRequest();- }-- }, Model.of(""));- input.setRequired(true);- form.add(input);-- final int pageId = getPage().getPageId();- form.add(new AjaxButton("save") {-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- Component addReply = newAddReply();- CommentPanel.this.replace(addReply);- target.add(addReply);-- CommentReply reply;- InheritableThreadLocalData.set(new PageId(pageId));- try {- reply = getComment().addReply(input.getModelObject());- } finally {- InheritableThreadLocalData.clear();- }- Component newReplyRow = newReplyRow(repliesView.newChildId(), reply);- repliesView.add(newReplyRow);- String script = String.format("$('#%s>.comment>.replies>table>tbody').append(\"<tr id='%s' class='reply'></tr>\");",- CommentPanel.this.getMarkupId(), newReplyRow.getMarkupId());- target.prependJavaScript(script);- target.add(newReplyRow);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- @Override- protected void onError(AjaxRequestTarget target, Form<?> form) {- super.onError(target, form);- target.add(feedback);- }-- });-- form.add(new AjaxLink<Void>("cancel") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));- }-- @Override- public void onClick(AjaxRequestTarget target) {- Component addReply = newAddReply();- CommentPanel.this.replace(addReply);- target.add(addReply);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- });-- CommentPanel.this.replace(row);- target.add(row);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- });- addReplyRow.add(fragment);-- return addReplyRow;- }-- private RepeatingView newRepliesView() {- RepeatingView repliesView = new RepeatingView("replies");-- for (CommentReply reply: repliesModel.getObject())- repliesView.add(newReplyRow(repliesView.newChildId(), reply));-- return repliesView;- }-- @Override- protected void onBeforeRender() {- addOrReplace(repliesView = newRepliesView());-- super.onBeforeRender();- }-- private Component newReplyRow(String id, CommentReply reply) {- final Long replyId = reply.getId();- final WebMarkupContainer row = new WebMarkupContainer(id, new LoadableDetachableModel<CommentReply>() {-- @Override- protected CommentReply load() {- return GitPlex.getInstance(Dao.class).load(CommentReply.class, replyId);- }-- });- row.setOutputMarkupId(true);-- String anchorName = "gp-comment-reply" + reply.getId();- row.add(new WebMarkupContainer("anchor").add(AttributeModifier.append("name", anchorName)));-- WebMarkupContainer avatarColumn = new WebMarkupContainer("avatar");- avatarColumn.add(new AvatarLink("avatar", reply.getUser(), null));- row.add(avatarColumn);-- final WebMarkupContainer head = new WebMarkupContainer("head");- head.setOutputMarkupId(true);- row.add(head);-- head.add(new AccountLink("user", reply.getUser()));- head.add(new Label("age", DateUtils.formatAge(reply.getDate())));-- head.add(new AjaxLink<Void>("edit") {-- @Override- public void onClick(AjaxRequestTarget target) {- Fragment fragment = new Fragment(BODY_ID, "editFrag", CommentPanel.this);-- final Form<?> form = new Form<Void>(FORM_ID);- form.setOutputMarkupId(true);- final NotificationPanel feedback = new NotificationPanel("feedback", form);- feedback.setOutputMarkupPlaceholderTag(true);- form.add(feedback);- fragment.add(form);- CommentReply reply = (CommentReply) row.getDefaultModelObject();- final CommentInput input = new CommentInput("input", new AbstractReadOnlyModel<PullRequest>() {-- @Override- public PullRequest getObject() {- return getComment().getRequest();- }-- }, Model.of(reply.getContent()));- input.setRequired(true);- form.add(input);-- final long lastVersion = reply.getVersion();- form.add(new AjaxButton("save") {-- @Override- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {- try {- CommentReply reply = (CommentReply) row.getDefaultModelObject();- if (lastVersion != reply.getVersion())- throw new StaleObjectStateException(CommentReply.class.getName(), reply.getId());- reply.setContent(input.getModelObject());- GitPlex.getInstance(CommentReplyManager.class).save(reply);-- Fragment fragment = renderReply(reply);- row.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- } catch (StaleObjectStateException e) {- error("Some one changed the content you are editing. Reload the page and try again.");- target.add(feedback);- }- }-- @Override- protected void onError(AjaxRequestTarget target, Form<?> form) {- super.onError(target, form);- target.add(feedback);- }-- });-- form.add(new AjaxLink<Void>("cancel") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener(form));- }-- @Override- public void onClick(AjaxRequestTarget target) {- CommentReply reply = (CommentReply) row.getDefaultModelObject();- Fragment fragment = renderReply(reply);- row.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- });-- fragment.setOutputMarkupId(true);- row.replace(fragment);- target.add(fragment);- target.add(head);- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- @Override- protected void onConfigure() {- super.onConfigure();-- setVisible(SecurityUtils.canModify(getComment()) && row.get(BODY_ID).get(FORM_ID) == null);- }-- });-- head.add(new AjaxLink<Void>("delete") {-- @Override- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {- super.updateAjaxAttributes(attributes);- attributes.getAjaxCallListeners().add(new ConfirmListener("Do you really want to delete this reply?"));- }-- @Override- public void onClick(AjaxRequestTarget target) {- CommentReply reply = (CommentReply) row.getDefaultModelObject();- reply.delete();- row.remove();- target.appendJavaScript(String.format("$('#%s').remove();", row.getMarkupId()));- send(CommentPanel.this, Broadcast.BUBBLE, new CommentResized(target, getComment()));- }-- @Override- protected void onConfigure() {- super.onConfigure();-- setVisible(SecurityUtils.canModify(getComment()));- }-- });-- head.add(newAdditionalReplyOperations("additionalOperations", (CommentReply) row.getDefaultModelObject()));- head.add(new WebMarkupContainer("permalink").add(AttributeAppender.append("href", "#"+anchorName)));-- row.add(renderReply(reply));-- Date lastVisitDate = getComment().getLastVisitDate();- if (lastVisitDate != null && lastVisitDate.before(reply.getDate())) {- row.add(AttributeAppender.append("class", " new"));- avatarColumn.add(AttributeAppender.append("title", "New reply since your last visit"));- }-- return row;- }-- protected Component newAdditionalCommentOperations(String id, IModel<Comment> comment) {- return new WebMarkupContainer(id).setVisible(false);- }-- protected Component newAdditionalReplyOperations(String id, CommentReply reply) {- return new WebMarkupContainer(id).setVisible(false);- }-- protected Component newActionComponent(String id) {- return new Label(id, "commented");- }-- @Override- protected void onDetach() {- repliesModel.detach();-- super.onDetach();- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);-- response.render(CssHeaderItem.forReference(- new CssResourceReference(CommentPanel.class, "comment.css")));- }--}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentEvent.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentEvent.javaindex c4a7b08895..3b2c33d67e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentEvent.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentEvent.java@@ -3,19 +3,19 @@ package com.pmease.gitplex.web.component.comment.event;import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;import com.pmease.commons.wicket.AjaxEvent;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;public class CommentEvent extends AjaxEvent {- private final Comment comment;+ private final CodeComment comment;- public CommentEvent(IPartialPageRequestHandler partialPageRequestHandlerndler, Comment comment) {+ public CommentEvent(IPartialPageRequestHandler partialPageRequestHandlerndler, CodeComment comment) {super(partialPageRequestHandlerndler);this.comment = comment;}- public Comment getComment() {+ public CodeComment getComment() {return comment;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentRemoved.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentRemoved.javaindex 86eaf776b4..cddb032759 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentRemoved.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentRemoved.java@@ -2,11 +2,11 @@ package com.pmease.gitplex.web.component.comment.event;import org.apache.wicket.ajax.AjaxRequestTarget;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;public class CommentRemoved extends CommentEvent {- public CommentRemoved(AjaxRequestTarget target, Comment comment) {+ public CommentRemoved(AjaxRequestTarget target, CodeComment comment) {super(target, comment);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentResized.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentResized.javaindex 51e818de34..7b614a2c27 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentResized.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/event/CommentResized.java@@ -2,11 +2,11 @@ package com.pmease.gitplex.web.component.comment.event;import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;public class CommentResized extends CommentEvent {- public CommentResized(IPartialPageRequestHandler partialPageRequestHandlerndler, Comment comment) {+ public CommentResized(IPartialPageRequestHandler partialPageRequestHandlerndler, CodeComment comment) {super(partialPageRequestHandlerndler, comment);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.javaindex 8280807d00..72a34e1bb4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/BlobDiffPanel.java@@ -15,7 +15,6 @@ import com.pmease.commons.git.Blob;import com.pmease.commons.git.BlobChange;import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.web.Constants;@@ -33,20 +32,16 @@ public class BlobDiffPanel extends Panel {private final IModel<PullRequest> requestModel;- private final IModel<Comment> commentModel;-private final BlobChange change;private final DiffMode diffMode;public BlobDiffPanel(String id, IModel<Depot> depotModel,- IModel<PullRequest> requestModel, IModel<Comment> commentModel,- BlobChange change, DiffMode diffMode) {+ IModel<PullRequest> requestModel, BlobChange change, DiffMode diffMode) {super(id);this.depotModel = depotModel;this.requestModel = requestModel;- this.commentModel = commentModel;this.change = change;this.diffMode = diffMode;}@@ -74,7 +69,7 @@ public class BlobDiffPanel extends Panel {elseadd(newFragment("Empty file removed.", false));} else {- add(new TextDiffPanel(CONTENT_ID, depotModel, requestModel, commentModel, change, diffMode));+ add(new TextDiffPanel(CONTENT_ID, depotModel, requestModel, change, diffMode));}} else if (blob.isPartial()) {add(newFragment("File is too large to be loaded.", true));@@ -109,7 +104,7 @@ public class BlobDiffPanel extends Panel {} else if (change.getAdditions() + change.getDeletions() == 0) {add(newFragment("Content is identical", false));} else {- add(new TextDiffPanel(CONTENT_ID, depotModel, requestModel, commentModel, change, diffMode));+ add(new TextDiffPanel(CONTENT_ID, depotModel, requestModel, change, diffMode));}} else if (change.getOldBlob().isPartial() || change.getNewBlob().isPartial()) {add(newFragment("File is too large to be loaded.", true));@@ -139,7 +134,6 @@ public class BlobDiffPanel extends Panel {protected void onDetach() {depotModel.detach();requestModel.detach();- commentModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.javaindex 93895486c6..5d06f1505d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/CommentAndPos.java@@ -2,13 +2,13 @@ package com.pmease.gitplex.web.component.diff.blob.text;import java.io.Serializable;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;class CommentAndPos implements Serializable {private static final long serialVersionUID = 1L;- Comment comment;+ CodeComment comment;int oldLineNo;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.javaindex d2a4a06fdd..99b0664931 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java@@ -36,7 +36,7 @@ import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.commons.lang.diff.LineDiff;import com.pmease.commons.lang.tokenizers.CmToken;import com.pmease.commons.util.StringUtils;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.search.hit.QueryHit;@@ -65,7 +65,7 @@ public class TextDiffPanel extends Panel {private final DiffMode diffMode;public TextDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,- IModel<Comment> commentModel, BlobChange change, DiffMode diffMode) {+ BlobChange change, DiffMode diffMode) {super(id);this.depotModel = depotModel;@@ -131,7 +131,7 @@ public class TextDiffPanel extends Panel {int index = params.getParameterValue("index").toInt();Integer lastContextSize = contextSizes.get(index);if (lastContextSize == null)- lastContextSize = Comment.DIFF_CONTEXT_SIZE;+ lastContextSize = CodeComment.DIFF_CONTEXT_SIZE;int contextSize = lastContextSize + Constants.DIFF_EXPAND_SIZE;contextSizes.put(index, contextSize);@@ -234,7 +234,7 @@ public class TextDiffPanel extends Panel {}private String renderDiffs() {- int contextSize = Comment.DIFF_CONTEXT_SIZE;+ int contextSize = CodeComment.DIFF_CONTEXT_SIZE;StringBuilder builder = new StringBuilder();builder.append("<colgroup><col width='40'></col>");if (diffMode == DiffMode.UNIFIED)diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.javaindex ebc9cabf00..2b0b0c8cb3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java@@ -39,7 +39,6 @@ import com.pmease.commons.lang.diff.DiffUtils;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.web.Constants;@@ -53,8 +52,6 @@ public abstract class RevisionDiffPanel extends Panel {private final IModel<PullRequest> requestModel;- private final IModel<Comment> commentModel;-private final String oldRev;private final String newRev;@@ -204,13 +201,12 @@ public abstract class RevisionDiffPanel extends Panel {};public RevisionDiffPanel(String id, IModel<Depot> depotModel, IModel<PullRequest> requestModel,- IModel<Comment> commentModel, String oldRev, String newRev, @Nullable String path,+ String oldRev, String newRev, @Nullable String path,@Nullable String comparePath, LineProcessor lineProcessor, DiffMode diffMode) {super(id);this.depotModel = depotModel;this.requestModel = requestModel;- this.commentModel = commentModel;this.oldRev = oldRev;this.newRev = newRev;this.path = path;@@ -328,7 +324,7 @@ public abstract class RevisionDiffPanel extends Panel {BlobChange change = item.getModelObject();item.setMarkupId("diff-" + change.getPath());item.setOutputMarkupId(true);- item.add(new BlobDiffPanel("change", depotModel, requestModel, commentModel, change, diffMode));+ item.add(new BlobDiffPanel("change", depotModel, requestModel, change, diffMode));}});@@ -347,7 +343,6 @@ public abstract class RevisionDiffPanel extends Panel {changesAndCountModel.detach();depotModel.detach();requestModel.detach();- commentModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewContext.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewContext.javaindex d7dd4984bd..12f204e09d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewContext.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewContext.java@@ -11,7 +11,6 @@ import com.pmease.commons.git.BlobIdent;import com.pmease.commons.lang.extractors.TokenPosition;import com.pmease.commons.wicket.component.menu.MenuItem;import com.pmease.commons.wicket.component.menu.MenuLink;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.search.hit.QueryHit;@@ -26,9 +25,6 @@ public interface BlobViewContext extends Serializable {@NullablePullRequest getPullRequest();- @Nullable- Comment getComment();-BlobIdent getBlobIdent();@Nullablediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.javaindex 5db202595b..1471e0c64c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/markdown/MarkdownRenderer.java@@ -15,8 +15,7 @@ public class MarkdownRenderer implements BlobRenderer {if (context.getBlobIdent().isFile()&& blob.getText() != null&& context.getBlobIdent().path.endsWith(".md")) {- if (context.getMark() != null || context.getMode() == Mode.BLAME- || context.getComment() != null && context.getComment().getBlobIdent().equals(context.getBlobIdent()))+ if (context.getMark() != null || context.getMode() == Mode.BLAME)return new SourceViewPanel(panelId, context, viewState);elsereturn new MarkdownFilePanel(panelId, context);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.javaindex 74b9a8f328..0f49da3628 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/editsave/EditSavePanel.java@@ -42,7 +42,6 @@ import com.pmease.commons.git.exception.ObjectAlreadyExistException;import com.pmease.commons.git.exception.ObsoleteCommitException;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.entity.Account;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.manager.AccountManager;@@ -126,7 +125,7 @@ public abstract class EditSavePanel extends Panel {changedContainer.setOutputMarkupPlaceholderTag(true);if (change != null) {changedContainer.add(new BlobDiffPanel("changes", depotModel,- new Model<PullRequest>(null), new Model<Comment>(null), change, DiffMode.UNIFIED));+ new Model<PullRequest>(null), change, DiffMode.UNIFIED));} else {changedContainer.add(new WebMarkupContainer("changes"));}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.javaindex 7102b92d25..7889dd86d9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/fileedit/FileEditPanel.java@@ -36,7 +36,6 @@ import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.assets.closestdescendant.ClosestDescendantResourceReference;import com.pmease.commons.wicket.assets.codemirror.CodeMirrorResourceReference;import com.pmease.commons.wicket.assets.diffmatchpatch.DiffMatchPatchResourceReference;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.web.component.diff.blob.BlobDiffPanel;@@ -140,7 +139,7 @@ public abstract class FileEditPanel extends Panel {};BlobDiffPanel preview = new BlobDiffPanel("preview", depotModel, new Model<PullRequest>(null),- new Model<Comment>(null), change, DiffMode.UNIFIED);+ change, DiffMode.UNIFIED);replace(preview);target.add(preview);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.javaindex e9392e25e6..5b96b134da 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitDetailPage.java@@ -41,7 +41,6 @@ import com.google.common.base.Preconditions;import com.pmease.commons.git.GitUtils;import com.pmease.commons.wicket.assets.oneline.OnelineResourceReference;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.manager.AuxiliaryManager;@@ -316,7 +315,7 @@ public class CommitDetailPage extends DepotPage {private void newCompareResult(@Nullable AjaxRequestTarget target) {compareResult = new RevisionDiffPanel("compareResult", depotModel,- Model.of((PullRequest)null), Model.of((Comment)null), getCompareWith(),+ Model.of((PullRequest)null), getCompareWith(),getCommit().name(), state.path, state.path, diffOption.getLineProcessor(),diffOption.getDiffMode()) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.javaindex b9edb65874..1543706ed3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/compare/RevisionComparePage.java@@ -38,7 +38,6 @@ import com.pmease.commons.wicket.component.tabbable.AjaxActionTab;import com.pmease.commons.wicket.component.tabbable.Tab;import com.pmease.commons.wicket.component.tabbable.Tabbable;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.component.DepotAndBranch;@@ -48,8 +47,8 @@ import com.pmease.gitplex.web.component.commitlist.CommitListPanel;import com.pmease.gitplex.web.component.diff.revision.RevisionDiffPanel;import com.pmease.gitplex.web.component.diff.revision.option.DiffOptionPanel;import com.pmease.gitplex.web.component.revisionpicker.AffinalRevisionPicker;-import com.pmease.gitplex.web.page.depot.NoCommitsPage;import com.pmease.gitplex.web.page.depot.DepotPage;+import com.pmease.gitplex.web.page.depot.NoCommitsPage;import com.pmease.gitplex.web.page.depot.pullrequest.newrequest.NewRequestPage;import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.RequestDetailPage;import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.overview.RequestOverviewPage;@@ -459,7 +458,7 @@ public class RevisionComparePage extends DepotPage {private void newRevDiffPanel(final WebMarkupContainer tabPanel, @Nullable AjaxRequestTarget target) {RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", depotModel,- new Model<PullRequest>(null), new Model<Comment>(null),+ new Model<PullRequest>(null),compareWithMergeBase?mergeBaseModel.getObject():leftSide.getRevision(),rightSide.getRevision(),StringUtils.isBlank(path)?null:path, null, diffOption.getLineProcessor(),diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.javaindex eb90b1aceb..168b3665ca 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java@@ -57,7 +57,6 @@ import com.pmease.commons.wicket.component.modal.ModalLink;import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior;import com.pmease.commons.wicket.websocket.WebSocketTrait;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.listener.RefListener;@@ -125,28 +124,11 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {private Long requestId;- private Long commentId;-- private final IModel<Comment> commentModel = new LoadableDetachableModel<Comment>() {-- @Override- protected Comment load() {- if (commentId != null)- return GitPlex.getInstance(Dao.class).load(Comment.class, commentId);- else- return null;- }-- };-private final IModel<PullRequest> requestModel = new LoadableDetachableModel<PullRequest>() {@Overrideprotected PullRequest load() {- Comment comment = getComment();- if (comment != null)- return comment.getRequest();- else if (requestId != null)+ if (requestId != null)return GitPlex.getInstance(Dao.class).load(PullRequest.class, requestId);elsereturn null;@@ -180,25 +162,17 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {trait.depotId = getDepot().getId();- commentId = params.get(PARAM_COMMENT).toOptionalLong();blobIdent.revision = params.get(PARAM_REVISION).toString();blobIdent.path = GitUtils.normalizePath(params.get(PARAM_PATH).toString());- Comment comment = commentModel.getObject();- if (comment != null) {- if (blobIdent.revision != null || blobIdent.path != null)- throw new IllegalArgumentException("Revision or path should not be specified if comment is specified");- blobIdent = comment.getBlobIdent();- } else {- requestId = params.get(PARAM_REQUEST).toOptionalLong();-- blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());- if (blobIdent.revision == null)- blobIdent.revision = getDepot().getDefaultBranch();+ requestId = params.get(PARAM_REQUEST).toOptionalLong();++ blobIdent.revision = GitUtils.normalizePath(params.get(PARAM_REVISION).toString());+ if (blobIdent.revision == null)+ blobIdent.revision = getDepot().getDefaultBranch();- if (requestId != null && !GitUtils.isHash(blobIdent.revision))- throw new IllegalArgumentException("Pull request can only be associated with a hash revision");- }+ if (requestId != null && !GitUtils.isHash(blobIdent.revision))+ throw new IllegalArgumentException("Pull request can only be associated with a hash revision");RevCommit commit = getDepot().getRevCommit(blobIdent.revision);trait.commitId = commit.copy();@@ -379,11 +353,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {}}- @Override- public Comment getComment() {- return commentModel.getObject();- }-@Overridepublic PullRequest getPullRequest() {return requestModel.getObject();@@ -607,7 +576,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {private HistoryState getState() {HistoryState state = new HistoryState();state.blobIdent = new BlobIdent(blobIdent);- state.commentId = commentId;state.mark = mark;state.mode = mode;state.requestId = requestId;@@ -616,7 +584,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {private void setState(HistoryState state) {blobIdent = new BlobIdent(state.blobIdent);- commentId = state.commentId;mark = state.mark;mode = state.mode;requestId = state.requestId;@@ -795,7 +762,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {@Overrideprotected void onDetach() {requestModel.detach();- commentModel.detach();super.onDetach();}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.javaindex d4324781da..af32be6164 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.java@@ -44,14 +44,13 @@ import com.pmease.commons.wicket.component.tabbable.Tab;import com.pmease.commons.wicket.component.tabbable.Tabbable;import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior.PageId;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;-import com.pmease.gitplex.core.entity.PullRequestUpdate;-import com.pmease.gitplex.core.entity.ReviewInvitation;-import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.PullRequest.IntegrationStrategy;import com.pmease.gitplex.core.entity.PullRequest.Status;+import com.pmease.gitplex.core.entity.PullRequestUpdate;+import com.pmease.gitplex.core.entity.ReviewInvitation;import com.pmease.gitplex.core.entity.component.CloseInfo;import com.pmease.gitplex.core.entity.component.DepotAndBranch;import com.pmease.gitplex.core.manager.PullRequestManager;@@ -351,8 +350,8 @@ public class NewRequestPage extends PullRequestPage {String oldRev = request.getBaseCommitHash();String newRev = request.getLatestUpdate().getHeadCommitHash();- RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", depotModel, new Model<PullRequest>(null),- new Model<Comment>(null), oldRev, newRev, path, null, diffOption.getLineProcessor(),+ RevisionDiffPanel diffPanel = new RevisionDiffPanel("revisionDiff", depotModel,+ new Model<PullRequest>(null), oldRev, newRev, path, null, diffOption.getLineProcessor(),diffOption.getDiffMode()) {@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.javaindex ce19667b07..0e0c459ba6 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/compare/RequestComparePage.java@@ -36,7 +36,6 @@ import org.apache.wicket.request.resource.CssResourceReference;import com.pmease.commons.git.Commit;import com.pmease.commons.git.GitUtils;-import com.pmease.commons.hibernate.dao.Dao;import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;import com.pmease.commons.wicket.ajaxlistener.IndicateLoadingListener;import com.pmease.commons.wicket.behavior.StickyBehavior;@@ -45,8 +44,7 @@ import com.pmease.commons.wicket.component.floating.AlignPlacement;import com.pmease.commons.wicket.component.floating.FloatingPanel;import com.pmease.commons.wicket.component.menu.MenuItem;import com.pmease.commons.wicket.component.menu.MenuLink;-import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;+import com.pmease.gitplex.core.entity.CodeComment;import com.pmease.gitplex.core.entity.Depot;import com.pmease.gitplex.core.entity.PullRequest;import com.pmease.gitplex.core.entity.PullRequestUpdate;@@ -97,18 +95,6 @@ public class RequestComparePage extends RequestDetailPage {private String comparePath;- private final IModel<Comment> commentModel = new LoadableDetachableModel<Comment>() {-- @Override- protected Comment load() {- if (state.commentId != null)- return GitPlex.getInstance(Dao.class).load(Comment.class, state.commentId);- else- return null;- }-- };-private WebMarkupContainer compareHead;private DiffOptionPanel diffOption;@@ -173,18 +159,10 @@ public class RequestComparePage extends RequestDetailPage {}private void initFromState(HistoryState state) {- Comment comment = commentModel.getObject();- if (comment != null) {- oldCommitHash = comment.getOldCommitHash();- newCommitHash = comment.getNewCommitHash();- path = comment.getBlobIdent().path;- comparePath = comment.getCompareWith().path;- } else {- oldCommitHash = getCommitHash(state.oldRev);- newCommitHash = getCommitHash(state.newRev);- path = state.path;- comparePath = state.comparePath;- }+ oldCommitHash = getCommitHash(state.oldRev);+ newCommitHash = getCommitHash(state.newRev);+ path = state.path;+ comparePath = state.comparePath;}private String getRevision(String commitHash) {@@ -531,16 +509,11 @@ public class RequestComparePage extends RequestDetailPage {@Overridepublic void onDetach() {- commentModel.detach();commitsModel.detach();super.onDetach();}- public static PageParameters paramsOf(Comment comment) {- return paramsOf(comment.getRequest(), comment.getId(), null, null, null, null);- }-public static PageParameters paramsOf(PullRequest request, String oldRev, String newRev) {return paramsOf(request, oldRev, newRev, null);}@@ -574,11 +547,11 @@ public class RequestComparePage extends RequestDetailPage {if (event.getPayload() instanceof CommentRemoved) {CommentRemoved commentRemoved = (CommentRemoved) event.getPayload();- Comment comment = (Comment) commentRemoved.getComment();+ CodeComment comment = (CodeComment) commentRemoved.getComment();// compare identifier instead of comment object as comment may have been deleted// to cause LazyInitializationException- if (Comment.idOf(comment).equals(state.commentId)) {+ if (CodeComment.idOf(comment).equals(state.commentId)) {state.commentId = null;state.oldRev = getRevision(oldCommitHash);state.newRev = getRevision(newCommitHash);@@ -742,7 +715,7 @@ public class RequestComparePage extends RequestDetailPage {private void newCompareResult(@Nullable IPartialPageRequestHandler partialPageRequestHandler) {compareResult = new RevisionDiffPanel("compareResult", depotModel,- requestModel, commentModel, oldCommitHash, newCommitHash, path, comparePath,+ requestModel, oldCommitHash, newCommitHash, path, comparePath,diffOption.getLineProcessor(), diffOption.getDiffMode()) {@Overridediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.javaindex 69fa49e24d..b1cb0c8ba3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java@@ -142,26 +142,6 @@ public class RequestOverviewPage extends RequestDetailPage {elserow.add(AttributeAppender.append("class", " non-update"));- PullRequestManager pullRequestManager = GitPlex.getInstance(PullRequestManager.class);- final Date lastVisitDate = pullRequestManager.getLastVisitDate(getPullRequest());-- row.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {-- @Override- protected String load() {- String cssClasses = "";- RenderableActivity activity = (RenderableActivity) row.getDefaultModelObject();- if (lastVisitDate != null && lastVisitDate.before(activity.getDate()))- cssClasses += " new";- return cssClasses;- }-- }));-- if (lastVisitDate != null && lastVisitDate.before(activity.getDate()))- avatarColumn.add(AttributeAppender.append("title", "New activity since your last visit"));-- RequestCycle.get().setMetaData(RENDERED_ACTIVITY, activity);return row;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/websocket/PullRequestChangeBroadcaster.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/websocket/PullRequestChangeBroadcaster.javaindex 10e0286b7d..c8beeee21d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/websocket/PullRequestChangeBroadcaster.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/websocket/PullRequestChangeBroadcaster.java@@ -9,14 +9,13 @@ import com.pmease.commons.loader.InheritableThreadLocalData;import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior;import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior.PageId;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.Comment;-import com.pmease.gitplex.core.entity.CommentReply;+import com.pmease.gitplex.core.entity.Account;import com.pmease.gitplex.core.entity.PullRequest;+import com.pmease.gitplex.core.entity.PullRequestComment;import com.pmease.gitplex.core.entity.PullRequestUpdate;import com.pmease.gitplex.core.entity.Review;import com.pmease.gitplex.core.entity.ReviewInvitation;import com.pmease.gitplex.core.listener.PullRequestListener;-import com.pmease.gitplex.core.entity.Account;public class PullRequestChangeBroadcaster implements PullRequestListener {@@ -58,7 +57,7 @@ public class PullRequestChangeBroadcaster implements PullRequestListener {}@Override- public void onCommented(Comment comment) {+ public void onCommented(PullRequestComment comment) {onChange(comment.getRequest(), PullRequest.Event.COMMENTED);}@@ -72,11 +71,6 @@ public class PullRequestChangeBroadcaster implements PullRequestListener {onChange(request, PullRequest.Event.ASSIGNED);}- @Override- public void onCommentReplied(CommentReply reply) {- onChange(reply.getComment().getRequest(), PullRequest.Event.COMMENT_REPLIED);- }-private void onChange(PullRequest request, PullRequest.Event event) {/** Make sure that pull request and associated objects are committed before@@ -115,13 +109,9 @@ public class PullRequestChangeBroadcaster implements PullRequestListener {}@Override- public void onMentioned(Comment comment, Account user) {+ public void onMentioned(PullRequestComment comment, Account user) {}- @Override- public void onMentioned(CommentReply reply, Account user) {- }-@Overridepublic void onInvitingReview(ReviewInvitation invitation) {}