Standardize REST endpoints for getting changes
The /detail and /review endpoints are practically identical to the standard change endpoint except for the default set of options. Make this equivalence explicit in the code by delegating to a GetChange instance from the other handlers. This change naturally gets caching for the other endpoints as well. Allow specifying options on /change/X; prior to this, users could add options to the default set from /detail but could not remove options. Change-Id: I03bb96141e79ae00359f8d5ec51413d1b27204dc
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestResource;
|
||||
import com.google.gerrit.extensions.restapi.RestResource.HasETag;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -23,7 +24,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
public class RevisionResource implements RestResource {
|
||||
public class RevisionResource implements RestResource, HasETag {
|
||||
public static final TypeLiteral<RestView<RevisionResource>> REVISION_KIND =
|
||||
new TypeLiteral<RestView<RevisionResource>>() {};
|
||||
|
||||
@@ -56,6 +57,14 @@ public class RevisionResource implements RestResource {
|
||||
return ps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getETag() {
|
||||
// Conservative estimate: refresh the revision if its parent change has
|
||||
// changed, so we don't have to check whether a given modification affected
|
||||
// this revision specifically.
|
||||
return change.getETag();
|
||||
}
|
||||
|
||||
Account.Id getAccountId() {
|
||||
return getUser().getAccountId();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user