List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder setTimeout
public void setTimeout(int timeout)
From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java
License:Apache License
private void searchFacet(final Search.UserField[] userfields, final String[] userqueries, final int offset, final String[] facetField, final String[] facetValue) { JsonpRequestBuilder rb = new JsonpRequestBuilder(); String query = Search.createQuery(userfields, userqueries, facetField, facetValue); String facets = ""; Iterator it = constants.facets.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); facets += pairs.getKey() + ","; }/*w ww. j av a 2 s. co m*/ facets = facets.substring(0, facets.length() - 1); String searchurl = searchURL(query, 0, false, 1, "_facet.field", facets); rb.setTimeout(100000); rb.requestObject(searchurl, new AsyncCallback<JsModel>() { public void onFailure(Throwable caught) { Util.reportInternalError("Viewing entity", caught); } public void onSuccess(JsModel result) { facetPanel.clear(); Map<String, List<String>> facetsList = ((JsFacet) result).getFacets(); displayFacets(new SearchInput(userfields, userqueries, offset, facetField, facetValue), facetsList); } }); }
From source file:org.dataconservancy.dcs.access.client.presenter.FacetedSearchPresenter.java
License:Apache License
private void getQueryResults(final String searchUrl, final String facets, final SearchInput searchInput, final boolean isAdvanced) { JsonpRequestBuilder rb = new JsonpRequestBuilder(); rb.setTimeout(100000); rb.requestObject(searchUrl, new AsyncCallback<JsModel>() { public void onFailure(Throwable caught) { Util.reportInternalError("Searching", caught); }/* w w w . j a v a2 s .c om*/ public void onSuccess(JsModel result) { displaySearchResults(searchUrl, (JsSearchResult) result, facets, searchInput, isAdvanced); Map<String, List<String>> facetsList = //JsFacet.getFacets(); ((JsFacet) result).getFacets(); displayFacets(searchInput, facetsList); } }); }
From source file:org.openremote.web.console.service.JSONPControllerConnector.java
License:Open Source License
private void doJsonpRequest(String url, JSONPControllerCallback callback, Integer timeout) { JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); if (timeout != null) { jsonp.setTimeout(timeout); }//from w w w . ja v a 2 s.c o m jsonp.requestObject(url, callback); }
From source file:org.thechiselgroup.biomixer.client.workbench.util.url.JsonpUrlFetchService.java
License:Apache License
/** * This is primarily used by the {@link RetryAsyncCallbackErrorHandler} that * this uses internally./*from ww w.ja va2 s . com*/ * * @param url * @param callback * @param previousNumberTries */ public void fetchURL(final String url, final AsyncCallback<String> callback, int previousNumberTries) { JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Could change timeout, but probably better to change retry attempt // number...except that exacerbates server load. Maybe longer timeout is // ok. jsonp.setTimeout(jsonp.getTimeout() * 4); jsonp.requestObject(url, new ErrorHandlingAsyncCallback<JavaScriptObject>( new RetryAsyncCallbackErrorHandler(callback, url, previousNumberTries, this)) { @Override protected void runOnSuccess(JavaScriptObject result) throws Exception { // Had trouble with injection...explicitly creating // instead. ErrorCodeJSONParser errorCodeParser = new ErrorCodeJSONParser(new JsJsonParser()); JSONObject jsonObject = new JSONObject(result); // This JSONObect method changes what appear to be // array entries to be string-integer indexed property // entries. // This happens when an array is presented without // explicit numeric indices. String jsonString = jsonObject.toString(); // Need to check for understood errors in response, such // as 403 forbidden. Integer errorCode = errorCodeParser.parse(jsonString); if (null != errorCode && 500 == errorCode) { // 500 errors don't get here! Caught lower down? // We can retry this once, since I have already seen // cases of very singular failures here. boolean retryAttempted = ((RetryAsyncCallbackErrorHandler) callback).manualRetry(); if (retryAttempted) { return; } // else if (403 == errorCode) { // // This error code, forbidden, is something I // want // // to ignore at the moment. // return; // } } else { // if (null == errorCode) { callback.onSuccess(jsonString); return; } // This wasn't a success, and we got an error code // we don't understand. // Treat as an error for the callback. callback.onFailure(new Exception("Error code, status: " + errorCode + ".")); throw new Exception("Status " + errorCode); } }); }