Remove gwtjsonrpc types from new REST API

Only rely on native GWT supplied interfaces like the GWT version of
AsyncCallback and StatusCodeException. This allows us to later think
about dropping gwtjsonrpc as a project dependency once everything has
been converted and no more JSON-RPC 2.0 interfaces exist.

Given the size of this change, its better to do it before too many
more REST style interfaces are written and depend upon gwtjsonrpc.

Change-Id: I7a9f8b73c3612bf7a55a7ec5f82165f8a5cd7107
This commit is contained in:
Shawn O. Pearce
2012-11-26 22:11:48 -08:00
parent db9d019f30
commit 06bfb9030a
19 changed files with 161 additions and 97 deletions

View File

@@ -24,14 +24,17 @@ import com.google.gerrit.common.errors.NoSuchEntityException;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.common.errors.NotSignedInException;
import com.google.gwt.core.client.GWT;
import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.gwt.user.client.rpc.StatusCodeException;
import com.google.gwtjsonrpc.client.RemoteJsonException;
import com.google.gwtjsonrpc.client.ServerUnavailableException;
import com.google.gwtjsonrpc.common.JsonConstants;
/** Abstract callback handling generic error conditions automatically */
public abstract class GerritCallback<T> implements AsyncCallback<T> {
public abstract class GerritCallback<T> implements
com.google.gwtjsonrpc.common.AsyncCallback<T>,
com.google.gwt.user.client.rpc.AsyncCallback<T> {
public void onFailure(final Throwable caught) {
if (isNotSignedIn(caught) || isInvalidXSRF(caught)) {
new NotSignedInDialog().center();
@@ -76,14 +79,16 @@ public abstract class GerritCallback<T> implements AsyncCallback<T> {
&& caught.getMessage().equals(JsonConstants.ERROR_INVALID_XSRF);
}
private static boolean isNotSignedIn(final Throwable caught) {
return caught instanceof RemoteJsonException
&& caught.getMessage().equals(NotSignedInException.MESSAGE);
private static boolean isNotSignedIn(Throwable caught) {
return RestApi.isNotSignedIn(caught)
|| (caught instanceof RemoteJsonException
&& caught.getMessage().equals(NotSignedInException.MESSAGE));
}
protected static boolean isNoSuchEntity(final Throwable caught) {
return caught instanceof RemoteJsonException
&& caught.getMessage().equals(NoSuchEntityException.MESSAGE);
protected static boolean isNoSuchEntity(Throwable caught) {
return RestApi.isNotFound(caught)
|| (caught instanceof RemoteJsonException
&& caught.getMessage().equals(NoSuchEntityException.MESSAGE));
}
protected static boolean isInactiveAccount(final Throwable caught) {