ChangeApi: Implement get/put topic
Change-Id: I8e76f05d52f486b85cb905f7a4bff95966faae79
This commit is contained in:
@@ -29,7 +29,9 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.change.Abandon;
|
||||
import com.google.gerrit.server.change.ChangeJson;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.change.GetTopic;
|
||||
import com.google.gerrit.server.change.PostReviewers;
|
||||
import com.google.gerrit.server.change.PutTopic;
|
||||
import com.google.gerrit.server.change.Restore;
|
||||
import com.google.gerrit.server.change.Revert;
|
||||
import com.google.gerrit.server.change.Revisions;
|
||||
@@ -53,6 +55,8 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
||||
private final Abandon abandon;
|
||||
private final Revert revert;
|
||||
private final Restore restore;
|
||||
private final GetTopic getTopic;
|
||||
private final PutTopic putTopic;
|
||||
private final Provider<PostReviewers> postReviewers;
|
||||
private final Provider<ChangeJson> changeJson;
|
||||
|
||||
@@ -63,6 +67,8 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
||||
Abandon abandon,
|
||||
Revert revert,
|
||||
Restore restore,
|
||||
GetTopic getTopic,
|
||||
PutTopic putTopic,
|
||||
Provider<PostReviewers> postReviewers,
|
||||
Provider<ChangeJson> changeJson,
|
||||
@Assisted ChangeResource change) {
|
||||
@@ -72,6 +78,8 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
||||
this.revisionApi = revisionApi;
|
||||
this.abandon = abandon;
|
||||
this.restore = restore;
|
||||
this.getTopic = getTopic;
|
||||
this.putTopic = putTopic;
|
||||
this.postReviewers = postReviewers;
|
||||
this.changeJson = changeJson;
|
||||
this.change = change;
|
||||
@@ -144,6 +152,22 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String topic() throws RestApiException {
|
||||
return getTopic.apply(change);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topic(String topic) throws RestApiException {
|
||||
PutTopic.Input in = new PutTopic.Input();
|
||||
in.topic = topic;
|
||||
try {
|
||||
putTopic.apply(change, in);
|
||||
} catch (OrmException | IOException e) {
|
||||
throw new RestApiException("Cannot set topic", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReviewer(String reviewer) throws RestApiException {
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
|
@@ -19,7 +19,7 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetTopic implements RestReadView<ChangeResource> {
|
||||
public class GetTopic implements RestReadView<ChangeResource> {
|
||||
@Override
|
||||
public String apply(ChangeResource rsrc) {
|
||||
return Strings.nullToEmpty(rsrc.getChange().getTopic());
|
||||
|
@@ -42,7 +42,7 @@ import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
|
||||
@Singleton
|
||||
class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
UiAction<ChangeResource> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeIndexer indexer;
|
||||
@@ -50,9 +50,9 @@ class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
private final ChangeUpdate.Factory updateFactory;
|
||||
private final ChangeMessagesUtil cmUtil;
|
||||
|
||||
static class Input {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
String topic;
|
||||
public String topic;
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
Reference in New Issue
Block a user