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();
}
}
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);
}
}
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);
}
}
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);
}
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();
}
}
Aggregations