Example usage for com.google.gwt.http.client RequestBuilder GET

List of usage examples for com.google.gwt.http.client RequestBuilder GET

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestBuilder GET.

Prototype

Method GET

To view the source code for com.google.gwt.http.client RequestBuilder GET.

Click Source Link

Document

Specifies that the HTTP GET method should be used.

Usage

From source file:n3phele.client.presenter.CommandActivity.java

License:Open Source License

protected void getRepos() {

    String url = repoListUrl;//  www  .jav a  2  s .  c om
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Couldn't retrieve JSON " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    Collection<Repository> r = Repository.asCollection(response.getText());
                    updateRepository(r.getElements());
                } else {
                    GWT.log("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        GWT.log("Couldn't retrieve JSON " + e.getMessage());
    }
}

From source file:n3phele.client.presenter.CommandActivity.java

License:Open Source License

/**
 * @param view//from www .j av a2 s .  c om
 */
public void fetchFiles(final FileNodeBrowser view, String repoURI, String prefix) {
    String url = repoURI + "/list";
    if (!isNullOrBlank(prefix)) {
        url += "?prefix=" + URL.encodeQueryString(prefix);
    }
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Couldn't retrieve JSON " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    GWT.log(response.getText());
                    RepoListResponse result = RepoListResponse.parseJSON(response.getText());
                    List<FileNode> crumbs = result.getCrumbs();
                    List<FileNode> namesWithPlaceholders = result.getFiles();
                    if (crumbs != null && CommandActivity.this.placeholderMap != null) {
                        String lastPath = "";
                        if (crumbs.size() > 1) {
                            FileNode lastCrumb = crumbs.get(crumbs.size() - 1);
                            lastPath = getCanonicalName(lastCrumb) + "/";
                        }
                        GWT.log("lastPath=" + lastPath);
                        if (CommandActivity.this.placeholderMap.containsKey(lastPath)) {
                            java.util.Collection<FileNode> placeholders = CommandActivity.this.placeholderMap
                                    .get(lastPath).values();
                            namesWithPlaceholders = new ArrayList<FileNode>(
                                    placeholders.size() + result.getFiles().size());
                            GWT.log("adding placeholder");
                            namesWithPlaceholders.addAll(placeholders);
                            namesWithPlaceholders.addAll(result.getFiles());
                        }
                    }
                    view.show(result.getCrumbs(), namesWithPlaceholders);
                } else {
                    GWT.log("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        GWT.log("Couldn't retrieve JSON " + e.getMessage());
    }

}

From source file:n3phele.client.presenter.CommandActivity.java

License:Open Source License

/**
 * @param view//from   w ww. ja v  a2s  . c  o m
 * @param repoURI
 * @param filename
 */
public void checkExists(final FileNodeBrowser view, String repoURI, final String filename) {
    String url = repoURI + "/validate";
    if (filename != null) {
        url += "?filename=" + URL.encodeQueryString(filename);
    }
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Couldn't retrieve JSON " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    GWT.log(response.getText());
                    boolean result = ValidationResponse.parseJSON(response.getText()).getExists();
                    if (result)
                        view.enableRun(filename);
                } else {
                    GWT.log("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        GWT.log("Couldn't retrieve JSON " + e.getMessage());
    }

}

From source file:n3phele.client.presenter.CommandListActivity.java

License:Open Source License

public void fetch(final int start, String search, boolean preferred) {
    lastStart = start;/*from w ww  .j  a  v a2s. c o m*/
    String url = URL.encode(
            collectionUrl + "&start=" + start + "&end=" + (start + PAGESIZE) + "&preferred=" + preferred);
    if (!isBlankOrNull(search))
        url += "&search=" + URL.encodeQueryString(search);
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                Window.alert("Request error " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    Collection<Command> c = Command.asCollection(response.getText());
                    updateData(c.getUri(), c.getElements(), start, c.getTotal());
                } else {
                    Window.alert("Response error " + response.getStatusText());
                }
            }
        });
    } catch (RequestException exception) {
        Window.alert("Request exception " + exception.getMessage());
    }
}

From source file:n3phele.client.presenter.CreateServiceActivity.java

License:Open Source License

public void getAccount() {
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, accountUri);
    try {/* w  ww  .  j a v a 2  s.c om*/
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    Account account = Account.asAccount(response.getText());
                    updateAccount(account);
                } else {

                }
            }

        });
    } catch (RequestException e) {
    }
}

From source file:n3phele.client.presenter.CreateServiceActivity.java

License:Open Source License

public void getAccountList() {
    String url = cacheManager.ServiceAddress + "account/listAccounts";
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {//from w  w w .ja va 2s  .c o  m
        @SuppressWarnings("unused")
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                Collection<CommandCloudAccount> accounts = CommandCloudAccount.asCollection(response.getText());
                display.setCloudAccounts(accounts.getElements());
            }

        });
    } catch (RequestException e) {
        //displayError("Couldn't retrieve JSON "+e.getMessage());
    }
}

From source file:n3phele.client.presenter.ProcessActivity.java

License:Open Source License

public void getProcess() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, processUri);
    try {//ww  w. j a  v  a  2 s  .co  m
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    CloudProcess process = CloudProcess.asCloudProcess(response.getText());
                    updateProcess(process);
                } else {

                }
            }

        });
    } catch (RequestException e) {
        //displayError("Couldn't retrieve JSON "+e.getMessage());
    }
}

From source file:n3phele.client.presenter.ProgressActivity.java

License:Open Source License

public void getProgress() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, progressUri);
    try {//  ww w . ja v a2 s  . c o  m
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    Progress progress = Progress.asProgress(response.getText());
                    updateProgress(progress);
                } else {

                }
            }

        });
    } catch (RequestException e) {
        //displayError("Couldn't retrieve JSON "+e.getMessage());
    }
}

From source file:n3phele.client.presenter.RepoActivity.java

License:Open Source License

public void getRepo() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, repositoryUri);
    try {/*w w  w . j  a  v a2  s  .  c  om*/
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log(response.getStatusCode() + " " + response.getText());
                if (200 == response.getStatusCode()) {
                    Repository repo = Repository.asRepository(response.getText());
                    updateRepo(repo);
                } else {
                    Window.alert("Update failure: " + response.getStatusText() + " " + response.getText());
                }
            }

        });
    } catch (RequestException e) {
        Window.alert("Update exception: " + e.toString());
    }
}

From source file:n3phele.client.presenter.RepoContentActivity.java

License:Open Source License

/**
 * @param node/*from  w  w w  . j  a  v a 2  s .co  m*/
 * @param fileDetailsPanel 
 */
public void getOrigin(final FileNode node, final FileDetailsPanel fileDetailsPanel) {

    String url = node.getRepository() + "/origin" + "?name=" + URL.encodeQueryString(node.getName());
    if (!isNullOrBlank(node.getPath())) {
        url += "&path=" + URL.encodeQueryString(node.getPath());
    }

    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // displayError("Couldn't retrieve JSON "+exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log(response.getStatusCode() + " " + response.getText());
                if (200 == response.getStatusCode()) {
                    Origin origin = Origin.asOrigin(response.getText());
                    provideOrigin(node, origin, fileDetailsPanel);
                } else {
                    Window.alert(
                            "Origin fetch failure: " + response.getStatusText() + " " + response.getText());
                }
            }

        });
    } catch (RequestException e) {
        Window.alert("Origin fetch exception: " + e.toString());
    }

}