use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class PurgeMondrianSchemaCacheCommand method performOperation.
protected void performOperation() {
String url = GWT.getHostPageBaseURL() + "api/system/refresh/mondrianSchemaCache";
RequestBuilder requestBuilder = new CsrfRequestBuilder(RequestBuilder.GET, url);
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
requestBuilder.setHeader("accept", "text/plain");
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), Messages.getString("mondrianSchemaCacheFlushedSuccessfully"), false, false, true);
dialogBox.center();
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
// showError(e);
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class RefreshMetaDataCommand method performOperation.
protected void performOperation() {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/system/refresh/metadata";
RequestBuilder requestBuilder = new CsrfRequestBuilder(RequestBuilder.GET, url);
requestBuilder.setHeader("accept", "text/plain");
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
MessageDialogBox dialogBox = // $NON-NLS-1$
new MessageDialogBox(Messages.getString("info"), response.getText(), true, false, true);
dialogBox.center();
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
// showError(e);
}
}
use of com.google.gwt.http.client.RequestCallback in project libgdx by libgdx.
the class GwtNet method sendHttpRequest.
@Override
public void sendHttpRequest(final HttpRequest httpRequest, final HttpResponseListener httpResultListener) {
if (httpRequest.getUrl() == null) {
httpResultListener.failed(new GdxRuntimeException("can't process a HTTP request without URL set"));
return;
}
final String method = httpRequest.getMethod();
final String value = httpRequest.getContent();
final boolean valueInBody = method.equalsIgnoreCase(HttpMethods.POST) || method.equals(HttpMethods.PUT);
RequestBuilder builder;
String url = httpRequest.getUrl();
if (method.equalsIgnoreCase(HttpMethods.GET)) {
if (value != null) {
url += "?" + value;
}
builder = new RequestBuilder(RequestBuilder.GET, url);
} else if (method.equalsIgnoreCase(HttpMethods.POST)) {
builder = new RequestBuilder(RequestBuilder.POST, url);
} else if (method.equalsIgnoreCase(HttpMethods.DELETE)) {
if (value != null) {
url += "?" + value;
}
builder = new RequestBuilder(RequestBuilder.DELETE, url);
} else if (method.equalsIgnoreCase(HttpMethods.PUT)) {
builder = new RequestBuilder(RequestBuilder.PUT, url);
} else {
throw new GdxRuntimeException("Unsupported HTTP Method");
}
Map<String, String> content = httpRequest.getHeaders();
Set<String> keySet = content.keySet();
for (String name : keySet) {
builder.setHeader(name, content.get(name));
}
builder.setTimeoutMillis(httpRequest.getTimeOut());
builder.setIncludeCredentials(httpRequest.getIncludeCredentials());
try {
Request request = builder.sendRequest(valueInBody ? value : null, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
httpResultListener.handleHttpResponse(new HttpClientResponse(response));
requests.remove(httpRequest);
listeners.remove(httpRequest);
}
@Override
public void onError(Request request, Throwable exception) {
httpResultListener.failed(exception);
requests.remove(httpRequest);
listeners.remove(httpRequest);
}
});
requests.put(httpRequest, request);
listeners.put(httpRequest, httpResultListener);
} catch (Throwable e) {
httpResultListener.failed(e);
}
}
use of com.google.gwt.http.client.RequestCallback 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.RequestCallback in project opennms by OpenNMS.
the class Application method initializeNav.
private void initializeNav() {
m_chartService.getAllLocations(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
m_nav.loadLocations(ChartUtils.convertJSONToLocationList(response.getText()));
}
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert("An error occured loading the locations");
}
});
m_chartService.getAllParticipants(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
m_nav.loadHosts(ChartUtils.convertJSONToParticipants(response.getText()));
}
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert("An error occured loading participants");
}
});
}
Aggregations