Remove old DeleteDraftChange RPC

Change-Id: I77f1cb57123922aa519eddbeda3b6b9fa44ea559
This commit is contained in:
David Ostrovsky
2013-12-06 22:33:42 +01:00
parent 0561211396
commit d0a4fea342
5 changed files with 16 additions and 90 deletions

View File

@@ -20,7 +20,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwtjsonrpc.common.AsyncCallback; import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.RemoteJsonService; import com.google.gwtjsonrpc.common.RemoteJsonService;
import com.google.gwtjsonrpc.common.RpcImpl; import com.google.gwtjsonrpc.common.RpcImpl;
import com.google.gwtjsonrpc.common.VoidResult;
import com.google.gwtjsonrpc.common.RpcImpl.Version; import com.google.gwtjsonrpc.common.RpcImpl.Version;
@RpcImpl(version = Version.V2_0) @RpcImpl(version = Version.V2_0)
@@ -29,10 +28,6 @@ public interface ChangeManageService extends RemoteJsonService {
@SignInRequired @SignInRequired
void publish(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback); void publish(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback);
@Audit
@SignInRequired
void deleteDraftChange(PatchSet.Id patchSetId, AsyncCallback<VoidResult> callback);
@Audit @Audit
@SignInRequired @SignInRequired
void rebaseChange(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback); void rebaseChange(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback);

View File

@@ -55,7 +55,6 @@ import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel; import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
import com.google.gwtjsonrpc.common.VoidResult;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -479,18 +478,22 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
@Override @Override
public void onClick(final ClickEvent event) { public void onClick(final ClickEvent event) {
b.setEnabled(false); b.setEnabled(false);
Util.MANAGE_SVC.deleteDraftChange(patchSet.getId(), ChangeApi.deleteChange(patchSet.getId().getParentKey().get(),
new GerritCallback<VoidResult>() { new GerritCallback<JavaScriptObject>() {
public void onSuccess(VoidResult result) { public void onSuccess(JavaScriptObject result) {
Gerrit.display(PageLinks.MINE); Gerrit.display(PageLinks.MINE);
} }
@Override public void onFailure(Throwable err) {
public void onFailure(Throwable caught) { if (SubmitFailureDialog.isConflict(err)) {
b.setEnabled(true); new SubmitFailureDialog(err.getMessage()).center();
super.onFailure(caught); Gerrit.display(PageLinks.MINE);
} } else {
}); b.setEnabled(true);
super.onFailure(err);
}
}
});
} }
}); });
actionsPanel.add(b); actionsPanel.add(b);

View File

@@ -18,22 +18,18 @@ import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.ChangeManageService; import com.google.gerrit.common.data.ChangeManageService;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwtjsonrpc.common.AsyncCallback; import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.VoidResult;
import com.google.inject.Inject; import com.google.inject.Inject;
class ChangeManageServiceImpl implements ChangeManageService { class ChangeManageServiceImpl implements ChangeManageService {
private final RebaseChangeHandler.Factory rebaseChangeFactory; private final RebaseChangeHandler.Factory rebaseChangeFactory;
private final PublishAction.Factory publishAction; private final PublishAction.Factory publishAction;
private final DeleteDraftChange.Factory deleteDraftChangeFactory;
@Inject @Inject
ChangeManageServiceImpl( ChangeManageServiceImpl(
final RebaseChangeHandler.Factory rebaseChangeFactory, final RebaseChangeHandler.Factory rebaseChangeFactory,
final PublishAction.Factory publishAction, final PublishAction.Factory publishAction) {
final DeleteDraftChange.Factory deleteDraftChangeFactory) {
this.rebaseChangeFactory = rebaseChangeFactory; this.rebaseChangeFactory = rebaseChangeFactory;
this.publishAction = publishAction; this.publishAction = publishAction;
this.deleteDraftChangeFactory = deleteDraftChangeFactory;
} }
public void rebaseChange(final PatchSet.Id patchSetId, public void rebaseChange(final PatchSet.Id patchSetId,
@@ -45,9 +41,4 @@ class ChangeManageServiceImpl implements ChangeManageService {
final AsyncCallback<ChangeDetail> callback) { final AsyncCallback<ChangeDetail> callback) {
publishAction.create(patchSetId).to(callback); publishAction.create(patchSetId).to(callback);
} }
public void deleteDraftChange(final PatchSet.Id patchSetId,
final AsyncCallback<VoidResult> callback) {
deleteDraftChangeFactory.create(patchSetId).to(callback);
}
} }

View File

@@ -34,7 +34,6 @@ public class ChangeModule extends RpcServletModule {
factory(PatchSetDetailFactory.Factory.class); factory(PatchSetDetailFactory.Factory.class);
factory(PatchSetPublishDetailFactory.Factory.class); factory(PatchSetPublishDetailFactory.Factory.class);
factory(PublishAction.Factory.class); factory(PublishAction.Factory.class);
factory(DeleteDraftChange.Factory.class);
} }
}); });
rpc(ChangeDetailServiceImpl.class); rpc(ChangeDetailServiceImpl.class);

View File

@@ -1,62 +0,0 @@
// Copyright (C) 2011 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.httpd.rpc.Handler;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ChangeUtil;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gwtjsonrpc.common.VoidResult;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.io.IOException;
class DeleteDraftChange extends Handler<VoidResult> {
interface Factory {
DeleteDraftChange create(PatchSet.Id patchSetId);
}
private final ChangeControl.Factory changeControlFactory;
private final ReviewDb db;
private final ChangeUtil changeUtil;
private final PatchSet.Id patchSetId;
@Inject
DeleteDraftChange(ReviewDb db,
ChangeControl.Factory changeControlFactory,
ChangeUtil changeUtil,
@Assisted PatchSet.Id patchSetId) {
this.changeControlFactory = changeControlFactory;
this.db = db;
this.changeUtil = changeUtil;
this.patchSetId = patchSetId;
}
@Override
public VoidResult call() throws NoSuchChangeException, OrmException, IOException {
Change.Id changeId = patchSetId.getParentKey();
ChangeControl control = changeControlFactory.validateFor(changeId);
if (!control.canDeleteDraft(db)) {
throw new NoSuchChangeException(changeId);
}
changeUtil.deleteDraftChange(patchSetId);
return VoidResult.INSTANCE;
}
}