Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

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

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

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

License:Open Source License

protected void refresh(String key) {

    String url = URL.encode(key + "?summary=true");
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {//  w w  w  .  ja v  a 2 s.c o m
        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()) {
                    Progress p = Progress.asProgress(response.getText());
                    updateData(p.getUri(), p);
                } 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.AbstractCloudProcessActivity.java

License:Open Source License

public AbstractCloudProcessActivity(String name, ClientFactory factory, CloudProcessView activityView,
        boolean countAll) {
    super();//from  w  w  w  .  j a v  a2s. co  m
    this.name = name;
    this.cacheManager = factory.getCacheManager();
    this.placeController = factory.getPlaceController();
    this.display = activityView;
    this.historyMapper = factory.getHistoryMapper();
    this.collectionUrl = URL.encode(cacheManager.ServiceAddress + "process");
    this.total = 0;
    this.countAll = countAll;
}

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

License:Open Source License

protected void refresh(String key) {

    String url = URL.encode(key + "?summary=true");
    // Send request to server and catch any errors.
    RequestBuilder builder = AuthenticatedRequestFactory.newRequest(RequestBuilder.GET, url);
    try {//from w ww. j  av  a  2 s  . c  o  m
        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()) {
                    CloudProcessSummary p = CloudProcessSummary.asCloudProcessSummary(response.getText());
                    updateData(p.getUri(), p);
                } 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.AbstractServiceActivity.java

License:Open Source License

public AbstractServiceActivity(String name, ClientFactory factory, ServiceListView activityView,
        boolean countAll, String query) {
    super();//from w  ww  . j  a va  2 s. c om
    this.name = name;
    this.cacheManager = factory.getCacheManager();
    this.placeController = factory.getPlaceController();
    this.display = activityView;
    this.historyMapper = factory.getHistoryMapper();
    this.collectionUrl = URL.encode(cacheManager.ServiceAddress + "process") + query;
    this.total = 0;
    this.countAll = countAll;
}

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

License:Open Source License

public AccountListActivity(String accountUri, ClientFactory factory) {

    this.historyMapper = factory.getHistoryMapper();
    this.display = factory.getAccountListView();
    this.cacheManager = factory.getCacheManager();
    this.accountCollection = URL.encode(factory.getCacheManager().ServiceAddress + "account");
}

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

License:Open Source License

public CommandActivity(String name, String uri, ClientFactory factory, CommandDetailView view) {
    super();// ww  w .ja va  2 s  .  c  o m
    this.name = name;
    this.cacheManager = factory.getCacheManager();
    this.placeController = factory.getPlaceController();
    this.display = view;
    this.objectUri = uri;
    this.repoListUrl = URL.encode(cacheManager.ServiceAddress + "repository");
    //      this.cloudListUrl = URL.encode(cacheManager.ServiceAddress + "cloud");
    //      this.accountListUrl = URL.encode(cacheManager.ServiceAddress + "account");
}

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

License:Open Source License

public CommandListActivity(String name, ClientFactory factory, String commandCollectionArgs,
        CommandListViewInterface view) {
    super();/*  ww  w. ja  v a 2  s.com*/
    this.name = name;
    this.cacheManager = factory.getCacheManager();
    this.placeController = factory.getPlaceController();
    this.display = view;
    this.collectionUrl = URL.encode(cacheManager.ServiceAddress + "command" + commandCollectionArgs);
    this.historyMapper = factory.getHistoryMapper();
    this.PAGESIZE = view.getPageSize();
}

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

License:Open Source License

public void fetch(final int start, String search, boolean preferred) {
    lastStart = start;/*w w  w.j a  va2s  .co  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.RepoActivity.java

License:Open Source License

private void updateRepoDetails(String url, String name, String description, String target, String kind,
        String root, boolean isPublic, String authId, String password) {

    if (url == null || url.trim().length() == 0) {
        url = cacheManager.ServiceAddress + "repository";
    }/*  www . j  a  v a  2s  . c  om*/
    // 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("name=");
    args.append(URL.encodeQueryString(name));
    if (description != null && description.length() != 0) {
        args.append("&description=");
        args.append(URL.encodeQueryString(description));
    }
    args.append("&target=");
    args.append(URL.encodeQueryString(target));
    args.append("&kind=");
    args.append(URL.encodeQueryString(kind));
    args.append("&root=");
    args.append(URL.encodeQueryString(root));
    args.append("&isPublic=");
    args.append(URL.encode(isPublic ? "true" : "false"));
    if (password != null && password.length() > 0) {
        args.append("&repositoryId=");
        args.append(URL.encodeQueryString(authId));
        args.append("&secret=");
        args.append(URL.encodeQueryString(password));
    }
    GWT.log(args.toString());
    GWT.log(authId);
    GWT.log(password);
    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()) {
                    goToPrevious();
                } else if (201 == response.getStatusCode()) {
                    goToPrevious();
                } else {
                    Window.alert(
                            "Repository update error " + response.getStatusText() + " " + response.getText());
                }
            }

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

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

License:Open Source License

public RepoListActivity(String repositoryUri, ClientFactory factory) {
    this.cacheManager = factory.getCacheManager();
    this.historyMapper = factory.getHistoryMapper();
    this.display = factory.getRepositoryListView();
    this.repositoryCollection = URL.encode(factory.getCacheManager().ServiceAddress + "repository");
}