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:org.jboss.bpm.console.client.URLBuilder.java

License:Open Source License

public String getProcessHistoryFailedInstanceURL(String id, String timestamp, String timespan) {
    String encodedId = URL.encode(id);
    return config.getConsoleServerUrl() + "/rs/history/definition/" + encodedId + "/instances/failed?timestamp="
            + timestamp + "&timespan=" + timespan;
}

From source file:org.jboss.bpm.console.client.URLBuilder.java

License:Open Source License

public String getProcessHistoryTerminatedInstanceURL(String id, String timestamp, String timespan) {
    String encodedId = URL.encode(id);
    return config.getConsoleServerUrl() + "/rs/history/definition/" + encodedId
            + "/instances/terminated?timestamp=" + timestamp + "&timespan=" + timespan;
}

From source file:org.jboss.bpm.console.client.URLBuilder.java

License:Open Source License

public String getProcessHistoryCompletedInstances4ChartURL(String id, String timespan) {
    String encodedId = URL.encode(id);
    return config.getConsoleServerUrl() + "/rs/history/definition/" + encodedId
            + "/instances/chart/completed?timespan=" + timespan;
}

From source file:org.jboss.bpm.console.client.URLBuilder.java

License:Open Source License

public String getProcessHistoryFailedInstances4ChartURL(String id, String timespan) {
    String encodedId = URL.encode(id);
    return config.getConsoleServerUrl() + "/rs/history/definition/" + encodedId
            + "/instances/chart/failed?timespan=" + timespan;
}

From source file:org.jboss.bpm.console.client.URLBuilder.java

License:Open Source License

public static void main(String[] args) throws Exception {
    System.out.println(URL.encode("{http://www.jboss.org/bpel/examples}HelloGoodbye-1"));
}

From source file:org.jboss.errai.bus.client.framework.transports.HttpPollingHandler.java

License:Apache License

/**
 * Sends the given string oon the outbound communication channel (as a POST
 * request to the server).//from   w ww .  j  av  a 2s .  com
 *
 * @param payload
 *     The message to send. It is sent verbatim.
 * @param callback
 *     The callback to receive success or error notification. Note that
 *     this callback IS NOT CALLED if the request is cancelled.
 * @param extraParameters
 *     Extra paramets to include in the HTTP request (key is parameter name;
 *     value is parameter value).
 *
 * @throws com.google.gwt.http.client.RequestException
 *     if the request cannot be sent at all.
 */
public Request sendPollingRequest(final String payload, final Map<String, String> extraParameters,
        final RequestCallback callback) throws RequestException {

    // LogUtil.log("[bus] sendPollingRequest(" + payload + ")");

    final String serviceEntryPoint;
    final Map<String, String> parmsMap;
    final boolean waitChannel;
    boolean activeWaitChannel = false;

    final Iterator<RxInfo> iterator = pendingRequests.iterator();
    while (iterator.hasNext()) {
        final RxInfo pendingRx = iterator.next();
        if (pendingRx.getRequest().isPending() && pendingRx.isWaiting()) {
            //  LogUtil.log("[bus] ABORT SEND: " + pendingRx + " is waiting" );
            // return null;
            activeWaitChannel = true;
        }

        if (!pendingRx.getRequest().isPending()) {
            iterator.remove();
        }
    }

    if (!activeWaitChannel && receiveCommCallback.canWait() && !rxActive) {
        parmsMap = new HashMap<String, String>(extraParameters);
        parmsMap.put("wait", "1");
        serviceEntryPoint = messageBus.getInServiceEntryPoint();
        waitChannel = true;
    } else {
        parmsMap = extraParameters;
        serviceEntryPoint = messageBus.getOutServiceEntryPoint();
        waitChannel = false;
    }

    rxActive = true;

    final StringBuilder extraParmsString = new StringBuilder();
    for (final Map.Entry<String, String> entry : parmsMap.entrySet()) {
        extraParmsString.append("&").append(URL.encodePathSegment(entry.getKey())).append("=")
                .append(URL.encodePathSegment(entry.getValue()));
    }

    final long latencyTime = System.currentTimeMillis();

    final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
            URL.encode(messageBus.getApplicationLocation(serviceEntryPoint)) + "?z=" + getNextRequestNumber()
                    + "&clientId=" + URL.encodePathSegment(messageBus.getClientId())
                    + extraParmsString.toString());
    builder.setHeader("Content-Type", "application/json; charset=utf-8");

    final RxInfo rxInfo = new RxInfo(System.currentTimeMillis(), waitChannel);

    try {
        // LogUtil.log("[bus] TX: " + payload);
        final Request request = builder.sendRequest(payload, new RequestCallback() {
            @Override
            public void onResponseReceived(final Request request, final Response response) {
                if (!waitChannel) {
                    measuredLatency = (int) (System.currentTimeMillis() - latencyTime);
                }

                pendingRequests.remove(rxInfo);
                callback.onResponseReceived(request, response);
                rxNumber++;
                rxActive = false;
            }

            @Override
            public void onError(final Request request, final Throwable exception) {
                pendingRequests.remove(rxInfo);
                callback.onError(request, exception);
                rxActive = false;
            }
        });

        rxInfo.setRequest(request);
        pendingRequests.add(rxInfo);

        return request;
    } catch (RequestException e) {
        throw e;
    }
}

From source file:org.jboss.errai.bus.client.framework.transports.SSEHandler.java

License:Apache License

@Override
public void configure(final Message capabilitiesMessage) {
    configured = true;/*  w w  w .  jav a2  s.c  om*/

    if (!isSSESupported()) {
        hosed = true;
        unsupportedReason = UNSUPPORTED_MESSAGE_NO_SERVER_SUPPORT;
        LogUtil.log("this browser does not support SSE");
        return;
    }

    this.sseEntryPoint = URL
            .encode(clientMessageBus.getApplicationLocation(clientMessageBus.getInServiceEntryPoint()))
            + "?z=0000&sse=1&clientId=" + URL.encodePathSegment(clientMessageBus.getClientId());

}

From source file:org.kie.workbench.common.screens.defaulteditor.client.editor.NewFileUploader.java

License:Apache License

String encode(final String uri) {
    return URL.encode(uri);
}

From source file:org.kie.workbench.common.screens.explorer.client.utils.URLHelper.java

License:Apache License

public static String getDownloadUrl(final Path path) {
    final StringBuilder sb = new StringBuilder(URLHelper.getServletUrl());
    sb.append("?").append(FileManagerFields.FORM_FIELD_PATH).append("=").append(URL.encode(path.toURI()));
    return sb.toString();
}

From source file:org.kuali.student.common.ui.client.security.SpringSecurityLoginDialogHandler.java

License:Educational Community License

private void createLoginPanel() {
    lightbox = new KSLightBox();
    VerticalPanel panel = new VerticalPanel();

    FlexTable table = new FlexTable();

    errorLabel = new Label();
    errorLabel.setText(TIMEOUT_MSG);
    errorLabel.setStyleName("KSError");

    username = new TextBox();
    username.setName("j_username");

    password = new PasswordTextBox();
    password.setName("j_password");

    table.setText(0, 0, "Username");
    table.setWidget(0, 1, username);//from   w ww.  ja v  a2s .  com

    table.setText(1, 0, "Password");
    table.setWidget(1, 1, password);

    table.setWidget(2, 0, (new Button("Login", new ClickHandler() {
        public void onClick(ClickEvent event) {

            //JIRA FIX : KSENROLL-8731 - Replaced StringBuffer with StringBuilder
            StringBuilder postData = new StringBuilder();
            postData.append(URL.encode("j_username")).append("=").append(username.getText());
            postData.append("&").append(URL.encode("j_password")).append("=").append(password.getText());

            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                    context.getApplicationContextUrl() + "/j_spring_security_check");
            builder.setHeader("Content-type", "application/x-www-form-urlencoded");

            try {
                builder.sendRequest(postData.toString(), new RequestCallback() {

                    @Override
                    public void onError(Request req, Throwable caught) {
                        lightbox.hide();
                        KSErrorDialog.show(caught);
                    }

                    @Override
                    public void onResponseReceived(Request req, Response res) {
                        if (res.getStatusCode() == Response.SC_OK
                                && !res.getText().contains("Bad credentials")) {
                            lightbox.hide();
                        } else {
                            errorLabel.setText("Your login attempt was not successful, try again.");
                        }
                    }
                });
            } catch (RequestException e) {
                KSErrorDialog.show(e);
            }
        }
    })));

    panel.add(errorLabel);
    panel.add(table);

    panel.setStyleName("KSLoginPanel");
    lightbox.setWidget(panel);
}