Search in sources :

Example 81 with RequestException

use of com.google.gwt.http.client.RequestException in project kie-wb-common by kiegroup.

the class FooterPresenter method setupUrl.

void setupUrl(final String url) {
    final Command onSuccess = makeOnSuccess(url);
    final Command onError = makeOnError();
    try {
        makeRequest(url, onSuccess, onError).send();
    } catch (final RequestException e) {
        onError.execute();
    }
}
Also used : Command(org.uberfire.mvp.Command) RequestException(com.google.gwt.http.client.RequestException)

Example 82 with RequestException

use of com.google.gwt.http.client.RequestException in project gerrit by GerritCodeReview.

the class RestApi method sendText.

private <T extends JavaScriptObject> void sendText(Method method, String body, HttpCallback<T> cb) {
    HttpImpl<T> httpCallback = new HttpImpl<>(background, cb);
    try {
        if (!background) {
            RpcStatus.INSTANCE.onRpcStart();
        }
        RequestBuilder req = request(method);
        req.setHeader("Content-Type", TEXT_UTF8);
        req.sendRequest(body, httpCallback);
    } catch (RequestException e) {
        httpCallback.onError(null, e);
    }
}
Also used : GWT(com.google.gwt.core.client.GWT) PUT(com.google.gwt.http.client.RequestBuilder.PUT) POST(com.google.gwt.http.client.RequestBuilder.POST) GET(com.google.gwt.http.client.RequestBuilder.GET) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException)

Example 83 with RequestException

use of com.google.gwt.http.client.RequestException in project gerrit by GerritCodeReview.

the class RestApi method sendJSON.

private <T extends JavaScriptObject> void sendJSON(Method method, JavaScriptObject content, HttpCallback<T> cb) {
    HttpImpl<T> httpCallback = new HttpImpl<>(background, cb);
    try {
        if (!background) {
            RpcStatus.INSTANCE.onRpcStart();
        }
        RequestBuilder req = request(method);
        req.setHeader("Content-Type", JSON_UTF8);
        req.sendRequest(str(content), httpCallback);
    } catch (RequestException e) {
        httpCallback.onError(null, e);
    }
}
Also used : GWT(com.google.gwt.core.client.GWT) PUT(com.google.gwt.http.client.RequestBuilder.PUT) POST(com.google.gwt.http.client.RequestBuilder.POST) GET(com.google.gwt.http.client.RequestBuilder.GET) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException)

Example 84 with RequestException

use of com.google.gwt.http.client.RequestException in project gerrit by GerritCodeReview.

the class NewAgreementScreen method showCLA.

private void showCLA(AgreementInfo cla) {
    current = cla;
    String url = cla.url();
    if (url != null && url.length() > 0) {
        agreementGroup.setVisible(true);
        agreementHtml.setText(Gerrit.C.rpcStatusWorking());
        if (!url.startsWith("http:") && !url.startsWith("https:")) {
            url = GWT.getHostPageBaseURL() + url;
        }
        final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
        rb.setCallback(new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                new ErrorDialog(exception).center();
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                final String ct = response.getHeader("Content-Type");
                if (response.getStatusCode() == 200 && ct != null && (ct.equals("text/html") || ct.startsWith("text/html;"))) {
                    agreementHtml.setHTML(response.getText());
                } else {
                    new ErrorDialog(response.getStatusText()).center();
                }
            }
        });
        try {
            rb.send();
        } catch (RequestException e) {
            new ErrorDialog(e).show();
        }
    } else {
        agreementGroup.setVisible(false);
    }
    finalGroup.setVisible(cla.autoVerifyGroup() != null);
    yesIAgreeBox.setText("");
    submit.setEnabled(false);
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) ErrorDialog(com.google.gerrit.client.ErrorDialog) NativeString(com.google.gerrit.client.rpc.NativeString) RequestException(com.google.gwt.http.client.RequestException)

Example 85 with RequestException

use of com.google.gwt.http.client.RequestException in project opennms by OpenNMS.

the class DefaultChartService method sendRequest.

private void sendRequest(String url, RequestCallback callback) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
    builder.setHeader("Accept", "application/json");
    builder.setUser("ipv6Rest");
    builder.setPassword("ipv6Rest");
    try {
        builder.sendRequest(null, callback);
    } catch (RequestException e) {
        e.printStackTrace();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

RequestException (com.google.gwt.http.client.RequestException)162 RequestCallback (com.google.gwt.http.client.RequestCallback)155 Response (com.google.gwt.http.client.Response)154 Request (com.google.gwt.http.client.Request)153 RequestBuilder (com.google.gwt.http.client.RequestBuilder)106 JSONException (com.google.gwt.json.client.JSONException)55 HttpException (com.willshex.gson.web.service.client.HttpException)55 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)17 BlockUsersRequest (com.willshex.blogwt.shared.api.user.call.BlockUsersRequest)12 BlockUsersResponse (com.willshex.blogwt.shared.api.user.call.BlockUsersResponse)12 ChangePasswordRequest (com.willshex.blogwt.shared.api.user.call.ChangePasswordRequest)12 ChangePasswordResponse (com.willshex.blogwt.shared.api.user.call.ChangePasswordResponse)12 ChangeUserAccessRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessRequest)12 ChangeUserAccessResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessResponse)12 ChangeUserDetailsRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsRequest)12 ChangeUserDetailsResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsResponse)12 CheckUsernameRequest (com.willshex.blogwt.shared.api.user.call.CheckUsernameRequest)12 CheckUsernameResponse (com.willshex.blogwt.shared.api.user.call.CheckUsernameResponse)12 FollowUsersRequest (com.willshex.blogwt.shared.api.user.call.FollowUsersRequest)12 FollowUsersResponse (com.willshex.blogwt.shared.api.user.call.FollowUsersResponse)12