Ejemplo n.º 1
0
 /** @sice 3.2M1 */
 public void addQueryStringEntry(StringBuilder builder, String key, Object value) {
   if (value != null) {
     if (value instanceof Iterable) {
       for (Object element : (Iterable<?>) value) {
         addQueryStringEntry(builder, key, element.toString());
         builder.append('&');
       }
     } else {
       addQueryStringEntry(builder, key, value.toString());
     }
   } else {
     addQueryStringEntry(builder, key, (String) null);
   }
 }
Ejemplo n.º 2
0
  /** @since 3.5M1 */
  public String toQueryString(Map<String, ?> queryParameters) {
    StringBuilder builder = new StringBuilder();

    for (Map.Entry<String, ?> entry : queryParameters.entrySet()) {
      addQueryStringEntry(builder, entry.getKey(), entry.getValue());
      builder.append('&');
    }

    return builder.toString();
  }
Ejemplo n.º 3
0
  private String getURL(String[] path, String action, String queryString) {
    StringBuilder builder = new StringBuilder(TestUtils.BASE_BIN_URL);

    builder.append(action);
    for (int i = 0; i < path.length; i++) {
      builder.append('/').append(escapeURL(path[i]));
    }

    boolean needToAddSecretToken = !Arrays.asList("view", "register", "download").contains(action);
    if (needToAddSecretToken || !StringUtils.isEmpty(queryString)) {
      builder.append('?');
    }
    if (needToAddSecretToken) {
      addQueryStringEntry(builder, "form_token", getSecretToken());
      builder.append('&');
    }
    if (!StringUtils.isEmpty(queryString)) {
      builder.append(queryString);
    }

    return builder.toString();
  }