Rename Patches to Files and PatchResource to FileResource.

Change-Id: I682f68631a0b00f8180d792373ada05ccb833824
This commit is contained in:
Colby Ranger 2013-05-07 16:18:41 -07:00
parent 700518d140
commit ef38c07162
4 changed files with 21 additions and 21 deletions

View File

@ -20,14 +20,14 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Patch; import com.google.gerrit.reviewdb.client.Patch;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
public class PatchResource implements RestResource { public class FileResource implements RestResource {
public static final TypeLiteral<RestView<PatchResource>> PATCH_KIND = public static final TypeLiteral<RestView<FileResource>> FILE_KIND =
new TypeLiteral<RestView<PatchResource>>() {}; new TypeLiteral<RestView<FileResource>>() {};
private final RevisionResource rev; private final RevisionResource rev;
private final Patch.Key key; private final Patch.Key key;
PatchResource(RevisionResource rev, String name) { FileResource(RevisionResource rev, String name) {
this.rev = rev; this.rev = rev;
this.key = new Patch.Key(rev.getPatchSet().getId(), name); this.key = new Patch.Key(rev.getPatchSet().getId(), name);
} }

View File

@ -23,16 +23,16 @@ import com.google.gerrit.extensions.restapi.RestView;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
class Patches implements ChildCollection<RevisionResource, PatchResource> { class Files implements ChildCollection<RevisionResource, FileResource> {
private final DynamicMap<RestView<PatchResource>> views; private final DynamicMap<RestView<FileResource>> views;
@Inject @Inject
Patches(DynamicMap<RestView<PatchResource>> views) { Files(DynamicMap<RestView<FileResource>> views) {
this.views = views; this.views = views;
} }
@Override @Override
public DynamicMap<RestView<PatchResource>> views() { public DynamicMap<RestView<FileResource>> views() {
return views; return views;
} }
@ -42,8 +42,8 @@ class Patches implements ChildCollection<RevisionResource, PatchResource> {
} }
@Override @Override
public PatchResource parse(RevisionResource rev, IdString id) public FileResource parse(RevisionResource rev, IdString id)
throws ResourceNotFoundException, OrmException, AuthException { throws ResourceNotFoundException, OrmException, AuthException {
return new PatchResource(rev, id.get()); return new FileResource(rev, id.get());
} }
} }

View File

@ -17,7 +17,7 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.server.change.ChangeResource.CHANGE_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.CommentResource.COMMENT_KIND;
import static com.google.gerrit.server.change.DraftResource.DRAFT_KIND; import static com.google.gerrit.server.change.DraftResource.DRAFT_KIND;
import static com.google.gerrit.server.change.PatchResource.PATCH_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.ReviewerResource.REVIEWER_KIND;
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND; import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
@ -35,12 +35,12 @@ public class Module extends RestApiModule {
bind(Reviewers.class); bind(Reviewers.class);
bind(Drafts.class); bind(Drafts.class);
bind(Comments.class); bind(Comments.class);
bind(Patches.class); bind(Files.class);
DynamicMap.mapOf(binder(), CHANGE_KIND); DynamicMap.mapOf(binder(), CHANGE_KIND);
DynamicMap.mapOf(binder(), COMMENT_KIND); DynamicMap.mapOf(binder(), COMMENT_KIND);
DynamicMap.mapOf(binder(), DRAFT_KIND); DynamicMap.mapOf(binder(), DRAFT_KIND);
DynamicMap.mapOf(binder(), PATCH_KIND); DynamicMap.mapOf(binder(), FILE_KIND);
DynamicMap.mapOf(binder(), REVIEWER_KIND); DynamicMap.mapOf(binder(), REVIEWER_KIND);
DynamicMap.mapOf(binder(), REVISION_KIND); DynamicMap.mapOf(binder(), REVISION_KIND);
@ -76,9 +76,9 @@ public class Module extends RestApiModule {
child(REVISION_KIND, "comments").to(Comments.class); child(REVISION_KIND, "comments").to(Comments.class);
get(COMMENT_KIND).to(GetComment.class); get(COMMENT_KIND).to(GetComment.class);
child(REVISION_KIND, "files").to(Patches.class); child(REVISION_KIND, "files").to(Files.class);
put(PATCH_KIND, "reviewed").to(PutReviewed.class); put(FILE_KIND, "reviewed").to(PutReviewed.class);
delete(PATCH_KIND, "reviewed").to(DeleteReviewed.class); delete(FILE_KIND, "reviewed").to(DeleteReviewed.class);
install(new FactoryModule() { install(new FactoryModule() {
@Override @Override

View File

@ -28,7 +28,7 @@ class Reviewed {
static class Input { static class Input {
} }
static class PutReviewed implements RestModifyView<PatchResource, Input> { static class PutReviewed implements RestModifyView<FileResource, Input> {
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
@Inject @Inject
@ -37,7 +37,7 @@ class Reviewed {
} }
@Override @Override
public Object apply(PatchResource resource, Input input) public Object apply(FileResource resource, Input input)
throws OrmException { throws OrmException {
ReviewDb db = dbProvider.get(); ReviewDb db = dbProvider.get();
AccountPatchReview apr = getExisting(db, resource); AccountPatchReview apr = getExisting(db, resource);
@ -52,7 +52,7 @@ class Reviewed {
} }
} }
static class DeleteReviewed implements RestModifyView<PatchResource, Input> { static class DeleteReviewed implements RestModifyView<FileResource, Input> {
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
@Inject @Inject
@ -61,7 +61,7 @@ class Reviewed {
} }
@Override @Override
public Object apply(PatchResource resource, Input input) public Object apply(FileResource resource, Input input)
throws OrmException { throws OrmException {
ReviewDb db = dbProvider.get(); ReviewDb db = dbProvider.get();
AccountPatchReview apr = getExisting(db, resource); AccountPatchReview apr = getExisting(db, resource);
@ -73,7 +73,7 @@ class Reviewed {
} }
private static AccountPatchReview getExisting(ReviewDb db, private static AccountPatchReview getExisting(ReviewDb db,
PatchResource resource) throws OrmException { FileResource resource) throws OrmException {
AccountPatchReview.Key key = new AccountPatchReview.Key( AccountPatchReview.Key key = new AccountPatchReview.Key(
resource.getPatchKey(), resource.getAccountId()); resource.getPatchKey(), resource.getAccountId());
return db.accountPatchReviews().get(key); return db.accountPatchReviews().get(key);