List of usage examples for com.google.gwt.http.client RequestBuilder RequestBuilder
protected RequestBuilder(String httpMethod, String url)
From source file:org.bonitasoft.console.client.view.DashboardPanel.java
License:Open Source License
/** * @param aResult/*from ww w . j a v a2 s.c om*/ */ protected void displayReport(ReportItem aResult) { try { RequestBuilder theRequestBuilder = new RequestBuilder(RequestBuilder.GET, myReportingDataSource.buildReportURL(aResult, ReportScope.USER)); theRequestBuilder.setCallback(new RequestCallback() { public void onError(Request aRequest, Throwable anException) { if (anException instanceof SessionTimeOutException) { // reload the page. Window.Location.reload(); } myReportHTML.setHTML(""); myOnGoingRequests--; nbOfErrors++; GWT.log("Unable to display report (error count:" + nbOfErrors + ")", anException); if (nbOfErrors >= 3) { GWT.log("Disabling recurrent call after too many consecutive errors.", null); myUpdateTimer.cancel(); } } public void onResponseReceived(Request aRequest, Response aResponse) { if (1 == myOnGoingRequests) { myReportHTML.setHTML(""); if (aResponse.getStatusCode() == Response.SC_OK) { myReportHTML.setHTML(aResponse.getText()); nbOfErrors = 0; } else { myReportHTML.setHTML(constants.unableToDisplayReport()); nbOfErrors++; GWT.log("Unable to display report (error count:" + nbOfErrors + ") " + aResponse.getText(), null); if (nbOfErrors >= 3) { GWT.log("Disabling recurrent call after too many errors.", null); myUpdateTimer.cancel(); } } } else { GWT.log("Skipping report result as there is still " + (myOnGoingRequests - 1) + " requests in the pipe.", null); } myOnGoingRequests--; } }); GWT.log("RPC: querying reporting", null); theRequestBuilder.send(); } catch (RequestException e) { myReportHTML.setHTML(""); } }
From source file:org.bonitasoft.console.client.view.reporting.ReportParametersEditorWidget.java
License:Open Source License
protected void run() { if (validate()) { try {// w w w . j ava 2 s. c o m RequestBuilder theRequestBuilder; final String theURL = myReportDataSource.buildReportURL(myItem, ReportScope.ADMIN); final String theCompleteURL = addParametersToURL(theURL); GWT.log("Calling the reporting engine with query: " + theCompleteURL); theRequestBuilder = new RequestBuilder(RequestBuilder.GET, theCompleteURL); theRequestBuilder.setCallback(new RequestCallback() { public void onError(Request aRequest, Throwable anException) { myReportResultPanel.clear(); myReportResultPanel .add(new HTML(constants.errorProcessingReport() + anException.getMessage())); myDownloadLink.setHref(null); myDownloadLink.setVisible(false); myRefreshLink.setVisible(false); } public void onResponseReceived(Request aRequest, Response aResponse) { myReportResultPanel.clear(); HTML theReport = new HTML(); theReport.setStyleName("bonita_report"); if (aResponse.getStatusCode() == Response.SC_OK) { theReport.setHTML(aResponse.getText()); myDownloadLink.setHref(theCompleteURL + "&OutputFormat=pdf"); myDownloadLink.setVisible(true); myRefreshLink.setVisible(true); } else { theReport.setHTML(constants.unableToDisplayReport() + "<BR/>" + aResponse.getText()); GWT.log("Unable to display report" + aResponse.getText(), null); myDownloadLink.setHref(null); myDownloadLink.setVisible(false); myRefreshLink.setVisible(false); } myReportResultPanel.add(theReport); } }); myReportResultPanel.clear(); myReportResultPanel.add(new HTML(constants.loading())); theRequestBuilder.send(); } catch (RequestException e) { Window.alert("Error while trying to query the reports:" + e.getMessage()); } } }
From source file:org.bonitasoft.console.client.view.reporting.UserStatsView.java
License:Open Source License
private void queryReport(int aRow, int aCol, int aReportIndex) { final RequestBuilder theRequestBuilder; if (aReportIndex < bonitaReports.length) { GWT.log("Calling report generation for: " + bonitaReports[aReportIndex].getUUID().getValue()); try {//from w w w. j av a 2 s.c o m final HTML theCell; if (aCol % 2 == 0) { myCurrentRow = new FlowPanel(); myCurrentRow.setStyleName("reporting_block"); myReportListPanel.add(myCurrentRow); } theCell = new HTML(); theCell.setHTML(myLoadingMessage); theCell.setStyleName("report_item"); myCurrentRow.add(theCell); theRequestBuilder = new RequestBuilder(RequestBuilder.GET, myReportingDataSource.buildReportURL(bonitaReports[aReportIndex], ReportScope.USER)); theRequestBuilder.setCallback(new BonitaReportRequestCallback(aRow, aCol, aReportIndex, theCell)); theRequestBuilder.send(); } catch (RequestException e) { GWT.log("Error while trying to query the reports:" + e.getMessage(), e); } } else { myReloadButton.setVisible(true); } }
From source file:org.bonitasoft.console.client.view.UserSettingsEditionView.java
License:Open Source License
private void buildSelectableReport(final ReportItem aReportItem, final HTML aContainer) { if (aContainer == null) { GWT.log("Container must not be null. Exit.", null); return;/* www . j ava 2 s . com*/ } try { if (aReportItem == null || aReportItem.getFileName() == null || aReportItem.getFileName().length() == 0) { GWT.log("Report name must neither be null nor empty. Exit.", null); return; } if (aReportItem.getUUID().equals(myUserProfile.getDefaultReportUUID()) || (myUserProfile.getDefaultReportUUID() == null && aReportItem.getUUID().equals(ConsoleConstants.DEFAULT_REPORT_UUID))) { // Select the report if it is the one used by the user. selectReportContainer(aContainer); } RequestBuilder theRequestBuilder = new RequestBuilder(RequestBuilder.GET, buildReportURL(aReportItem)); theRequestBuilder.setCallback(new RequestCallback() { public void onError(Request aRequest, Throwable anException) { aContainer.setHTML(constants.unableToDisplayReport()); } public void onResponseReceived(Request aRequest, Response aResponse) { if (aResponse.getStatusCode() == Response.SC_OK) { aContainer.setHTML(aResponse.getText()); } else { aContainer.setHTML(constants.unableToDisplayReport()); } aContainer.addClickHandler(new ClickHandler() { public void onClick(ClickEvent anEvent) { selectReportContainer(aContainer); mySelectedReport = aReportItem; } }); } }); aContainer.setHTML(loadingHTML); theRequestBuilder.send(); } catch (RequestException e) { aContainer.setHTML(constants.unableToDisplayReport()); } }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIAddRequest.java
License:Open Source License
@Override public void run() { this.request = new RequestBuilder(RequestBuilder.POST, this.itemDefinition.getAPIUrl() + "/"); super.run();/*from w w w. j av a 2s . com*/ }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIDeleteRequest.java
License:Open Source License
@Override public void run() { if (this.ids.size() == 0) { throw new APIException("Delete must take at least one id."); } else if (this.ids.size() == 1) { this.request = new RequestBuilder(RequestBuilder.DELETE, this.itemDefinition.getAPIUrl() + "/" + this.ids.get(0)); } else {/* w w w . j a va 2 s. com*/ final UrlBuilder url = new UrlBuilder(this.itemDefinition.getAPIUrl()); String sb = "["; for (int i = 0; i < this.ids.size(); i++) { sb += (i > 0 ? "," : "") + "\"" + this.ids.get(i) + "\""; } sb += "]"; this.request = new RequestBuilder(RequestBuilder.DELETE, url.toString()); this.request.setRequestData(sb); } super.run(); }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIGetRequest.java
License:Open Source License
@Override public void run() { final UrlBuilder url = new UrlBuilder(this.itemDefinition.getAPIUrl() + "/" + this.id.toString()); if (getDeploys() != null && getDeploys().size() > 0) { url.addParameter(PARAMETER_DEPLOY, getDeploys()); }/*from w ww. j a va2s . c om*/ if (getCounters() != null && getCounters().size() > 0) { url.addParameter(PARAMETER_COUNTER, getCounters()); } this.request = new RequestBuilder(RequestBuilder.GET, url.toString()); super.run(); }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APISearchRequest.java
License:Open Source License
@Override public void run() { final UrlBuilder url = new UrlBuilder(this.itemDefinition.getAPIUrl()); url.addParameter(PARAMETER_PAGE, getPage()); url.addParameter(PARAMETER_LIMIT, getResultsPerPage()); if (getOrder() != null && getOrder().length() > 0) { url.addParameter(PARAMETER_ORDER, getOrder()); }/*ww w. j a v a2 s . c o m*/ if (getSearch() != null && getSearch().length() > 0) { url.addParameter(PARAMETER_SEARCH, getSearch()); } if (getFilters() != null && getFilters().size() > 0) { url.addParameter(PARAMETER_FILTER, getFilters()); } if (getDeploys() != null && getDeploys().size() > 0) { url.addParameter(PARAMETER_DEPLOY, getDeploys()); } if (getCounters() != null && getCounters().size() > 0) { url.addParameter(PARAMETER_COUNTER, getCounters()); } this.request = new RequestBuilder(RequestBuilder.GET, url.toString()); super.run(); }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIUpdateRequest.java
License:Open Source License
@Override public void run() { this.request = new RequestBuilder(RequestBuilder.PUT, this.itemDefinition.getAPIUrl() + "/" + this.id); super.run();/*from ww w .j av a2 s. c o m*/ }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.HttpRequest.java
License:Open Source License
/** * Send the HTTP request with data/* w w w . ja v a 2 s . c o m*/ * * @param method * The method to use between RequestBuilder.GET, RequestBuilder.POST, RequestBuilder.PUT, RequestBuilder.DELETE * @param callback * The APICallback to call onSuccess or onError. * @param url * The URL of the API * @param datas * The data to send */ public void send(final Method method, final String url, final String datas, final String contentType, final HttpCallback callback) { final RequestBuilder builder = new RequestBuilder(method, url); if (datas != null) { builder.setRequestData(datas); } if (contentType != null) { builder.setHeader("Content-Type", (contentType != null ? contentType : "text/plain") + ";charset=UTF-8"); } if (UserSessionVariables.getUserVariable(UserSessionVariables.API_TOKEN) != null) { builder.setHeader("X-Bonita-API-Token", UserSessionVariables.getUserVariable(UserSessionVariables.API_TOKEN)); } builder.setTimeoutMillis(30000); builder.setCallback(callback); Request request = null; try { request = builder.send(); } catch (final RequestException e) { callback.onError(request, e); } }