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.inject.TypeLiteral;
public class PatchResource implements RestResource {
public static final TypeLiteral<RestView<PatchResource>> PATCH_KIND =
new TypeLiteral<RestView<PatchResource>>() {};
public class FileResource implements RestResource {
public static final TypeLiteral<RestView<FileResource>> FILE_KIND =
new TypeLiteral<RestView<FileResource>>() {};
private final RevisionResource rev;
private final Patch.Key key;
PatchResource(RevisionResource rev, String name) {
FileResource(RevisionResource rev, String name) {
this.rev = rev;
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.inject.Inject;
class Patches implements ChildCollection<RevisionResource, PatchResource> {
private final DynamicMap<RestView<PatchResource>> views;
class Files implements ChildCollection<RevisionResource, FileResource> {
private final DynamicMap<RestView<FileResource>> views;
@Inject
Patches(DynamicMap<RestView<PatchResource>> views) {
Files(DynamicMap<RestView<FileResource>> views) {
this.views = views;
}
@Override
public DynamicMap<RestView<PatchResource>> views() {
public DynamicMap<RestView<FileResource>> views() {
return views;
}
@ -42,8 +42,8 @@ class Patches implements ChildCollection<RevisionResource, PatchResource> {
}
@Override
public PatchResource parse(RevisionResource rev, IdString id)
public FileResource parse(RevisionResource rev, IdString id)
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.CommentResource.COMMENT_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.RevisionResource.REVISION_KIND;
@ -35,12 +35,12 @@ public class Module extends RestApiModule {
bind(Reviewers.class);
bind(Drafts.class);
bind(Comments.class);
bind(Patches.class);
bind(Files.class);
DynamicMap.mapOf(binder(), CHANGE_KIND);
DynamicMap.mapOf(binder(), COMMENT_KIND);
DynamicMap.mapOf(binder(), DRAFT_KIND);
DynamicMap.mapOf(binder(), PATCH_KIND);
DynamicMap.mapOf(binder(), FILE_KIND);
DynamicMap.mapOf(binder(), REVIEWER_KIND);
DynamicMap.mapOf(binder(), REVISION_KIND);
@ -76,9 +76,9 @@ public class Module extends RestApiModule {
child(REVISION_KIND, "comments").to(Comments.class);
get(COMMENT_KIND).to(GetComment.class);
child(REVISION_KIND, "files").to(Patches.class);
put(PATCH_KIND, "reviewed").to(PutReviewed.class);
delete(PATCH_KIND, "reviewed").to(DeleteReviewed.class);
child(REVISION_KIND, "files").to(Files.class);
put(FILE_KIND, "reviewed").to(PutReviewed.class);
delete(FILE_KIND, "reviewed").to(DeleteReviewed.class);
install(new FactoryModule() {
@Override

View File

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