Add setHashtags method on the change API

Change-Id: I4653857e3266d673f7d04e063da5324f880e5cba
This commit is contained in:
David Pursehouse 2014-09-16 12:25:38 +09:00
parent 9d56774ade
commit f4b48cc997
2 changed files with 24 additions and 0 deletions

View File

@ -85,6 +85,11 @@ public interface ChangeApi {
/** {@code get} with {@link ListChangesOption} set to NONE. */
ChangeInfo info() throws RestApiException;
/**
* Set hashtags on a change
**/
void setHashtags(HashtagsInput input) throws RestApiException;
/**
* A default implementation which allows source compatibility
* when adding new methods to the interface.
@ -174,5 +179,10 @@ public interface ChangeApi {
public ChangeInfo info() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setHashtags(HashtagsInput input) throws RestApiException {
throw new NotImplementedException();
}
}
}

View File

@ -19,6 +19,7 @@ import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.Changes;
import com.google.gerrit.extensions.api.changes.HashtagsInput;
import com.google.gerrit.extensions.api.changes.RestoreInput;
import com.google.gerrit.extensions.api.changes.RevertInput;
import com.google.gerrit.extensions.api.changes.RevisionApi;
@ -30,6 +31,7 @@ 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.PostHashtags;
import com.google.gerrit.server.change.PostReviewers;
import com.google.gerrit.server.change.PutTopic;
import com.google.gerrit.server.change.Restore;
@ -59,6 +61,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
private final PutTopic putTopic;
private final Provider<PostReviewers> postReviewers;
private final Provider<ChangeJson> changeJson;
private final PostHashtags postHashtags;
@Inject
ChangeApiImpl(Changes changeApi,
@ -71,6 +74,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
PutTopic putTopic,
Provider<PostReviewers> postReviewers,
Provider<ChangeJson> changeJson,
PostHashtags postHashtags,
@Assisted ChangeResource change) {
this.changeApi = changeApi;
this.revert = revert;
@ -82,6 +86,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
this.putTopic = putTopic;
this.postReviewers = postReviewers;
this.changeJson = changeJson;
this.postHashtags = postHashtags;
this.change = change;
}
@ -204,4 +209,13 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
public ChangeInfo info() throws RestApiException {
return get(EnumSet.noneOf(ListChangesOption.class));
}
@Override
public void setHashtags(HashtagsInput input) throws RestApiException {
try {
postHashtags.apply(change, input);
} catch (IOException | OrmException e) {
throw new RestApiException("Cannot post hashtags", e);
}
}
}