当前位置: 首页>>代码示例>>Java>>正文


Java URIBuilder.addParameter方法代码示例

本文整理汇总了Java中org.apache.http.client.utils.URIBuilder.addParameter方法的典型用法代码示例。如果您正苦于以下问题:Java URIBuilder.addParameter方法的具体用法?Java URIBuilder.addParameter怎么用?Java URIBuilder.addParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.utils.URIBuilder的用法示例。


在下文中一共展示了URIBuilder.addParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: acceptFriend

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
VerifyUserResponse acceptFriend(String hostUrl, BaseRequest baseRequest, String passTicket, VerifyUser[] verifyUsers) throws IOException, URISyntaxException {
    final int opCode = VerifyUserOPCode.VERIFYOK.getCode();
    final int[] sceneList = new int[]{AddScene.WEB.getCode()};
    final String path = String.format(WECHAT_URL_VERIFY_USER, hostUrl);
    VerifyUserRequest request = new VerifyUserRequest();
    request.setBaseRequest(baseRequest);
    request.setOpcode(opCode);
    request.setSceneList(sceneList);
    request.setSceneListCount(sceneList.length);
    request.setSkey(baseRequest.getSkey());
    request.setVerifyContent("");
    request.setVerifyUserList(verifyUsers);
    request.setVerifyUserListSize(verifyUsers.length);

    URIBuilder builder = new URIBuilder(path);
    builder.addParameter("r", String.valueOf(System.currentTimeMillis()));
    builder.addParameter("pass_ticket", passTicket);
    final URI uri = builder.build().toURL().toURI();

    ResponseEntity<String> responseEntity
            = restTemplate.exchange(uri, HttpMethod.POST, new HttpEntity<>(request, this.postHeader), String.class);
    return jsonMapper.readValue(WechatUtils.textDecode(responseEntity.getBody()), VerifyUserResponse.class);
}
 
开发者ID:kanjielu,项目名称:jeeves,代码行数:24,代码来源:WechatHttpServiceInternal.java

示例2: buildAPICall

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
public static String buildAPICall(APICall query, Map<String, String> parameters) throws Exception
{
	if(query != null && StringUtils.isNotBlank(query.getBaseURL()))
	{
		logger.debug("APICall Base URL: " + query.getBaseURL());
		URIBuilder builder = new URIBuilder(query.getBaseURL());
		if(parameters != null && !parameters.isEmpty() && query.HasParameters())
		{
			for (Map.Entry<String, String> entry : parameters.entrySet())
			{
			    String key = entry.getKey();
			    if(StringUtils.isNotBlank(key) && query.getParameters().contains(key))
			    {
					String value = entry.getValue();
					builder.addParameter(key, value);
					logger.debug("Added Parameter: key=" + key + ", value=" + value);
			    }
			}
		}
		
		return builder.build().toString();
	}
	return null;
}
 
开发者ID:scriptkittie,项目名称:bandcamp-api,代码行数:25,代码来源:ConfigUtil.java

示例3: createTreeRequest

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private HttpRequestBase createTreeRequest(Long parentId) {
    try {
        URIBuilder builder = new URIBuilder(serverParameters.getServerUrl()
                + serverParameters.getProjectTreeUrl());
        builder.addParameter("parentId", String.valueOf(parentId));

        HttpGet get = new HttpGet(builder.build());
        setDefaultHeader(get);
        if (isSecure()) {
            addAuthorizationToRequest(get);
        }
        return get;
    } catch (URISyntaxException e) {
        throw new ApplicationException(e.getMessage(), e);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:17,代码来源:DatasetListHandler.java

示例4: buildURI

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private URI buildURI() {
    try {
        URIBuilder builder = new URIBuilder(httpServiceInfo.getUrl()).setCharset(CHARSET);
        for (Map.Entry<String, String> param : parameters.entrySet()) {
            String value = param.getValue();
            if (value == null || Constants.JSON_BODY.equals(param.getKey())) {
                continue;
            }
            builder.addParameter(param.getKey(), value);
        }
        return builder.build();
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:17,代码来源:HttpServiceRequest.java

示例5: buildUri

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private static URI buildUri(String pathPrefix, String path, Map<String, String> params) {
    Objects.requireNonNull(path, "path must not be null");
    try {
        String fullPath;
        if (pathPrefix != null) {
            if (path.startsWith("/")) {
                fullPath = pathPrefix + path;
            } else {
                fullPath = pathPrefix + "/" + path;
            }
        } else {
            fullPath = path;
        }

        URIBuilder uriBuilder = new URIBuilder(fullPath);
        for (Map.Entry<String, String> param : params.entrySet()) {
            uriBuilder.addParameter(param.getKey(), param.getValue());
        }
        return uriBuilder.build();
    } catch(URISyntaxException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestClient.java

示例6: runCommand

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Override
public int runCommand() {
    try {
        String url = serverParameters.getServerUrl() + getRequestUrl();
        URIBuilder builder = new URIBuilder(String.format(url, referenceId));
        if (geneFileId != null) {
            builder.addParameter("geneFileId", String.valueOf(geneFileId));
        }
        HttpPut put = new HttpPut(builder.build());
        setDefaultHeader(put);
        if (isSecure()) {
            addAuthorizationToRequest(put);
        }
        String result = RequestManager.executeRequest(put);
        checkAndPrintRegistrationResult(result, printJson, printTable);
    } catch (URISyntaxException e) {
        throw new ApplicationException(e.getMessage(), e);
    }
    return 0;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:21,代码来源:GeneAddingHandler.java

示例7: build

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Creates a URI for the requested api and method
 * [bittrex-api-url]/[version]/[api]/[method]
 * 
 * @param api
 *            API to use
 * @param method
 *            String literal representing the methodname
 * @param params
 *            URI Parameter
 * @return Bittrex API URI
 */
public static URI build(String api, String method, Map<String, String> params) {
	final URIBuilder builder = new URIBuilder();
	builder.setScheme(SCHEME);
	builder.setHost(HOST);
	builder.setPath(String.format("%s/%s/%s/%s", API_PATH, VERSION, api, method));
	if(params == null) {
		params = new HashMap<>();
	}
	
	for(Entry<String, String> paramEntry : params.entrySet()) {
		builder.addParameter(paramEntry.getKey(), paramEntry.getValue());
	}

	try {
		return builder.build();
	} catch (URISyntaxException e) {
		// Do
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:Lyhnx,项目名称:bittrex-api-wrapper,代码行数:35,代码来源:BittrexUri.java

示例8: constructServiceUrl

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Construct service url string.
 *
 * @param request      the request
 * @param response     the response
 * @param wsfedRequest the ws federation request
 * @return the service url
 */
protected String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response,
                                     final WSFederationRequest wsfedRequest) {
    try {
        final URIBuilder builder = new URIBuilder(this.callbackService.getId());

        builder.addParameter(WSFederationConstants.WA, wsfedRequest.getWa());
        builder.addParameter(WSFederationConstants.WREPLY, wsfedRequest.getWreply());
        builder.addParameter(WSFederationConstants.WTREALM, wsfedRequest.getWtrealm());

        if (StringUtils.isNotBlank(wsfedRequest.getWctx())) {
            builder.addParameter(WSFederationConstants.WCTX, wsfedRequest.getWctx());
        }
        if (StringUtils.isNotBlank(wsfedRequest.getWfresh())) {
            builder.addParameter(WSFederationConstants.WREFRESH, wsfedRequest.getWfresh());
        }
        if (StringUtils.isNotBlank(wsfedRequest.getWhr())) {
            builder.addParameter(WSFederationConstants.WHR, wsfedRequest.getWhr());
        }
        if (StringUtils.isNotBlank(wsfedRequest.getWreq())) {
            builder.addParameter(WSFederationConstants.WREQ, wsfedRequest.getWreq());
        }

        final URI url = builder.build();

        LOGGER.debug("Built service callback url [{}]", url);
        return org.jasig.cas.client.util.CommonUtils.constructServiceUrl(request, response,
                url.toString(), casProperties.getServer().getName(),
                CasProtocolConstants.PARAMETER_SERVICE,
                CasProtocolConstants.PARAMETER_TICKET, false);
    } catch (final Exception e) {
        throw new SamlException(e.getMessage(), e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:42,代码来源:BaseWSFederationRequestController.java

示例9: createURL

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private URL createURL(String collection, String resource, String subResource,
    Map<String, ?> parameters) throws IOException {
  try {
    StringBuilder sb = new StringBuilder();
    sb.append(kmsUrl);
    if (collection != null) {
      sb.append(collection);
      if (resource != null) {
        sb.append("/").append(URLEncoder.encode(resource, UTF8));
        if (subResource != null) {
          sb.append("/").append(subResource);
        }
      }
    }
    URIBuilder uriBuilder = new URIBuilder(sb.toString());
    if (parameters != null) {
      for (Map.Entry<String, ?> param : parameters.entrySet()) {
        Object value = param.getValue();
        if (value instanceof String) {
          uriBuilder.addParameter(param.getKey(), (String) value);
        } else {
          for (String s : (String[]) value) {
            uriBuilder.addParameter(param.getKey(), s);
          }
        }
      }
    }
    return uriBuilder.build().toURL();
  } catch (URISyntaxException ex) {
    throw new IOException(ex);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:KMSClientProvider.java

示例10: createURLFromList

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private URL createURLFromList(String collection, List<String> resources, String subResource,
                      Map<String, ?> parameters) throws IOException
{
  try {
    StringBuilder sb = new StringBuilder();
    sb.append(kmsUrl);
    if (collection != null) {
      sb.append(collection);
      if (resources != null) {
        boolean foundNotNull = false;
        for (String resource : resources) {
          if (resource != null) {
            sb.append("/").append(URLEncoder.encode(resource, UTF8));
            foundNotNull = true;
          }
        }
        if (foundNotNull && subResource != null) {
          sb.append("/").append(subResource);
        }
      }
    }
    URIBuilder uriBuilder = new URIBuilder(sb.toString());
    if (parameters != null) {
      for (Map.Entry<String, ?> param : parameters.entrySet()) {
        Object value = param.getValue();
        if (value instanceof String) {
          uriBuilder.addParameter(param.getKey(), (String) value);
        } else {
          for (String s : (String[]) value) {
            uriBuilder.addParameter(param.getKey(), s);
          }
        }
      }
    }
    return uriBuilder.build().toURL();
  } catch (URISyntaxException ex) {
    throw new IOException(ex);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:40,代码来源:KMSPREClientProvider.java

示例11: createURLFromList

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private URL createURLFromList(String collection, List<String> resources, String subResource,
                              Map<String, ?> parameters) throws IOException
{
  try {
    StringBuilder sb = new StringBuilder();
    sb.append(renUrl);
    if (collection != null) {
      sb.append(collection);
      if (resources != null) {
        boolean foundNotNull = false;
        for (String resource : resources) {
          if (resource != null) {
            sb.append("/").append(URLEncoder.encode(resource, UTF8));
            foundNotNull = true;
          }
        }
        if (foundNotNull && subResource != null) {
          sb.append("/").append(subResource);
        }
      }
    }
    URIBuilder uriBuilder = new URIBuilder(sb.toString());
    if (parameters != null) {
      for (Map.Entry<String, ?> param : parameters.entrySet()) {
        Object value = param.getValue();
        if (value instanceof String) {
          uriBuilder.addParameter(param.getKey(), (String) value);
        } else {
          for (String s : (String[]) value) {
            uriBuilder.addParameter(param.getKey(), s);
          }
        }
      }
    }
    return uriBuilder.build().toURL();
  } catch (URISyntaxException ex) {
    throw new IOException(ex);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:40,代码来源:ReEncryptionClientProvider.java

示例12: runCommand

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Override public int runCommand() {
    //AbstractResultPrinter printer = AbstractResultPrinter.getPrinter(false, "%s");
    try {
        URIBuilder builder = new URIBuilder(serverParameters.getServerUrl() + getRequestUrl());
        if (chrName != null) {
            builder.addParameter("chromosomeName", chrName);
        }
        if (startIndex != null) {
            builder.addParameter("startIndex", startIndex.toString());
        }
        if (endIndex != null) {
            builder.addParameter("endIndex", endIndex.toString());
        }

        HttpPost post = new HttpPost(builder.build());
        setDefaultHeader(post);
        post.setEntity(
                new StringEntity(getMapper().writeValueAsString(new UrlRequest(dataset, ids))));

        String result = RequestManager.executeRequest(post);

        isResultOk(result);
        String url = getResult(result, String.class);
        url = serverParameters.getServerUrl() + url;

        AbstractResultPrinter printer;
        if (!printJson && !printTable) {
            printer = AbstractResultPrinter.getPrinter(true, "%s");
        } else {
            printer = AbstractResultPrinter.getPrinter(printTable, "%s");
        }
        printer.printSimple(url);
        return 0;
    } catch (URISyntaxException | JsonProcessingException | UnsupportedEncodingException e) {
        throw new ApplicationException(e.getMessage(), e);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:38,代码来源:UrlGeneratorHandler.java

示例13: buildUri

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
static URI buildUri(String path, Map<String, String> params) {
    Objects.requireNonNull(path, "path must not be null");
    try {
        URIBuilder uriBuilder = new URIBuilder(path);
        for (Map.Entry<String, String> param : params.entrySet()) {
            uriBuilder.addParameter(param.getKey(), param.getValue());
        }
        return uriBuilder.build();
    } catch(URISyntaxException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:13,代码来源:HttpClient.java

示例14: adicionarFiltros

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private void adicionarFiltros(HttpRequestBase httpRequestClient, Map<String, String> filters)
        throws URISyntaxException {
    if (filters != null && !filters.isEmpty()) {
        URIBuilder uriBuilder = new URIBuilder(httpRequestClient.getURI());

        for (String key : filters.keySet()) {
            uriBuilder.addParameter(key, filters.get(key));
        }

        httpRequestClient.setURI(uriBuilder.build());
    }
}
 
开发者ID:pjbank,项目名称:pjbank-java-sdk,代码行数:13,代码来源:CartaoCreditoManager.java

示例15: createSearchFilesApiUrl

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Creates the search request url from search request.
 *
 * @param endpoint
 *            base url string
 * @param request
 *            request object containing search parameters
 * @return url containing all the user search parameters
 * @throws StockException
 *             if request object contains invalid parameters
 * @see SearchFilesRequest
 * @see StockException
 */
static String createSearchFilesApiUrl(final String endpoint,
        final SearchFilesRequest request) throws StockException {

    try {
        new URI(endpoint).toURL();
        URIBuilder uriBuilder = new URIBuilder(endpoint);
        if (!request.getLocale().isEmpty()) {
            uriBuilder.setParameter(LOCALE, request.getLocale());
        }
        SearchParameters searchParams = request.getSearchParams();
        for (Field field : searchParams.getClass().getDeclaredFields()) {
            field.setAccessible(true);

            if (field.get(searchParams) == null) {
                continue;
            }

            SearchParamURLMapperInternal paramAnnotation = field
                    .getAnnotation(SearchParamURLMapperInternal.class);
            if (paramAnnotation != null) {
                String paramName = SEARCH_PARAMS_PREFIX
                        + paramAnnotation.value();
                if (field.getType().isArray()) {
                    Object arrayObj = field.get(searchParams);
                    int length = Array.getLength(arrayObj);
                    for (int i = 0; i < length; i++) {
                        uriBuilder.setParameter(paramName,
                                Array.get(arrayObj, i).toString());
                    }
                } else if (paramAnnotation.type().equals(
                        SearchParamURLMapperInternal.BOOLEAN_TO_INTEGER)) {
                    Boolean bool = (Boolean) field.get(searchParams);
                    if (bool) {
                        uriBuilder.setParameter(paramName, "1");
                    } else {
                        uriBuilder.setParameter(paramName, "0");
                    }
                } else {
                    uriBuilder.setParameter(paramName,
                            field.get(searchParams).toString());
                }
            }
        }

        ResultColumn[] resultColumns = request.getResultColumns();
        if (resultColumns != null) {
            for (int i = 0; i < Array.getLength(resultColumns); i++) {
                uriBuilder.addParameter(RESULT_COLUMNS,
                        resultColumns[i].toString());
            }
        }
        String url = uriBuilder.toString();
        return url;
    } catch (NullPointerException | IllegalArgumentException
            | IllegalAccessException
            | URISyntaxException | MalformedURLException e) {
        throw new StockException("Could not create the search request url");
    }
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:73,代码来源:SearchFiles.java


注:本文中的org.apache.http.client.utils.URIBuilder.addParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。