List of usage examples for com.google.gwt.http.client Response SC_BAD_REQUEST
int SC_BAD_REQUEST
To view the source code for com.google.gwt.http.client Response SC_BAD_REQUEST.
Click Source Link
From source file:com.google.gerrit.client.account.MyGpgKeysScreen.java
License:Apache License
private void doAddKey() { if (keyText.getText().isEmpty()) { return;/*from w w w . j a v a 2 s . co m*/ } addButton.setEnabled(false); keyText.setEnabled(false); AccountApi.addGpgKey("self", keyText.getText(), new AsyncCallback<NativeMap<GpgKeyInfo>>() { @Override public void onSuccess(NativeMap<GpgKeyInfo> result) { keyText.setEnabled(true); refreshKeys(); } @Override public void onFailure(Throwable caught) { keyText.setEnabled(true); addButton.setEnabled(true); if (caught instanceof StatusCodeException) { StatusCodeException sce = (StatusCodeException) caught; if (sce.getStatusCode() == Response.SC_CONFLICT || sce.getStatusCode() == Response.SC_BAD_REQUEST) { errorText.setText(sce.getEncodedResponse()); } else { errorText.setText(sce.getMessage()); } } else { errorText.setText("Unexpected error saving key: " + caught.getMessage()); } errorPanel.setVisible(true); } }); }
From source file:com.google.gwt.sample.healthyeatingapp.client.FacebookGraph.java
private void QueryGraph(String id, Method method, String params, final Callback<JSONObject, Throwable> callback) { final String requestData = "access_token=" + token + (params != null ? "&" + params : ""); RequestBuilder builder;/* w w w . j av a2 s. c om*/ if (method == RequestBuilder.POST) { builder = new RequestBuilder(method, "https://graph.facebook.com/" + id); builder.setHeader("Content-Type", "application/x-www-form-urlencoded"); } else if (method == RequestBuilder.GET) { builder = new RequestBuilder(method, "https://graph.facebook.com/" + id + "?" + requestData); } else { callback.onFailure(new IOException("doGraph only supports GET and POST requests")); return; } try { builder.sendRequest(requestData, new RequestCallback() { public void onError(Request request, Throwable exception) { callback.onFailure(exception); } public void onResponseReceived(Request request, Response response) { if (Response.SC_OK == response.getStatusCode()) { callback.onSuccess(JSONParser.parseStrict(response.getText()).isObject()); } else if (Response.SC_BAD_REQUEST == response.getStatusCode()) { callback.onFailure(new IOException("Error: " + response.getText())); } else { callback.onFailure( new IOException("Couldn't retrieve JSON (" + response.getStatusText() + ")")); } } }); } catch (RequestException e) { callback.onFailure(e); } }
From source file:de.spartusch.nasfvi.client.MainWidget.java
License:Apache License
@Override public final void onResponseReceived(final Request request, final Response response) { int sc = response.getStatusCode(); String respText = response.getText(); if (sc == Response.SC_OK) { NResponse nresp = NResponse.parse(respText); if (nresp.isSuccess()) { hints.setOpen(false);/*from www. j a v a 2 s . c o m*/ NResponseWidget widget = new NResponseWidget(nresp, this); responsePanel.setWidget(widget); } else { setMessage("Ihre Anfrage wurde verstanden und verarbeitet." + " Doch das Vorlesungsverzeichnis enthlt keine Daten" + " zur Beantwortung der Anfrage.", null); } } else if (sc == Response.SC_BAD_REQUEST) { setMessage("Die Anfrage konnte nicht verarbeitet werden." + " Bitte formulieren Sie um!", "error"); } else { Main.displayError(response.getStatusText(), respText); } }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
private void asyncGetJson(final String url, final GotJsonCallback callback) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try {//from w w w . ja va2 s . c o m builder.sendRequest(null, new RequestCallback() { public void onError(final Request request, final Throwable e) { displayError("Failed to get " + url + ": " + e.getMessage()); // Since we don't call the callback we've been given, reset this // bit of state as we're not going to retry anything right now. pending_requests = 0; } public void onResponseReceived(final Request request, final Response response) { final int code = response.getStatusCode(); if (code == Response.SC_OK) { clearError(); callback.got(JSONParser.parse(response.getText())); return; } else if (code >= Response.SC_BAD_REQUEST) { // 400+ => Oops. // Since we don't call the callback we've been given, reset this // bit of state as we're not going to retry anything right now. pending_requests = 0; String err = response.getText(); // If the response looks like a JSON object, it probably contains // an error message. if (!err.isEmpty() && err.charAt(0) == '{') { final JSONValue json = JSONParser.parse(err); final JSONObject result = json == null ? null : json.isObject(); final JSONValue jerr = result == null ? null : result.get("err"); final JSONString serr = jerr == null ? null : jerr.isString(); err = serr.stringValue(); // If the error message has multiple lines (which is common if // it contains a stack trace), show only the first line and // hide the rest in a panel users can expand. final int newline = err.indexOf('\n', 1); final String msg = "Request failed: " + response.getStatusText(); if (newline < 0) { displayError(msg + ": " + err); } else { displayError(msg); final DisclosurePanel dp = new DisclosurePanel(err.substring(0, newline)); RootPanel.get("queryuimain").add(dp); // Attach the widget. final InlineLabel content = new InlineLabel(err.substring(newline, err.length())); content.addStyleName("fwf"); // For readable stack traces. dp.setContent(content); current_error.getElement().appendChild(dp.getElement()); } } else { displayError("Request failed while getting " + url + ": " + response.getStatusText()); // Since we don't call the callback we've been given, reset this // bit of state as we're not going to retry anything right now. pending_requests = 0; } graphstatus.setText(""); } } }); } catch (RequestException e) { displayError("Failed to get " + url + ": " + e.getMessage()); } }
From source file:org.bonitasoft.console.client.user.process.action.ProcessInstantiationCallbackBehavior.java
License:Open Source License
public void onError(final String responseContent, final int errorCode) { if (errorCode == Response.SC_BAD_REQUEST) { GWT.log("Error while instantiating process : " + responseContent); final String errorMessage = _( "Error while trying to start the case. Some required information is missing (contract not fulfilled)."); ViewController.closePopup();/*ww w . j ava2 s . co m*/ showError(errorMessage); } else if (errorCode == Response.SC_UNAUTHORIZED) { Window.Location.reload(); } else { showError(_("Error while trying to start the case.")); } }
From source file:org.obiba.opal.web.gwt.app.client.administration.identifiers.presenter.CopySystemIdentifiersModalPresenter.java
License:Open Source License
@Override public void onSubmit(TableDto selection) { if (!validationHandler.validate()) return;/* www. j a va 2 s. c o m*/ GWT.log(selection.getDatasourceName() + " " + table.getName()); getView().setBusy(true); String uri = UriBuilder.create().segment("identifiers", "mappings", "entities", "_sync") .query("datasource", selection.getDatasourceName(), "table", selection.getName()).build(); ResourceRequestBuilderFactory.newBuilder().forResource(uri) // .post() // .withCallback(new ResponseCodeCallback() { @Override public void onResponseCode(Request request, Response response) { getView().setBusy(false); if (response.getStatusCode() == Response.SC_OK) { getView().hide(); fireEvent(new IdentifiersTableSelectionEvent.Builder().dto(table).build()); } else { getView().showError(response.getText(), null); } } }, Response.SC_BAD_REQUEST, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_OK).send(); }
From source file:org.obiba.opal.web.gwt.app.client.administration.identifiers.presenter.GenerateIdentifiersModalPresenter.java
License:Open Source License
public void initialize(VariableDto variable, final TableDto table) { this.variable = variable; this.table = table; String prefix = variable.getName().toUpperCase() + "-"; getView().setDefault(10, prefix);//from w w w . j a v a 2 s . co m UriBuilder ub = UriBuilder.create().segment("identifiers", "mapping", "{}", "_count").query("type", table.getEntityType()); ResourceRequestBuilderFactory.newBuilder().forResource(ub.build(variable.getName())).get()// .withCallback(new ResponseCodeCallback() { @Override public void onResponseCode(Request request, Response response) { try { getView().setAffectedEntities( table.getValueSetCount() - Integer.parseInt(response.getText())); } catch (Exception e) { GWT.log("Unable to get identifiers mapping count: " + e.getMessage()); } } }, Response.SC_OK, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_NOT_FOUND, Response.SC_BAD_REQUEST) .send(); }
From source file:org.obiba.opal.web.gwt.app.client.administration.identifiers.presenter.IdentifiersMappingModalPresenter.java
License:Open Source License
public void onUpdate(VariableDto updatedVariable) { UriBuilder uriBuilder = UriBuilders.IDENTIFIERS_TABLE_VARIABLE.create(); ResourceRequestBuilderFactory.newBuilder() .forResource(uriBuilder.build(tableDto.getName(), variable.getName())) // .put() // .withResourceBody(VariableDto.stringify(updatedVariable)) // .withCallback(new VariableUpdateCallback(updatedVariable), Response.SC_BAD_REQUEST, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_OK) .send();// ww w. ja va 2s . c o m }
From source file:org.obiba.opal.web.gwt.app.client.administration.identifiers.presenter.IdentifiersMappingModalPresenter.java
License:Open Source License
public void doCreate(VariableDto newVariable) { UriBuilder uriBuilder;//from www . j a va2 s.c o m uriBuilder = UriBuilders.IDENTIFIERS_TABLE_VARIABLES.create(); ResourceRequestBuilderFactory.newBuilder().forResource(uriBuilder.build(tableDto.getName())) // .post() // .withResourceBody("[" + VariableDto.stringify(newVariable) + "]") // .withCallback(new VariableCreateCallback(newVariable), Response.SC_BAD_REQUEST, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_OK) .send(); }
From source file:org.obiba.opal.web.gwt.app.client.administration.identifiers.presenter.IdentifiersTableModalPresenter.java
License:Open Source License
public void doCreate(TableDto newTable) { ResourceRequestBuilderFactory.newBuilder().forResource(UriBuilders.IDENTIFIERS_TABLES.create().build()) // .post() // .withResourceBody(TableDto.stringify(newTable)) // .withCallback(new TableCreateCallback(newTable), Response.SC_BAD_REQUEST, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_CREATED) .send();// ww w.j av a2s. c o m }