RevisionApi: Implement actions() API
Change-Id: I7566c847788d603aef999a6179957ea1d7edd164
This commit is contained in:
parent
bbaea3fb34
commit
eb7d88c1ec
@ -55,7 +55,6 @@ import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
import com.google.gerrit.testutil.TempFileUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@ -455,11 +454,10 @@ public abstract class AbstractDaemonTest {
|
||||
.review(ReviewInput.approve());
|
||||
}
|
||||
|
||||
protected Map<String, ActionInfo> getActions(String changeId) throws Exception {
|
||||
return newGson().fromJson(
|
||||
adminSession.get("/changes/"
|
||||
+ changeId
|
||||
+ "/revisions/1/actions").getReader(),
|
||||
new TypeToken<Map<String, ActionInfo>>() {}.getType());
|
||||
protected Map<String, ActionInfo> getActions(String id) throws Exception {
|
||||
return gApi.changes()
|
||||
.id(id)
|
||||
.revision(1)
|
||||
.actions();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.extensions.common.MergeableInfo;
|
||||
@ -54,6 +55,8 @@ public interface RevisionApi {
|
||||
|
||||
CommentApi comment(String id) throws RestApiException;
|
||||
|
||||
Map<String, ActionInfo> actions() throws RestApiException;
|
||||
|
||||
/**
|
||||
* A default implementation which allows source compatibility
|
||||
* when adding new methods to the interface.
|
||||
@ -163,5 +166,10 @@ public interface RevisionApi {
|
||||
public CommentApi comment(String id) throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ActionInfo> actions() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.extensions.api.changes.RebaseInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.extensions.common.MergeableInfo;
|
||||
@ -40,6 +41,7 @@ import com.google.gerrit.server.change.DeleteDraftPatchSet;
|
||||
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.GetRevisionActions;
|
||||
import com.google.gerrit.server.change.ListComments;
|
||||
import com.google.gerrit.server.change.ListDraftComments;
|
||||
import com.google.gerrit.server.change.Mergeable;
|
||||
@ -87,6 +89,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
private final DraftApiImpl.Factory draftFactory;
|
||||
private final Comments comments;
|
||||
private final CommentApiImpl.Factory commentFactory;
|
||||
private final GetRevisionActions revisionActions;
|
||||
|
||||
@Inject
|
||||
RevisionApiImpl(Changes changes,
|
||||
@ -110,6 +113,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
DraftApiImpl.Factory draftFactory,
|
||||
Comments comments,
|
||||
CommentApiImpl.Factory commentFactory,
|
||||
GetRevisionActions revisionActions,
|
||||
@Assisted RevisionResource r) {
|
||||
this.changes = changes;
|
||||
this.cherryPick = cherryPick;
|
||||
@ -132,6 +136,7 @@ class RevisionApiImpl implements RevisionApi {
|
||||
this.draftFactory = draftFactory;
|
||||
this.comments = comments;
|
||||
this.commentFactory = commentFactory;
|
||||
this.revisionActions = revisionActions;
|
||||
this.revision = r;
|
||||
}
|
||||
|
||||
@ -329,4 +334,9 @@ class RevisionApiImpl implements RevisionApi {
|
||||
throw new RestApiException("Cannot retrieve comment", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ActionInfo> actions() throws RestApiException {
|
||||
return revisionActions.apply(revision).value();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.restapi.ETagView;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
@ -31,6 +32,8 @@ import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class GetRevisionActions implements ETagView<RevisionResource> {
|
||||
private final ActionJson delegate;
|
||||
@ -47,7 +50,7 @@ public class GetRevisionActions implements ETagView<RevisionResource> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(RevisionResource rsrc) {
|
||||
public Response<Map<String, ActionInfo>> apply(RevisionResource rsrc) {
|
||||
return Response.withMustRevalidate(delegate.format(rsrc));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user