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

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

Introduction

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

Prototype

public static String encodeQueryString(String decodedURLComponent) 

Source Link

Document

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

Usage

From source file:org.bonitasoft.console.client.user.task.action.CheckFormMappingAndDisplayProcessInstanciationFormAction.java

License:Open Source License

protected void searchFormMappingForProcess(final TreeIndexed<String> parameters) {
    final String processId = parameters.getValue(ProcessItem.ATTRIBUTE_ID);
    RequestBuilder requestBuilder;/* www  . j a  va2  s .co  m*/
    final String processIdFilter = URL.encodeQueryString(PageItem.ATTRIBUTE_PROCESS_ID + "=" + processId);
    final String mappingTypeFilter = URL
            .encodeQueryString(ATTRIBUTE_FORM_MAPPING_TYPE + "=" + PROCESS_START_FORM_MAPPING);
    requestBuilder = new RequestBuilder(RequestBuilder.GET,
            "../API/form/mapping?c=10&p=0&f=" + processIdFilter + "&f=" + mappingTypeFilter);
    requestBuilder.setCallback(new FormMappingCallback(processId, parameters));
    try {
        requestBuilder.send();
    } catch (final RequestException e) {
        GWT.log("Error while creating the from mapping request", e);
    }
}

From source file:org.bonitasoft.console.client.view.LogoutWidget.java

License:Open Source License

private Widget buildLogoutLink() {

    Anchor theLogoutLink = new Anchor(constants.logout());
    theLogoutLink.setStylePrimaryName("identif-2");

    URLUtils urlUtils = URLUtilsFactory.getInstance();
    List<String> paramsToRemove = new ArrayList<String>();
    paramsToRemove.add(URLUtils.LOCALE_PARAM);
    final String domain = Window.Location.getParameter(URLUtils.DOMAIN_PARAM);
    String theRedirectURL = urlUtils.rebuildUrl(urlUtils.removeHashFromUrl(), paramsToRemove, null, null, null);
    String theURL = RpcSecurityServices.getLogoutURL();
    String theURLSuffix = "?" + URLUtils.REDIRECT_URL_PARAM + "=";
    try {//from   ww w  .j a v a  2 s  .c  o  m
        theURLSuffix += URL.encodeQueryString(theRedirectURL);
    } catch (Exception e) {
        Window.alert("Unable to redirect to login page: Invalid URL");
        theURLSuffix += GWT.getModuleBaseURL();
    }
    if (domain != null) {
        theURLSuffix += "&" + URLUtils.DOMAIN_PARAM + "=" + domain;
    }
    theLogoutLink.setHref(theURL + theURLSuffix);

    return theLogoutLink;
}

From source file:org.bonitasoft.forms.client.view.common.URLUtils.java

License:Open Source License

private String buildUrlHash(final String hash, final List<String> hashParamsToRemove,
        final Map<String, String> hashParamsToAdd) {
    final StringBuilder hashParams = new StringBuilder();
    if (hash != null) {
        final Map<String, String> hashParameters = getHashParameters(hash);
        for (final Entry<String, String> hashParamEntry : hashParameters.entrySet()) {
            if (hashParamsToRemove == null || !hashParamsToRemove.contains(hashParamEntry.getKey())) {
                if (hashParams.length() > 0) {
                    hashParams.append("&");
                }//from  w w w .  jav  a  2  s . c o m
                hashParams.append(URL.encodeQueryString(hashParamEntry.getKey()));
                if (hashParamEntry.getValue() != null) {
                    hashParams.append("=");
                    hashParams.append(URL.encodeQueryString(hashParamEntry.getValue()));
                }
            }
        }
    }
    if (hashParamsToAdd != null && !hashParamsToAdd.isEmpty()) {
        for (final Entry<String, String> hashParamEntry : hashParamsToAdd.entrySet()) {
            if (hashParams.length() > 0) {
                hashParams.append("&");
            }
            hashParams.append(URL.encodeQueryString(hashParamEntry.getKey()));
            if (hashParamEntry.getValue() != null) {
                hashParams.append("=");
                hashParams.append(URL.encodeQueryString(hashParamEntry.getValue()));
            }
        }
    }
    return hashParams.toString();
}

From source file:org.bonitasoft.forms.client.view.common.URLUtils.java

License:Open Source License

/**
 * @param applicationURL//  ww  w . jav  a 2s  . c  om
 * @param urlContext
 * @return
 */
public String getFormRedirectionUrl(final String applicationURL, final Map<String, Object> urlContext) {
    final StringBuilder url = new StringBuilder(applicationURL);
    if (applicationURL.contains("?")) {
        url.append("&");
    } else {
        url.append("?");
    }
    url.append(URLUtils.LOCALE_PARAM);
    url.append("=");
    url.append(getLocale());
    url.append("#");
    final Iterator<Entry<String, Object>> it = urlContext.entrySet().iterator();
    final int size = urlContext.size();
    for (int i = 0; i < size; i++) {
        final Entry<String, Object> entry = it.next();
        final String key = entry.getKey();
        final String value = entry.getValue().toString();
        url.append(key + "=" + URL.encodeQueryString(value));
        if (i < size - 1) {
            url.append("&");
        }
    }
    return url.toString();
}

From source file:org.bonitasoft.forms.client.view.common.URLUtils.java

License:Open Source License

/**
 * @param urlContext//w  w w. ja  v  a2  s.  c  o m
 * @return
 */
public String getFormRedirectionHash(final Map<String, Object> urlContext) {
    final StringBuilder hashBuilder = new StringBuilder();
    final Iterator<Entry<String, Object>> it = urlContext.entrySet().iterator();
    final int size = urlContext.size();
    for (int i = 0; i < size; i++) {
        final Entry<String, Object> entry = it.next();
        final String key = entry.getKey();
        final String value = entry.getValue().toString();
        hashBuilder.append(key + "=" + URL.encodeQueryString(value));
        if (i < size - 1) {
            hashBuilder.append("&");
        }
    }
    return hashBuilder.toString();
}

From source file:org.bonitasoft.forms.client.view.common.URLUtils.java

License:Open Source License

public String buildLayoutURL(final String bodyContentId, final String formID, final String taskId,
        final boolean isPageLayout) throws UnsupportedEncodingException {
    final StringBuffer theURL = new StringBuffer(GWT.getModuleBaseURL()).append(FORM_LAYOUT_DOWNLOAD);
    if (bodyContentId != null) {
        theURL.append("?" + BODY_CONTENT_ID + "=").append(URL.encodeQueryString(bodyContentId));
        theURL.append("&" + IS_PAGE_LAYOUT + "=").append(isPageLayout);
        if (formID != null) {
            theURL.append("&" + FORM_ID + "=").append(URL.encodeQueryString(formID));
        }// w  ww .  j  av a 2 s . co m
        if (taskId != null) {
            theURL.append("&" + TASK_ID_PARAM + "=").append(URL.encodeQueryString(taskId));
        }
    } else {
        return null;
    }

    return theURL.toString();
}

From source file:org.bonitasoft.forms.client.view.common.URLUtils.java

License:Open Source License

/**
 * Display the login page/*from   w  w  w  . j  a v a 2s  .com*/
 */
public void showLoginView() {

    final String theRedirectURL = "../login.jsp";

    final List<String> paramsToRemove = new ArrayList<String>();
    paramsToRemove.add(URLUtils.LOCALE_PARAM);
    final List<String> hashParamToRemove = new ArrayList<String>();
    hashParamToRemove.add(URLUtils.AUTO_LOGIN_PARAM);
    hashParamToRemove.add(URLUtils.USER_CREDENTIALS_PARAM);
    final String redirectUrl = rebuildUrl(paramsToRemove, null, hashParamToRemove, null);
    String theURLSuffix = "?" + REDIRECT_URL_PARAM + "=";
    try {
        theURLSuffix += URL.encodeQueryString(redirectUrl);
    } catch (final Exception e) {
        Window.alert("Unable to redirect to login page: Invalid URL");
        theURLSuffix += GWT.getModuleBaseURL();
    } finally {
        windowRedirect(theRedirectURL + theURLSuffix);
    }
}

From source file:org.bonitasoft.forms.client.view.FormsAsyncCallback.java

License:Open Source License

protected void handleSessionTimeout() {
    DOMUtils domUtils = DOMUtils.getInstance();
    URLUtils urlUtils = URLUtils.getInstance();
    String url = urlUtils.removeURLparameters(Window.Location.getHref());
    if (!domUtils.isPageInFrame()) {
        url += "?redirectUrl="
                + URL.encodeQueryString(Window.Location.getQueryString() + Window.Location.getHash());
    }//from   w ww. j  av a  2 s .  c om
    urlUtils.parentFrameRedirect(url);
}

From source file:org.bonitasoft.forms.client.view.widget.FileDownloadWidget.java

License:Open Source License

public void setFilePath(String filePath, final String realFileName) {
    filePath = URL.encodeQueryString(filePath);
    final String fileName = URL.encodeQueryString(realFileName);
    final String downloadURL = URLUtils.getInstance().getFileURL(attachmentServletURL, filePath, fileName);
    if (hasImagePreview) {
        final String imageURL = URLUtils.getInstance().getFileURL(imageServletURL, filePath, fileName);
        previewImage.setTitle(fileName);
        previewImage.setUrl(imageURL);/*from   w  w w.  j a v a 2s  .  c  om*/
    }
    fileNameLabel.setHref(downloadURL);
    fileNameLabel.setText(realFileName);
}

From source file:org.bonitasoft.forms.client.view.widget.TodoListTaskWidget.java

License:Open Source License

protected void handleSessionTimeout(final FormURLComponents nextFormURL) {
    DOMUtils domUtils = DOMUtils.getInstance();
    String url = urlUtils.removeURLparameters(Window.Location.getHref());
    if (!domUtils.isPageInFrame()) {
        url += "?redirectUrl=" + URL.encodeQueryString(getUrlToNextTaskForm(nextFormURL));
    }//from w w  w.j av  a  2 s .c om
    urlUtils.parentFrameRedirect(url);
}