Support GET, PUT, DELETE on /changes/{id}/topic
The topic is now modified by REST API calls against /topic. The web UI uses PUT to alter the topic with a JSON payload, but the server accepts quite a few different REST forms that clients can easily send. Change-Id: Ia5edbb232bc288acdad8b145956ad275d170629a
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.changedetail;
|
||||
|
||||
import com.google.gerrit.common.data.ChangeDetail;
|
||||
import com.google.gerrit.common.errors.NoSuchEntityException;
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.changedetail.AlterTopic;
|
||||
import com.google.gerrit.server.mail.EmailException;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class AlterTopicHandler extends Handler<ChangeDetail> {
|
||||
|
||||
interface Factory {
|
||||
AlterTopicHandler create(@Assisted Change.Id changeId,
|
||||
@Assisted("topic") String topic,
|
||||
@Assisted("message") @Nullable String message);
|
||||
}
|
||||
|
||||
private final Provider<AlterTopic> alterTopicProvider;
|
||||
private final ChangeDetailFactory.Factory changeDetailFactory;
|
||||
|
||||
private final Change.Id changeId;
|
||||
private final String topic;
|
||||
@Nullable
|
||||
private final String message;
|
||||
|
||||
@Inject
|
||||
AlterTopicHandler(final Provider<AlterTopic> alterTopicProvider,
|
||||
final ChangeDetailFactory.Factory changeDetailFactory,
|
||||
@Assisted final Change.Id changeId,
|
||||
@Assisted("topic") final String topic,
|
||||
@Assisted("message") @Nullable final String message) {
|
||||
this.alterTopicProvider = alterTopicProvider;
|
||||
this.changeDetailFactory = changeDetailFactory;
|
||||
|
||||
this.changeId = changeId;
|
||||
this.topic = topic;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeDetail call() throws EmailException, IOException,
|
||||
NoSuchChangeException, NoSuchEntityException, OrmException,
|
||||
PatchSetInfoNotAvailableException, RepositoryNotFoundException,
|
||||
InvalidChangeOperationException {
|
||||
final AlterTopic alterTopic = alterTopicProvider.get();
|
||||
alterTopic.setChangeId(changeId);
|
||||
alterTopic.setTopic(topic);
|
||||
alterTopic.setMessage(message);
|
||||
alterTopic.call();
|
||||
return changeDetailFactory.create(changeId).call();
|
||||
}
|
||||
}
|
||||
@@ -30,19 +30,16 @@ class ChangeDetailServiceImpl implements ChangeDetailService {
|
||||
private final IncludedInDetailFactory.Factory includedInDetail;
|
||||
private final PatchSetDetailFactory.Factory patchSetDetail;
|
||||
private final PatchSetPublishDetailFactory.Factory patchSetPublishDetail;
|
||||
private final AlterTopicHandler.Factory alterTopic;
|
||||
|
||||
@Inject
|
||||
ChangeDetailServiceImpl(final ChangeDetailFactory.Factory changeDetail,
|
||||
final IncludedInDetailFactory.Factory includedInDetail,
|
||||
final PatchSetDetailFactory.Factory patchSetDetail,
|
||||
final PatchSetPublishDetailFactory.Factory patchSetPublishDetail,
|
||||
final AlterTopicHandler.Factory alterTopic) {
|
||||
final PatchSetPublishDetailFactory.Factory patchSetPublishDetail) {
|
||||
this.changeDetail = changeDetail;
|
||||
this.includedInDetail = includedInDetail;
|
||||
this.patchSetDetail = patchSetDetail;
|
||||
this.patchSetPublishDetail = patchSetPublishDetail;
|
||||
this.alterTopic = alterTopic;
|
||||
}
|
||||
|
||||
public void changeDetail(final Change.Id id,
|
||||
@@ -69,9 +66,4 @@ class ChangeDetailServiceImpl implements ChangeDetailService {
|
||||
final AsyncCallback<PatchSetPublishDetail> callback) {
|
||||
patchSetPublishDetail.create(id).to(callback);
|
||||
}
|
||||
|
||||
public void alterTopic(final Change.Id id, final String topic,
|
||||
final String message, final AsyncCallback<ChangeDetail> callback) {
|
||||
alterTopic.create(id, topic, message).to(callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class ChangeModule extends RpcServletModule {
|
||||
install(new FactoryModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
factory(AlterTopicHandler.Factory.class);
|
||||
factory(RestoreChangeHandler.Factory.class);
|
||||
factory(RevertChange.Factory.class);
|
||||
factory(RebaseChangeHandler.Factory.class);
|
||||
|
||||
Reference in New Issue
Block a user