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.obiba.opal.web.gwt.rest.client.DefaultResourceRequestBuilder.java

License:Open Source License

@Override
public DefaultResourceRequestBuilder<T> withFormBody(String... keyValues) {
    for (int i = 0; i < keyValues.length; i += 2) {
        form.put(keyValues[i], URL.encodeQueryString(keyValues[i + 1]));
    }/*from www .  j  a v  a2 s. c o m*/
    return this;
}

From source file:org.opennms.dashboard.client.portlet.ResourceGraph.java

License:Open Source License

private String buildGraphUrl(String resourceId, String report, String start, String end) {
    return "graph/graph.png?resourceId=" + URL.encodeQueryString(resourceId) + "&report="
            + URL.encodeQueryString(report) + "&start=" + start + "&end=" + end;
}

From source file:org.openremote.app.client.assets.asset.AssetViewActivity.java

License:Open Source License

@Override
public void writeAssetToView() {
    super.writeAssetToView();
    view.setIconAndType(asset.getWellKnownType().getIcon(), asset.getType());

    // Build the link manually, shorter result than AssetQueryMapper, and we must hardcode the path anyway
    String query = Values.createObject()
            .put("select", Values.createObject().put("include", Values.create("ALL")))
            .put("id", Values.create(asset.getId())).toJson();
    view.setAccessPublicReadAnchor(//  w w w.  j  a  va 2 s .  c o  m
            "/" + asset.getTenantRealm() + "/asset/public/query?q=" + URL.encodeQueryString(query));
}

From source file:org.opentaps.gwt.common.client.listviews.EntityEditableListView.java

License:Open Source License

private int makeBatchPostData(int index, String action, List<Record> records, StringBuilder sb) {
    for (Record record : records) {
        if (index > 0) {
            sb.append("&");
        }/*from   www .j  av  a  2 s.c o  m*/
        // set the submit flag
        sb.append(UtilLookup.ROW_SUBMIT_PREFIX).append(index).append("=").append("Y");
        // add the action, so the service knows what to do with the data
        sb.append("&").append(UtilLookup.PARAM_CUD_ACTION).append(UtilLookup.MULTI_ROW_DELIMITER).append(index)
                .append("=").append(URL.encodeQueryString(action));
        for (String field : record.getFields()) {
            // remove client-side permissions
            if (Permissions.isPermissionField(field)) {
                continue;
            }
            sb.append("&").append(field).append(UtilLookup.MULTI_ROW_DELIMITER).append(index).append("=");
            if (!record.isEmpty(field)) {
                sb.append(URL.encodeQueryString(record.getAsString(field)));
            }
        }
        // add additional fields that may be required in the service
        if (additionalBatchData != null) {
            for (String extraField : additionalBatchData.keySet()) {
                sb.append("&").append(extraField).append(UtilLookup.MULTI_ROW_DELIMITER).append(index)
                        .append("=").append(URL.encodeQueryString(additionalBatchData.get(extraField)));
            }
        }
        index++;
    }
    return index;
}

From source file:org.overlord.sramp.ui.client.places.PlaceUtils.java

License:Apache License

/**
 * Creates a place token in the standard query-param string format. The query parameters should be passed
 * in with a key and a value for each parameter. If one of the parameters should be present without a
 * value, pass an empty string for its associated value.  If the value of a param is null, it will be
 * excluded from the token.//  ww  w  .ja  v a  2  s  .  c o m
 * 
 * @param params param/value pairs
 * @return place token string
 */
public static String createPlaceToken(Object... params) {
    StringBuilder builder = new StringBuilder();
    boolean first = true;
    for (int i = 0; i < params.length; i += 2) {
        String key = (String) params[i];
        Object val = params[i + 1];
        String encodedValue = "";
        if (val != null) {
            if (first) {
                first = false;
            } else {
                builder.append("&");
            }
            encodedValue = URL.encodeQueryString(val.toString());
            builder.append(key).append("=").append(encodedValue);
        }
    }
    return builder.toString();
}

From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.NoVncUtils.java

License:Open Source License

private static String createHttpsRedirectUrl(String noVncPageUrl) {
    // first we hit the websocket host and port to validate the HTTPS certificate
    // see https://bugzilla.mozilla.org/show_bug.cgi?id=594502
    // we will be redirect to novnc static web page afterwards
    String redirectedUrl = SchedulerConfig.get().getNoVncUrl();
    redirectedUrl += "/redirect";
    redirectedUrl += "?url=" + URL.encodeQueryString(noVncPageUrl);
    return redirectedUrl;
}

From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.UsageView.java

License:Open Source License

private ClickHandler downloadUsageData() {
    return new ClickHandler() {
        @Override//from www .  j a  v  a2s.  com
        public void onClick(ClickEvent event) {
            String from = DATE_FORMAT.format(readDateFromFormItem(datesForm.getItem("From")));
            String to = DATE_FORMAT.format(readDateFromFormItem(datesForm.getItem("To")));

            String url = GWT.getModuleBaseURL() + "usageexporter";
            url += "?sessionId=" + LoginModel.getInstance().getSessionId();
            url += "&user=" + userSelect.getValue().toString();
            url += "&startDate=" + URL.encodeQueryString(from);
            url += "&endDate=" + URL.encodeQueryString(to);
            Window.open(url, "_blank", "");
        }
    };
}

From source file:org.pentaho.mantle.client.admin.ContentCleanerPanel.java

License:Open Source License

/**
 * @param age//  w w w.j a v a  2  s.  c  o m
 *          in milliseconds
 */
public void deleteContentNow(long age) {

    showLoadingIndicator();

    String date = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(new Date());
    String json = "{\"jobName\": \"Content Cleaner\", \"actionClass\": \"org.pentaho.platform.admin.GeneratedContentCleaner\","
            + " \"jobParameters\":[ { \"name\": \"age\", \"stringValue\": \"" + age
            + "\", \"type\": \"string\" }], \"simpleJobTrigger\": { \"endTime\": null, \"repeatCount\": \"0\", "
            + "\"repeatInterval\": \"0\", \"startTime\": \"" + date + "\", \"uiPassParam\": \"RUN_ONCE\"} }";

    RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.POST,
            GWT.getHostPageBaseURL() + "api/scheduler/job");
    scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    scheduleFileRequestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$
    try {
        scheduleFileRequestBuilder.sendRequest(json, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
            }

            public void onResponseReceived(Request request, Response response) {
                String jobId = response.getText();
                final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET,
                        GWT.getHostPageBaseURL() + "api/scheduler/jobinfo?jobId="
                                + URL.encodeQueryString(jobId));
                requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                requestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$
                requestBuilder.setHeader("accept", "application/json"); //$NON-NLS-1$//$NON-NLS-2$

                // create a timer to check if the job has finished
                Timer t = new Timer() {
                    public void run() {
                        try {
                            requestBuilder.sendRequest(null, new RequestCallback() {

                                @Override
                                public void onResponseReceived(Request request, Response response) {
                                    // if we're receiving a correct job info, then the job is still executing.
                                    // once the job is finished, it is removed from scheduler and we should receive a 404 code.
                                    if (response.getStatusCode() != Response.SC_OK) {
                                        hideLoadingIndicator();
                                        cancel();
                                    }
                                }

                                @Override
                                public void onError(Request request, Throwable throwable) {
                                    hideLoadingIndicator();
                                    cancel();
                                }
                            });
                        } catch (RequestException e) {
                            hideLoadingIndicator();
                            cancel();
                        }
                    }
                };
                t.scheduleRepeating(1000);
            }
        });
    } catch (RequestException re) {
        hideLoadingIndicator();
    }
}

From source file:org.pentaho.mantle.client.dialogs.scheduling.NewBlockoutScheduleDialog.java

License:Open Source License

@Override
protected boolean onFinish() {
    JsJobTrigger trigger = getJsJobTrigger();
    JSONObject schedule = getSchedule();

    // TODO -- Add block out verification that it is not completely blocking an existing schedule
    if (updateMode) {
        addBlockoutPeriod(schedule, trigger, "update?jobid=" + URL.encodeQueryString(editJob.getJobId())); //$NON-NLS-1$
    } else {//w  w w.  j  a  va 2  s . c o m
        addBlockoutPeriod(schedule, trigger, "add"); //$NON-NLS-1$
    }
    getCallback().okPressed();

    return true;
}

From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleParamsDialog.java

License:Open Source License

public void initDialog() {
    scheduleParamsWizardPanel = new ScheduleParamsWizardPanel(filePath);
    IWizardPanel[] wizardPanels = { scheduleParamsWizardPanel };
    setWizardPanels(wizardPanels);//from  ww w.ja  va 2  s.c om
    setWidth("800px");
    String urlPath = URL.encodePathSegment(NameUtils.encodeRepositoryPath(filePath));

    String urlParams = "";
    if (editJob != null) {
        // add all edit params to URL
        JsArray<JsJobParam> jparams = editJob.getJobParams();
        for (int i = 0; i < jparams.length(); i++) {
            urlParams += i == 0 ? "?" : "&";
            if (jparams.get(i).getValue().startsWith("[") && jparams.get(i).getValue().indexOf(",") >= 0) {
                // it's an array!
                StringTokenizer st = new StringTokenizer(jparams.get(i).getValue(), "[],");
                int tokens = st.countTokens();
                int numParamsAdded = 0;
                for (int j = 0; j < tokens; j++) {
                    String token = st.tokenAt(j);
                    if (!StringUtils.isEmpty(token)) {
                        if (numParamsAdded > 0) {
                            urlParams += "&";
                        }
                        numParamsAdded++;
                        urlParams += jparams.get(i).getName() + "=" + URL.encodeQueryString(token.trim());
                    }
                }
            } else if (jparams.get(i).getValue().startsWith("[")
                    && jparams.get(i).getValue().indexOf(".") >= 0) {
                // mondrian style param
                urlParams += jparams.get(i).getName() + "="
                        + URL.encodeQueryString(jparams.get(i).getValue().trim());
            } else if (jparams.get(i).getValue().startsWith("[") && jparams.get(i).getValue().endsWith("]")) {
                // single value, remove []
                String param = jparams.get(i).getValue().trim();
                param = param.substring(1);
                param = param.substring(0, param.length() - 1);
                urlParams += jparams.get(i).getName() + "=" + URL.encodeQueryString(param);
            } else {
                urlParams += jparams.get(i).getName() + "="
                        + URL.encodeQueryString(jparams.get(i).getValue().trim());
            }
        }
    }
    setParametersUrl(
            ScheduleHelper.getFullyQualifiedURL() + "api/repos/" + urlPath + "/parameterUi" + urlParams); //$NON-NLS-1$ //$NON-NLS-2$
    wizardDeckPanel.setHeight("100%"); //$NON-NLS-1$

    wizardDeckPanel.getElement().getParentElement().addClassName("schedule-dialog-content");
    wizardDeckPanel.getElement().getParentElement().removeClassName("dialog-content");

    setSize("650px", "450px");
    addStyleName("schedule-params-dialog");
}