Example usage for com.google.gwt.http.client RequestCallback RequestCallback

List of usage examples for com.google.gwt.http.client RequestCallback RequestCallback

Introduction

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

Prototype

RequestCallback

Source Link

Usage

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

License:Open Source License

public void deleteFile(final FileNode object) {
    String filename = getCanonicalName(object);
    String url = this.repo.getUri() + "/file?filename=" + URL.encodeQueryString(filename);
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.DELETE, url);
    try {// ww w .j  av  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(response.getStatusCode() + " " + response.getText());
                if (200 == response.getStatusCode()) {
                    fetchFiles(object.getRepository(), object.getPath());
                } else {
                    Window.alert("Delete failure: " + response.getStatusText() + " " + response.getText());
                }
            }

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

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

License:Open Source License

public void deleteFolder(final FileNode object) {
    String filename = getCanonicalName(object);

    String url = this.repo.getUri() + "/folder?filename=" + URL.encodeQueryString(filename);
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.DELETE, url);
    try {// ww  w . j a  v  a 2 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(response.getStatusCode() + " " + response.getText());
                if (200 != response.getStatusCode()) {
                    Window.alert("Delete failure: " + response.getStatusText() + " " + response.getText());
                }
            }

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

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

License:Open Source License

public void getRepositoryList() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, repositoryCollection);
    try {//from  w  w w.  j a va2 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()) {
                    Collection<Repository> repository = Repository.asCollection(response.getText());
                    updateRepositoryList(repository.getElements());
                } else {

                }
            }

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

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

License:Open Source License

public void getProcess() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, processUri);
    try {//from  w  ww .  j  ava  2  s .  co m
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Got error");
            }

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

                }
            }

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

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

License:Open Source License

public void getAction() {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, serviceUri);
    try {/* w  ww. jav a 2  s .  c  o m*/
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Got error");
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    StackServiceAction stackAction = StackServiceAction.asAction(response.getText());
                    display.setStackAction(stackAction);
                }
            }

        });
    } catch (RequestException e) {
        GWT.log("Got error");
    }
}

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

License:Open Source License

public void getAction(String uri) {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, uri);
    try {//from   ww w  . j av  a 2s  .  c  o m
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Got error");
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    stackAction = StackServiceAction.asAction(response.getText());
                    for (Stack s : stackAction.getStackList()) {
                        if (s.getId().equals(stackId)) {
                            stack = s;
                            break;
                        }

                    }
                    if (stack.getVms().size() > 0) {
                        for (String str : stack.getVms()) {
                            getProcess(str);
                        }
                    }
                }
            }

        });
    } catch (RequestException e) {
        GWT.log("Got error");
    }
}

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

License:Open Source License

public void getProcess(String processUri) {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, processUri);
    try {/* w  w  w.j a 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()) {
                    CloudProcess process = CloudProcess.asCloudProcess(response.getText());
                    listCloudProcess.add(process);
                    display.setDisplayList(listCloudProcess);
                    getAssimilateAction(process.getName(), process.getAction());

                } else {

                }
            }

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

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

License:Open Source License

public void getAssimilateAction(String name, String uri) {
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, uri);
    final String fname = name;
    try {//www.j  a  v  a  2  s  .  c om
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("Got error");
            }

            public void onResponseReceived(Request request, Response response) {
                GWT.log("Got reply");
                if (200 == response.getStatusCode()) {
                    AssimilateVMAction action = AssimilateVMAction.asAction(response.getText());
                    updateCloudIP(fname, action.getTargetIP());
                }
            }

        });
    } catch (RequestException e) {
        GWT.log("Got error");
    }
}

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

License:Open Source License

private void updateUserDetails(String url, String email, String firstName, String lastName,
        final String password) {

    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.POST, url);
    builder.setHeader("Content-type", "application/x-www-form-urlencoded");
    StringBuilder args = new StringBuilder();
    args.append("email=");
    args.append(URL.encodeQueryString(email));
    args.append("&firstName=");
    args.append(URL.encodeQueryString(firstName));
    args.append("&lastName=");
    args.append(URL.encodeQueryString(lastName));
    if (password != null && password.length() > 0) {
        args.append("&secret=");
        args.append(URL.encodeQueryString(password));
    }/*w  ww  .  j ava  2  s  . c om*/
    try {
        Request request = builder.sendRequest(args.toString(), 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()) {
                    if (isSelf) {
                        User user = User.asUser(response.getText());
                        String pw = password;
                        if (pw == null || pw.length() == 0) {
                            pw = AuthenticatedRequestFactory.getDefaultPassword();
                        }
                        AuthenticatedRequestFactory.setCredentials(user.getName(), pw, user);
                        N3phele.basePanel.updateUser(user);
                    }
                    goToPrevious();
                } else {
                    Window.alert("Update failure: " + response.getStatusText() + " " + response.getText());
                }
            }

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

From source file:n3phele.client.view.AccountHyperlinkView.java

License:Open Source License

private void kill(String uri) {
    String url = uri;//from  ww w .  j  a va2 s .  c o m
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.DELETE, url);
    builder.setHeader("account",
            account.getUri().substring(account.getUri().lastIndexOf('/') + 1, account.getUri().length()));
    try {
        @SuppressWarnings("unused")
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                Window.alert("Couldn't delete " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (204 == response.getStatusCode()) {
                    if (AccountHyperlinkView.this.presenter != null) {
                        presenter.initTimerDelete();
                    }
                    //presenter.callGetTopLevel();
                    //AccountHyperlinkView.this.presenter.getVSList();
                } else {
                    Window.alert("Couldn't delete (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        Window.alert("Couldn't delete " + e.getMessage());

    }
}