Rename comment-related classes to reduce confusion
Change the names to include "Comment", to make it clear that they are related to draft comments rather than changes or anything else. Change-Id: Ie9c82b2fab6797c6e69a97394a5ad1d36cfdb6ec
This commit is contained in:
@@ -18,10 +18,10 @@ import com.google.gerrit.extensions.api.changes.DraftApi;
|
||||
import com.google.gerrit.extensions.api.changes.DraftInput;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.change.DeleteDraft;
|
||||
import com.google.gerrit.server.change.DraftResource;
|
||||
import com.google.gerrit.server.change.GetDraft;
|
||||
import com.google.gerrit.server.change.PutDraft;
|
||||
import com.google.gerrit.server.change.DeleteDraftComment;
|
||||
import com.google.gerrit.server.change.DraftCommentResource;
|
||||
import com.google.gerrit.server.change.GetDraftComment;
|
||||
import com.google.gerrit.server.change.PutDraftComment;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -30,19 +30,19 @@ import java.io.IOException;
|
||||
|
||||
class DraftApiImpl implements DraftApi {
|
||||
interface Factory {
|
||||
DraftApiImpl create(DraftResource d);
|
||||
DraftApiImpl create(DraftCommentResource d);
|
||||
}
|
||||
|
||||
private final DeleteDraft deleteDraft;
|
||||
private final GetDraft getDraft;
|
||||
private final PutDraft putDraft;
|
||||
private final DraftResource draft;
|
||||
private final DeleteDraftComment deleteDraft;
|
||||
private final GetDraftComment getDraft;
|
||||
private final PutDraftComment putDraft;
|
||||
private final DraftCommentResource draft;
|
||||
|
||||
@Inject
|
||||
DraftApiImpl(DeleteDraft deleteDraft,
|
||||
GetDraft getDraft,
|
||||
PutDraft putDraft,
|
||||
@Assisted DraftResource draft) {
|
||||
DraftApiImpl(DeleteDraftComment deleteDraft,
|
||||
GetDraftComment getDraft,
|
||||
PutDraftComment putDraft,
|
||||
@Assisted DraftCommentResource draft) {
|
||||
this.deleteDraft = deleteDraft;
|
||||
this.getDraft = getDraft;
|
||||
this.putDraft = putDraft;
|
||||
|
@@ -34,13 +34,13 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.change.CherryPick;
|
||||
import com.google.gerrit.server.change.Comments;
|
||||
import com.google.gerrit.server.change.CreateDraft;
|
||||
import com.google.gerrit.server.change.CreateDraftComment;
|
||||
import com.google.gerrit.server.change.DeleteDraftPatchSet;
|
||||
import com.google.gerrit.server.change.Drafts;
|
||||
import com.google.gerrit.server.change.DraftComments;
|
||||
import com.google.gerrit.server.change.FileResource;
|
||||
import com.google.gerrit.server.change.Files;
|
||||
import com.google.gerrit.server.change.ListComments;
|
||||
import com.google.gerrit.server.change.ListDrafts;
|
||||
import com.google.gerrit.server.change.ListDraftComments;
|
||||
import com.google.gerrit.server.change.Mergeable;
|
||||
import com.google.gerrit.server.change.PostReview;
|
||||
import com.google.gerrit.server.change.Publish;
|
||||
@@ -80,9 +80,9 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
||||
private final Provider<Mergeable> mergeable;
|
||||
private final FileApiImpl.Factory fileApi;
|
||||
private final ListComments listComments;
|
||||
private final ListDrafts listDrafts;
|
||||
private final CreateDraft createDraft;
|
||||
private final Drafts drafts;
|
||||
private final ListDraftComments listDrafts;
|
||||
private final CreateDraftComment createDraft;
|
||||
private final DraftComments drafts;
|
||||
private final DraftApiImpl.Factory draftFactory;
|
||||
private final Comments comments;
|
||||
private final CommentApiImpl.Factory commentFactory;
|
||||
@@ -103,9 +103,9 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
||||
Provider<Mergeable> mergeable,
|
||||
FileApiImpl.Factory fileApi,
|
||||
ListComments listComments,
|
||||
ListDrafts listDrafts,
|
||||
CreateDraft createDraft,
|
||||
Drafts drafts,
|
||||
ListDraftComments listDrafts,
|
||||
CreateDraftComment createDraft,
|
||||
DraftComments drafts,
|
||||
DraftApiImpl.Factory draftFactory,
|
||||
Comments comments,
|
||||
CommentApiImpl.Factory commentFactory,
|
||||
|
@@ -42,7 +42,7 @@ import java.sql.Timestamp;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class CreateDraft implements RestModifyView<RevisionResource, DraftInput> {
|
||||
public class CreateDraftComment implements RestModifyView<RevisionResource, DraftInput> {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeUpdate.Factory updateFactory;
|
||||
private final CommentJson commentJson;
|
||||
@@ -50,7 +50,7 @@ public class CreateDraft implements RestModifyView<RevisionResource, DraftInput>
|
||||
private final PatchListCache patchListCache;
|
||||
|
||||
@Inject
|
||||
CreateDraft(Provider<ReviewDb> db,
|
||||
CreateDraftComment(Provider<ReviewDb> db,
|
||||
ChangeUpdate.Factory updateFactory,
|
||||
CommentJson commentJson,
|
||||
PatchLineCommentsUtil plcUtil,
|
@@ -22,7 +22,7 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.PatchLineCommentsUtil;
|
||||
import com.google.gerrit.server.change.DeleteDraft.Input;
|
||||
import com.google.gerrit.server.change.DeleteDraftComment.Input;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -34,7 +34,7 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class DeleteDraft implements RestModifyView<DraftResource, Input> {
|
||||
public class DeleteDraftComment implements RestModifyView<DraftCommentResource, Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DeleteDraft implements RestModifyView<DraftResource, Input> {
|
||||
private final PatchListCache patchListCache;
|
||||
|
||||
@Inject
|
||||
DeleteDraft(Provider<ReviewDb> db,
|
||||
DeleteDraftComment(Provider<ReviewDb> db,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
ChangeUpdate.Factory updateFactory,
|
||||
PatchListCache patchListCache) {
|
||||
@@ -55,7 +55,7 @@ public class DeleteDraft implements RestModifyView<DraftResource, Input> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<CommentInfo> apply(DraftResource rsrc, Input input)
|
||||
public Response<CommentInfo> apply(DraftCommentResource rsrc, Input input)
|
||||
throws OrmException, IOException {
|
||||
ChangeUpdate update = updateFactory.create(rsrc.getControl());
|
||||
|
@@ -24,14 +24,14 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
public class DraftResource implements RestResource {
|
||||
public static final TypeLiteral<RestView<DraftResource>> DRAFT_KIND =
|
||||
new TypeLiteral<RestView<DraftResource>>() {};
|
||||
public class DraftCommentResource implements RestResource {
|
||||
public static final TypeLiteral<RestView<DraftCommentResource>> DRAFT_COMMENT_KIND =
|
||||
new TypeLiteral<RestView<DraftCommentResource>>() {};
|
||||
|
||||
private final RevisionResource rev;
|
||||
private final PatchLineComment comment;
|
||||
|
||||
DraftResource(RevisionResource rev, PatchLineComment c) {
|
||||
DraftCommentResource(RevisionResource rev, PatchLineComment c) {
|
||||
this.rev = rev;
|
||||
this.comment = c;
|
||||
}
|
@@ -30,17 +30,17 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
||||
private final DynamicMap<RestView<DraftResource>> views;
|
||||
public class DraftComments implements ChildCollection<RevisionResource, DraftCommentResource> {
|
||||
private final DynamicMap<RestView<DraftCommentResource>> views;
|
||||
private final Provider<CurrentUser> user;
|
||||
private final ListDrafts list;
|
||||
private final ListDraftComments list;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final PatchLineCommentsUtil plcUtil;
|
||||
|
||||
@Inject
|
||||
Drafts(DynamicMap<RestView<DraftResource>> views,
|
||||
DraftComments(DynamicMap<RestView<DraftCommentResource>> views,
|
||||
Provider<CurrentUser> user,
|
||||
ListDrafts list,
|
||||
ListDraftComments list,
|
||||
Provider<ReviewDb> dbProvider,
|
||||
PatchLineCommentsUtil plcUtil) {
|
||||
this.views = views;
|
||||
@@ -51,7 +51,7 @@ public class Drafts implements ChildCollection<RevisionResource, DraftResource>
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicMap<RestView<DraftResource>> views() {
|
||||
public DynamicMap<RestView<DraftCommentResource>> views() {
|
||||
return views;
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ public class Drafts implements ChildCollection<RevisionResource, DraftResource>
|
||||
}
|
||||
|
||||
@Override
|
||||
public DraftResource parse(RevisionResource rev, IdString id)
|
||||
public DraftCommentResource parse(RevisionResource rev, IdString id)
|
||||
throws ResourceNotFoundException, OrmException, AuthException {
|
||||
checkIdentifiedUser();
|
||||
String uuid = id.get();
|
||||
for (PatchLineComment c : plcUtil.draftByPatchSetAuthor(dbProvider.get(),
|
||||
rev.getPatchSet().getId(), rev.getAccountId(), rev.getNotes())) {
|
||||
if (uuid.equals(c.getKey().get())) {
|
||||
return new DraftResource(rev, c);
|
||||
return new DraftCommentResource(rev, c);
|
||||
}
|
||||
}
|
||||
throw new ResourceNotFoundException(id);
|
@@ -21,17 +21,17 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetDraft implements RestReadView<DraftResource> {
|
||||
public class GetDraftComment implements RestReadView<DraftCommentResource> {
|
||||
|
||||
private final CommentJson commentJson;
|
||||
|
||||
@Inject
|
||||
GetDraft(CommentJson commentJson) {
|
||||
GetDraftComment(CommentJson commentJson) {
|
||||
this.commentJson = commentJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommentInfo apply(DraftResource rsrc) throws OrmException {
|
||||
public CommentInfo apply(DraftCommentResource rsrc) throws OrmException {
|
||||
return commentJson.format(rsrc.getComment());
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class ListComments extends ListDrafts {
|
||||
public class ListComments extends ListDraftComments {
|
||||
@Inject
|
||||
ListComments(Provider<ReviewDb> db,
|
||||
CommentJson commentJson,
|
||||
|
@@ -28,13 +28,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class ListDrafts implements RestReadView<RevisionResource> {
|
||||
public class ListDraftComments implements RestReadView<RevisionResource> {
|
||||
protected final Provider<ReviewDb> db;
|
||||
protected CommentJson commentJson;
|
||||
protected final PatchLineCommentsUtil plcUtil;
|
||||
|
||||
@Inject
|
||||
ListDrafts(Provider<ReviewDb> db,
|
||||
ListDraftComments(Provider<ReviewDb> db,
|
||||
CommentJson commentJson,
|
||||
PatchLineCommentsUtil plcUtil) {
|
||||
this.db = db;
|
@@ -17,7 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import static com.google.gerrit.server.change.ChangeEditResource.CHANGE_EDIT_KIND;
|
||||
import static com.google.gerrit.server.change.ChangeResource.CHANGE_KIND;
|
||||
import static com.google.gerrit.server.change.CommentResource.COMMENT_KIND;
|
||||
import static com.google.gerrit.server.change.DraftResource.DRAFT_KIND;
|
||||
import static com.google.gerrit.server.change.DraftCommentResource.DRAFT_COMMENT_KIND;
|
||||
import static com.google.gerrit.server.change.FileResource.FILE_KIND;
|
||||
import static com.google.gerrit.server.change.ReviewerResource.REVIEWER_KIND;
|
||||
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
|
||||
@@ -35,13 +35,13 @@ public class Module extends RestApiModule {
|
||||
bind(ChangesCollection.class);
|
||||
bind(Revisions.class);
|
||||
bind(Reviewers.class);
|
||||
bind(Drafts.class);
|
||||
bind(DraftComments.class);
|
||||
bind(Comments.class);
|
||||
bind(Files.class);
|
||||
|
||||
DynamicMap.mapOf(binder(), CHANGE_KIND);
|
||||
DynamicMap.mapOf(binder(), COMMENT_KIND);
|
||||
DynamicMap.mapOf(binder(), DRAFT_KIND);
|
||||
DynamicMap.mapOf(binder(), DRAFT_COMMENT_KIND);
|
||||
DynamicMap.mapOf(binder(), FILE_KIND);
|
||||
DynamicMap.mapOf(binder(), REVIEWER_KIND);
|
||||
DynamicMap.mapOf(binder(), REVISION_KIND);
|
||||
@@ -90,11 +90,11 @@ public class Module extends RestApiModule {
|
||||
post(REVISION_KIND, "test.submit_type").to(TestSubmitType.class);
|
||||
get(REVISION_KIND, "archive").to(GetArchive.class);
|
||||
|
||||
child(REVISION_KIND, "drafts").to(Drafts.class);
|
||||
put(REVISION_KIND, "drafts").to(CreateDraft.class);
|
||||
get(DRAFT_KIND).to(GetDraft.class);
|
||||
put(DRAFT_KIND).to(PutDraft.class);
|
||||
delete(DRAFT_KIND).to(DeleteDraft.class);
|
||||
child(REVISION_KIND, "drafts").to(DraftComments.class);
|
||||
put(REVISION_KIND, "drafts").to(CreateDraftComment.class);
|
||||
get(DRAFT_COMMENT_KIND).to(GetDraftComment.class);
|
||||
put(DRAFT_COMMENT_KIND).to(PutDraftComment.class);
|
||||
delete(DRAFT_COMMENT_KIND).to(DeleteDraftComment.class);
|
||||
|
||||
child(REVISION_KIND, "comments").to(Comments.class);
|
||||
get(COMMENT_KIND).to(GetComment.class);
|
||||
|
@@ -39,18 +39,18 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutDraft implements RestModifyView<DraftResource, DraftInput> {
|
||||
public class PutDraftComment implements RestModifyView<DraftCommentResource, DraftInput> {
|
||||
|
||||
private final Provider<ReviewDb> db;
|
||||
private final DeleteDraft delete;
|
||||
private final DeleteDraftComment delete;
|
||||
private final PatchLineCommentsUtil plcUtil;
|
||||
private final ChangeUpdate.Factory updateFactory;
|
||||
private final CommentJson commentJson;
|
||||
private final PatchListCache patchListCache;
|
||||
|
||||
@Inject
|
||||
PutDraft(Provider<ReviewDb> db,
|
||||
DeleteDraft delete,
|
||||
PutDraftComment(Provider<ReviewDb> db,
|
||||
DeleteDraftComment delete,
|
||||
PatchLineCommentsUtil plcUtil,
|
||||
ChangeUpdate.Factory updateFactory,
|
||||
CommentJson commentJson,
|
||||
@@ -64,7 +64,7 @@ public class PutDraft implements RestModifyView<DraftResource, DraftInput> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<CommentInfo> apply(DraftResource rsrc, DraftInput in) throws
|
||||
public Response<CommentInfo> apply(DraftCommentResource rsrc, DraftInput in) throws
|
||||
BadRequestException, OrmException, IOException {
|
||||
PatchLineComment c = rsrc.getComment();
|
||||
ChangeUpdate update = updateFactory.create(rsrc.getControl());
|
@@ -127,7 +127,7 @@ public class CommentsTest {
|
||||
|
||||
@Inject private AllUsersNameProvider allUsers;
|
||||
@Inject private Comments comments;
|
||||
@Inject private Drafts drafts;
|
||||
@Inject private DraftComments drafts;
|
||||
@Inject private GetComment getComment;
|
||||
@Inject private IdentifiedUser.GenericFactory userFactory;
|
||||
@Inject private InMemoryRepositoryManager repoManager;
|
||||
@@ -142,10 +142,10 @@ public class CommentsTest {
|
||||
final TypeLiteral<DynamicMap<RestView<CommentResource>>> commentViewsType =
|
||||
new TypeLiteral<DynamicMap<RestView<CommentResource>>>() {};
|
||||
@SuppressWarnings("unchecked")
|
||||
final DynamicMap<RestView<DraftResource>> draftViews =
|
||||
final DynamicMap<RestView<DraftCommentResource>> draftViews =
|
||||
createMock(DynamicMap.class);
|
||||
final TypeLiteral<DynamicMap<RestView<DraftResource>>> draftViewsType =
|
||||
new TypeLiteral<DynamicMap<RestView<DraftResource>>>() {};
|
||||
final TypeLiteral<DynamicMap<RestView<DraftCommentResource>>> draftViewsType =
|
||||
new TypeLiteral<DynamicMap<RestView<DraftCommentResource>>>() {};
|
||||
|
||||
final AccountLoader.Factory alf =
|
||||
createMock(AccountLoader.Factory.class);
|
||||
|
Reference in New Issue
Block a user