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


Java URIBuilder.toString方法代码示例

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


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

示例1: createSearchCategoryApiUrl

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Helper method to create request URL from SearchCategoryRequest object.
 * @param endPoint base URL string
 * @param request the object of SearchCategoryRequest used for creating URL
 * @return URL containing all the parameters from SearchCategoryRequest
 * @throws StockException if request contains invalid parameters
 * @see SearchCategoryRequest
 * @see StockException
 */
static String createSearchCategoryApiUrl(final String endPoint,
        final SearchCategoryRequest request) throws StockException {
    try {
        new URI(endPoint).toURL();
        URIBuilder uriBuilder = new URIBuilder(endPoint);
        for (Field field : request.getClass().getDeclaredFields()) {
            field.setAccessible(true);
            if (field.get(request) == null) {
                continue;
            }
            SearchParamURLMapperInternal paramAnnotation = field
                    .getAnnotation(SearchParamURLMapperInternal.class);
            if (paramAnnotation != null) {
                uriBuilder.setParameter(paramAnnotation.value(),
                        field.get(request).toString());
            }
        }
        String url = uriBuilder.toString();
        return url;
    } catch (NullPointerException | IllegalArgumentException
            | IllegalAccessException | MalformedURLException
            | URISyntaxException e) {
        throw new StockException("Could not create the search request url");
    }
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:35,代码来源:SearchCategory.java

示例2: buildCallbackUrlResponseType

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
protected String buildCallbackUrlResponseType(Authentication authentication, Service service, String redirectUri, AccessToken accessToken, List<NameValuePair> params) throws Exception {
	String state = authentication.getAttributes().get("state").toString();
	String nonce = authentication.getAttributes().get("nonce").toString();
	URIBuilder builder = new URIBuilder(redirectUri);
	StringBuilder stringBuilder = new StringBuilder();
	stringBuilder.append("access_token").append('=').append(accessToken.getId()).append('&').append("token_type").append('=').append("bearer").append('&').append("expires_in").append('=').append(this.casProperties.getTicket().getTgt().getTimeToKillInSeconds());
	params.forEach((p) -> {
		stringBuilder.append('&').append(p.getName()).append('=').append(p.getValue());
	});
	if(StringUtils.isNotBlank(state)) {
		stringBuilder.append('&').append("state").append('=').append(EncodingUtils.urlEncode(state));
	}

	if(StringUtils.isNotBlank(nonce)) {
		stringBuilder.append('&').append("nonce").append('=').append(EncodingUtils.urlEncode(nonce));
	}

	builder.setFragment(stringBuilder.toString());
	String url = builder.toString();
	return url;
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:22,代码来源:OAuth20AuthorizeEndpointController.java

示例3: createLicenseApiUrl

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Helper method to create request URL from LicenseRequest object.
 * @param endPoint base URL string
 * @param request the object of LicenseRequest used for creating URL
 * @return URL containing all the parameters from LicenseRequest
 * @throws StockException if request contains invalid parameters
 * @see LicenseRequest
 * @see StockException
 */
static String createLicenseApiUrl(final String endPoint,
        final LicenseRequest request) throws StockException {
    try {
        new URI(endPoint).toURL();
        URIBuilder uriBuilder = new URIBuilder(endPoint);
        for (Field field : request.getClass().getDeclaredFields()) {
            field.setAccessible(true);
            if (field.get(request) == null) {
                continue;
            }
            SearchParamURLMapperInternal paramAnnotation = field
                    .getAnnotation(SearchParamURLMapperInternal.class);
            if (paramAnnotation != null) {
                uriBuilder.setParameter(paramAnnotation.value(),
                        field.get(request).toString());
            }
        }
        String url = uriBuilder.toString();
        return url;
    } catch (NullPointerException | IllegalArgumentException
            | IllegalAccessException | MalformedURLException
            | URISyntaxException e) {
        throw new StockException("Could not create the license"
                + " request url");
    }
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:36,代码来源:License.java

示例4: makeNextLink

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/** Makes the `next` link for navigation purposes. */
private String makeNextLink(int skip) throws ODataException
{
   try
   {
      String selfLnk = ServiceFactory.ROOT_URL;
      URIBuilder ub = new URIBuilder(selfLnk);
      ub.setParameter("$skip", String.valueOf(skip));
      return ub.toString();
   }
   catch (URISyntaxException ex)
   {
      throw new ODataException("Cannot make next link", ex);
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:16,代码来源:Processor.java

示例5: buildUriFromRepositoryName

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
protected String buildUriFromRepositoryName(String gitUriParam, String gitServiceUrl) throws SLException {
    try {
        URIBuilder gitUriBuilder = new URIBuilder(gitServiceUrl);
        gitUriBuilder.setPath(PATH_SEPARATOR + gitUriParam);
        return gitUriBuilder.toString();
    } catch (URISyntaxException e) {
        throw new SLException(e, Messages.ERROR_PROCESSING_GIT_URI);
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:10,代码来源:ProcessGitSourceStep.java

示例6: getRedirectUrl

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
public String getRedirectUrl() throws URISyntaxException {
	URIBuilder builder = new URIBuilder(this.baseUrl + "/authorize")				
			.addParameter("client_id", this.clientId)
			.addParameter("redirect_uri", new URI(this.redirectUri).toString())
			.addParameter("response_type", "code")
			.addParameter("scopes", scopes);

	URI uri = new URI(builder.toString());

	return uri.toString();
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:12,代码来源:DashboardAuthenticationRedirectBuilder.java

示例7: postSlackCommandWithFile

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private void postSlackCommandWithFile(Map<String, String> params, byte [] fileContent, String fileName, String command, SlackMessageHandleImpl handle) {
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme(SLACK_API_SCHEME).setHost(SLACK_API_HOST).setPath(SLACK_API_PATH+"/"+command);
    for (Map.Entry<String, String> arg : params.entrySet())
    {
        uriBuilder.setParameter(arg.getKey(),arg.getValue());
    }
    HttpPost request = new HttpPost(uriBuilder.toString());
    HttpClient client = getHttpClient();
    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
    try
    {
        builder.addBinaryBody("file",fileContent, ContentType.DEFAULT_BINARY,fileName);
        request.setEntity(builder.build());
        HttpResponse response = client.execute(request);
        String jsonResponse = ReaderUtils.readAll(new InputStreamReader(response.getEntity().getContent()));
        LOGGER.debug("PostMessage return: " + jsonResponse);
        ParsedSlackReply reply = SlackJSONReplyParser.decode(parseObject(jsonResponse),this);
        handle.setReply(reply);
    }
    catch (Exception e)
    {
        // TODO : improve exception handling
        e.printStackTrace();
    }
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:27,代码来源:SlackWebSocketSessionImpl.java

示例8: 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

示例9: buildCallbackUrlResponseType

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Build callback url response type string.
 *
 * @param authentication the authentication
 * @param service        the service
 * @param redirectUri    the redirect uri
 * @param accessToken    the access token
 * @param params         the params
 * @return the string
 * @throws Exception the exception
 */
protected String buildCallbackUrlResponseType(final Authentication authentication,
                                              final Service service,
                                              final String redirectUri,
                                              final AccessToken accessToken,
                                              final List<NameValuePair> params) throws Exception {
    final String state = authentication.getAttributes().get(OAuth20Constants.STATE).toString();
    final String nonce = authentication.getAttributes().get(OAuth20Constants.NONCE).toString();

    final URIBuilder builder = new URIBuilder(redirectUri);
    final StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(OAuth20Constants.ACCESS_TOKEN)
            .append('=')
            .append(accessToken.getId())
            .append('&')
            .append(OAuth20Constants.TOKEN_TYPE)
            .append('=')
            .append(OAuth20Constants.TOKEN_TYPE_BEARER)
            .append('&')
            .append(OAuth20Constants.EXPIRES_IN)
            .append('=')
            .append(casProperties.getTicket().getTgt().getTimeToKillInSeconds());

    params.forEach(p -> stringBuilder.append('&')
            .append(p.getName())
            .append('=')
            .append(p.getValue()));

    if (StringUtils.isNotBlank(state)) {
        stringBuilder.append('&')
                .append(OAuth20Constants.STATE)
                .append('=')
                .append(EncodingUtils.urlEncode(state));
    }
    if (StringUtils.isNotBlank(nonce)) {
        stringBuilder.append('&')
                .append(OAuth20Constants.NONCE)
                .append('=')
                .append(EncodingUtils.urlEncode(nonce));
    }
    builder.setFragment(stringBuilder.toString());
    final String url = builder.toString();
    return url;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:55,代码来源:OAuth20AuthorizeEndpointController.java


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