List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:org.pentaho.ui.database.event.DataHandler.java
License:Open Source License
private void setDefaultPoolParameters() { RequestBuilder poolingParamsBuilder = new RequestBuilder(RequestBuilder.GET, getBaseURL() + "poolingParameters"); //$NON-NLS-1$ try {/*from w ww . j a v a2 s . com*/ poolingParamsBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { showMessage(messages.getString("DataHandler.ERROR_MESSAGE_TITLE"), exception.getMessage(), //$NON-NLS-1$ exception.getMessage().length() > 300); } @Override public void onResponseReceived(Request request, Response response) { Boolean success = response.getStatusCode() == Response.SC_OK; if (success) { AutoBean<IDatabaseConnectionPoolParameterList> bean = AutoBeanCodex.decode( connectionAutoBeanFactory, IDatabaseConnectionPoolParameterList.class, response.getText()); final IDatabaseConnectionPoolParameterList paramListWrapper = bean.as(); poolingParameters = new DatabaseConnectionPoolParameter[paramListWrapper .getDatabaseConnectionPoolParameters().size()]; GwtLayoutHandler.deferUpdateUI(poolParameterTree, new Command() { @Override public void execute() { if (poolParameterTree != null) { int i = 0; for (IDatabaseConnectionPoolParameter parameter : paramListWrapper .getDatabaseConnectionPoolParameters()) { XulTreeRow row = poolParameterTree.getRootChildren().addNewRow(); row.addCellText(0, "false"); //$NON-NLS-1$ row.addCellText(1, parameter.getParameter()); row.addCellText(2, parameter.getDefaultValue()); poolingParameters[i] = new DatabaseConnectionPoolParameter( parameter.getParameter(), parameter.getDefaultValue(), parameter.getDescription()); i++; } // HACK: reDim the pooling table poolParameterTree.setRows(poolParameterTree.getRows()); } } }); } } }); } catch (RequestException e) { showMessage(messages.getString("DataHandler.ERROR_MESSAGE_TITLE"), e.getMessage(), //$NON-NLS-1$ e.getMessage().length() > 300); } }
From source file:org.pentaho.ui.database.gwt.GwtXulAsyncDatabaseDialectService.java
License:Open Source License
@Override public void getDatabaseDialects(final XulServiceCallback<List<IDatabaseDialect>> callback) { RequestBuilder registerDialectRequestBuilder = new RequestBuilder(RequestBuilder.GET, getBaseUrl() + "getDatabaseDialects"); registerDialectRequestBuilder.setHeader("Content-Type", "application/json"); try {// w w w. ja va 2 s . c o m registerDialectRequestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { AutoBean<IDatabaseDialectList> databaseDialectBean = AutoBeanCodex .decode(connectionAutoBeanFactory, IDatabaseDialectList.class, response.getText()); callback.success(databaseDialectBean.as().getDialects()); } @Override public void onError(Request request, Throwable exception) { callback.error("error testing connection: ", exception);//$NON-NLS-1$ } }); } catch (RequestException e) { callback.error("error testing connection: ", e);//$NON-NLS-1$ } }
From source file:org.pentaho.ui.database.gwt.GwtXulAsyncDatabaseDialectService.java
License:Open Source License
@Override public void getDatabaseTypes(final XulServiceCallback<List<IDatabaseType>> callback) { RequestBuilder registerDialectRequestBuilder = new RequestBuilder(RequestBuilder.GET, getBaseUrl() + "getDatabaseTypes"); registerDialectRequestBuilder.setHeader("Content-Type", "application/json"); try {// w w w.j a va 2 s. co m registerDialectRequestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(final Request request, final Response response) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { AutoBean<IDatabaseTypesList> databaseTypesBean = AutoBeanCodex.decode( connectionAutoBeanFactory, IDatabaseTypesList.class, response.getText()); callback.success(databaseTypesBean.as().getDbTypes()); } }); } @Override public void onError(Request request, Throwable exception) { callback.error("error testing connection: ", exception);//$NON-NLS-1$ } }); } catch (RequestException e) { callback.error("error testing connection: ", e);//$NON-NLS-1$ } }
From source file:org.pentaho.ui.xul.gwt.sample.ExampleXulApp.java
License:Open Source License
public void bundleLoaded(String bundleName) { try {/*w w w .j a va 2 s.c o m*/ RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "tree.xul"); try { Request response = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { // Code omitted for clarity } public void onResponseReceived(Request request, Response response) { displayXulDialog(response.getText()); // Code omitted for clarity } }); } catch (RequestException e) { // Code omitted for clarity } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.pentaho.ui.xul.gwt.util.AsyncXulLoader.java
License:Open Source License
public void bundleLoaded(String bundleName) { if (fromSource) { // already given Xul source if (loadingOverlay) { loadOverlay(xulSrc);//from w w w . j a v a 2 s . c o m } else if (removingOverlay) { removeOverlay(xulSrc); } else { generateXulContainer(xulSrc); } return; } // Load XUL source from server try { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, xulSrc); try { Request response = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("Error loading XUL: " + exception.getMessage()); //$NON-NLS-1$ } public void onResponseReceived(Request request, Response response) { if (caching) { overlayCache.put(xulSrc, response.getText()); } if (AsyncXulLoader.this.loadingOverlay) { loadOverlay(response.getText()); } else if (AsyncXulLoader.this.removingOverlay) { removeOverlay(response.getText()); } else { generateXulContainer(response.getText()); } } }); } catch (RequestException e) { Window.alert("error loading bundle: " + e.getMessage()); //$NON-NLS-1$ } } catch (Exception e) { Window.alert("error loading bundle: " + e.getMessage()); //$NON-NLS-1$ e.printStackTrace(); } }
From source file:org.pentaho.ui.xul.gwt.util.AsyncXulLoader.java
License:Open Source License
public void processIncludes(final com.google.gwt.xml.client.Document gwtDoc) { for (int y = 0; y < gwtDoc.getChildNodes().getLength(); y++) { final com.google.gwt.xml.client.Node window = gwtDoc.getChildNodes().item(y); try {//from ww w .j a v a2s .com if (window.getNodeName().equals("window") == false) { continue; } } catch (Exception e) { continue; } for (int i = 0; i < window.getChildNodes().getLength(); i++) { final com.google.gwt.xml.client.Node ele = window.getChildNodes().item(i); if (ele.getNodeName() != null && ele.getNodeName().equals("pen:include")) { try { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, ele.getAttributes().getNamedItem("src").getNodeValue()); builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("Error loading XUL: " + exception.getMessage()); //$NON-NLS-1$ } public void onResponseReceived(Request request, Response response) { com.google.gwt.xml.client.Document doc = XMLParser.parse(response.getText()); Node parent = ele.getParentNode(); parent.removeChild(ele); for (int z = 0; z < doc.getChildNodes().getLength(); z++) { if (doc.getChildNodes().item(z).getChildNodes().getLength() > 0) { parent.appendChild(doc.getChildNodes().item(z)); break; } } processIncludes(gwtDoc); return; } }); } catch (RequestException e) { Window.alert("error loading bundle: " + e.getMessage()); //$NON-NLS-1$ } } } } loadXulContainer(gwtDoc); }
From source file:org.primordion.ef.tex.Xholon2TexWirDiaO.java
License:Open Source License
protected void downloadPreambleAndWriteToTarget(String preambleFileName, String part1, String part2, String outFileName, String outPath, IXholon root) { try {/*from www . j av a 2s . c o m*/ //final String _contentType = contentType; final IXholon _root = root; new RequestBuilder(RequestBuilder.GET, preambleFileName).sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request req, Response resp) { if (resp.getStatusCode() == resp.SC_OK) { //root.println(resp.getText()); writeToTarget(part1 + resp.getText() + part2, outFileName, outPath, _root); } else { //root.println("status code:" + resp.getStatusCode()); //root.println("status text:" + resp.getStatusText()); //root.println("text:\n" + resp.getText()); writeToTarget(part1 + "% PREAMBLE" + preambleFileName + " status code:" + resp.getStatusCode() + " status text:" + resp.getStatusText() + "text:" + resp.getText() + "\n" + part2, outFileName, outPath, _root); } } @Override public void onError(Request req, Throwable e) { //root.println("onError:" + e.getMessage()); writeToTarget( part1 + "% PREAMBLE" + preambleFileName + " onError:" + e.getMessage() + "\n" + part2, outFileName, outPath, _root); } }); } catch (RequestException e) { //root.println("RequestException:" + e.getMessage()); writeToTarget( part1 + "% PREAMBLE" + preambleFileName + " RequestException:" + e.getMessage() + "\n" + part2, outFileName, outPath, root); } }
From source file:org.primordion.ef.xholon.DocRequester.java
License:Open Source License
/** * * @param fileName A local file name, or remote uri (http). * @param contentType One of "_xhn" "ih" "cd" "csh" etc. *//*from w w w .j av a 2 s .c om*/ protected void writeAll(String fileName, String contentType) { /* this is the non-GWT version out = root.getApp().getOut(); String fileName = root.getApp().getCompositeStructureHierarchyFile(); Reader in = MiscIo.openInputFile(fileName); try { char[] buf = new char[8192]; while (true) { int len = in.read(buf); if (len < 0) {break;} out.write(buf, 0, len); } out.flush(); } catch (IOException e) { e.printStackTrace(); } MiscIo.closeInputFile(in);*/ // GWT version //String fileName = root.getApp().getCompositeStructureHierarchyFile(); IApplication app = root.getApp(); String content = null; if (app.getWorkbookBundle() != null) { content = ((XholonWorkbookBundle) app.getWorkbookBundle()).getResource(contentType); } if (content != null) { writeToTarget(content, contentType, contentType, root); } else if (fileName == null) { // app is probably using a ClientBundle String efText = app.rcConfig(contentType, (ClientBundleWithLookup) app.findGwtClientBundle()); writeToTarget(efText, contentType, contentType, root); return; } else { try { final String _contentType = contentType; final IXholon _root = root; new RequestBuilder(RequestBuilder.GET, fileName).sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request req, Response resp) { if (resp.getStatusCode() == resp.SC_OK) { //root.println(resp.getText()); writeToTarget(resp.getText(), _contentType, _contentType, _root); } else { root.println("status code:" + resp.getStatusCode()); root.println("status text:" + resp.getStatusText()); root.println("text:\n" + resp.getText()); } } @Override public void onError(Request req, Throwable e) { root.println("onError:" + e.getMessage()); } }); } catch (RequestException e) { root.println("RequestException:" + e.getMessage()); } } }
From source file:org.primordion.xholon.service.nosql.Neo4jRestApi.java
License:Open Source License
/** * Get Neo4j service root, as a test.//w ww . ja v a2 s . c o m * GET http://localhost:7474/db/data/ */ protected void getServiceRoot() { String url = "http://localhost:7474/db/data/"; try { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url)); builder.setHeader("Accept", "application/json"); // " ;charset=UTF-8" builder.sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request req, Response resp) { if (resp.getStatusCode() == resp.SC_OK) { String jsonStr = resp.getText(); // display the raw returned JSON String contextNode.println(jsonStr); // parse the returned JSON String, and get and display a single value JSONValue jsonValue = ((JSONObject) JSONParser.parseStrict(jsonStr)).get("neo4j_version"); contextNode.println("neo4j_version = " + jsonValue); } else { contextNode.println("status code:" + resp.getStatusCode()); contextNode.println("status text:" + resp.getStatusText()); contextNode.println("text:\n" + resp.getText()); } } @Override public void onError(Request req, Throwable e) { contextNode.println("onError:" + e.getMessage()); } }); } catch (RequestException e) { contextNode.println("RequestException:" + e.getMessage()); } }
From source file:org.primordion.xholon.service.svg.SvgViewBrowser.java
License:Open Source License
/** * Load an SVG image from a URI./*from ww w .j av a 2s. c om*/ */ protected void loadSvg(final String uri) { final IXholon this_ = this; final IXholon client_ = client; try { new RequestBuilder(RequestBuilder.GET, uri).sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request req, Response resp) { if (resp.getStatusCode() == resp.SC_OK) { diagram = loadSvg(resp.getText(), uri); finishSetup(); client_.sendSyncMessage(SIG_STATUS_OK_REQ, null, this_); } else { if (uri.equals(svgUri) && (svgUriFallback != null)) { loadSvg(svgUriFallback); } else { String xmlString = xmlGwtresource2String(uri); if (xmlString == null) { client_.sendSyncMessage(SIG_STATUS_NOT_OK_REQ, resp.getText(), this_); this_.removeChild(); // remove self from the Xholon tree } else { diagram = loadSvg(xmlString, uri); finishSetup(); client_.sendSyncMessage(SIG_STATUS_OK_REQ, null, this_); } } } } @Override public void onError(Request req, Throwable e) { client_.sendSyncMessage(SIG_STATUS_NOT_OK_REQ, e.getMessage(), this_); this_.removeChild(); // remove self from the Xholon tree } }); } catch (RequestException e) { client_.sendSyncMessage(SIG_STATUS_NOT_OK_REQ, e.getMessage(), this_); this_.removeChild(); // remove self from the Xholon tree } }