Package com.google.gerrit.server
Class CommentsUtil
- java.lang.Object
-
- com.google.gerrit.server.CommentsUtil
-
public class CommentsUtil extends Object
Utility functions to manipulate Comments.These methods either query for and update Comments in the NoteDb or ReviewDb, depending on the state of the NotesMigration.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.Ordering<CommentInfo>
COMMENT_INFO_ORDER
static com.google.common.collect.Ordering<Comment>
COMMENT_ORDER
-
Method Summary
-
-
-
Field Detail
-
COMMENT_ORDER
public static final com.google.common.collect.Ordering<Comment> COMMENT_ORDER
-
COMMENT_INFO_ORDER
public static final com.google.common.collect.Ordering<CommentInfo> COMMENT_INFO_ORDER
-
-
Method Detail
-
getCommentPsId
public static PatchSet.Id getCommentPsId(Change.Id changeId, Comment comment)
-
newComment
public Comment newComment(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, Boolean unresolved, String parentUuid) throws com.google.gwtorm.server.OrmException, UnprocessableEntityException
- Throws:
com.google.gwtorm.server.OrmException
UnprocessableEntityException
-
newRobotComment
public RobotComment newRobotComment(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, String robotId, String robotRunId)
-
getPublished
public Optional<Comment> getPublished(ReviewDb db, ChangeNotes notes, Comment.Key key) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
getDraft
public Optional<Comment> getDraft(ReviewDb db, ChangeNotes notes, IdentifiedUser user, Comment.Key key) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
publishedByChange
public List<Comment> publishedByChange(ReviewDb db, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
robotCommentsByChange
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
draftByChange
public List<Comment> draftByChange(ReviewDb db, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
byPatchSet
public List<Comment> byPatchSet(ReviewDb db, ChangeNotes notes, PatchSet.Id psId) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
publishedByChangeFile
public List<Comment> publishedByChangeFile(ReviewDb db, ChangeNotes notes, Change.Id changeId, String file) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
publishedByPatchSet
public List<Comment> publishedByPatchSet(ReviewDb db, ChangeNotes notes, PatchSet.Id psId) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
robotCommentsByPatchSet
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
draftByPatchSetAuthor
public List<Comment> draftByPatchSetAuthor(ReviewDb db, PatchSet.Id psId, Account.Id author, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
draftByChangeFileAuthor
public List<Comment> draftByChangeFileAuthor(ReviewDb db, ChangeNotes notes, String file, Account.Id author) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
draftByChangeAuthor
public List<Comment> draftByChangeAuthor(ReviewDb db, ChangeNotes notes, Account.Id author) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
putComments
public void putComments(ReviewDb db, ChangeUpdate update, PatchLineComment.Status status, Iterable<Comment> comments) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
putRobotComments
public void putRobotComments(ChangeUpdate update, Iterable<RobotComment> comments)
-
deleteComments
public void deleteComments(ReviewDb db, ChangeUpdate update, Iterable<Comment> comments) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
deleteCommentByRewritingHistory
public void deleteCommentByRewritingHistory(ReviewDb db, ChangeUpdate update, Comment.Key commentKey, PatchSet.Id psId, String newMessage) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
deleteAllDraftsFromAllUsers
public void deleteAllDraftsFromAllUsers(Change.Id changeId) throws IOException
- Throws:
IOException
-
setCommentRevId
public static void setCommentRevId(Comment c, PatchListCache cache, Change change, PatchSet ps) throws PatchListNotAvailableException
- Throws:
PatchListNotAvailableException
-
getDraftRefs
public Collection<org.eclipse.jgit.lib.Ref> getDraftRefs(Change.Id changeId) throws com.google.gwtorm.server.OrmException
Get NoteDb draft refs for a change.Works if NoteDb is not enabled, but the results are not meaningful.
This is just a simple ref scan, so the results may potentially include refs for zombie draft comments. A zombie draft is one which has been published but the write to delete the draft ref from All-Users failed.
- Parameters:
changeId
- change ID.- Returns:
- raw refs from All-Users repo.
- Throws:
com.google.gwtorm.server.OrmException
-
toPatchLineComments
public static Iterable<PatchLineComment> toPatchLineComments(Change.Id changeId, PatchLineComment.Status status, Iterable<Comment> comments)
-
toComments
public static List<Comment> toComments(String serverId, Iterable<PatchLineComment> comments)
-
-