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


Java URIBuilder.setParameter方法代码示例

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


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

示例1: testEditList

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Test
public void testEditList() throws URISyntaxException, ClientProtocolException, IOException {
    String url = "http://127.0.0.1:8080/sjk-market-admin/admin/catalogconvertor/edit.list.d";
    URIBuilder urlb = new URIBuilder(url);

    // 参数
    urlb.setParameter("id", "1,2");
    urlb.setParameter("marketName", "eoemarket,eoemarket");
    urlb.setParameter("catalog", "1,1");
    urlb.setParameter("subCatalog", "15,8");
    urlb.setParameter("subCatalogName", "系统工具,生活娱乐1");
    urlb.setParameter("targetCatalog", "1,1");
    urlb.setParameter("targetSubCatalog", "14,9");

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(urlb.build());
    HttpResponse response = httpClient.execute(httpPost);
    logger.debug("URL:{}\n{}\n{}", url, response.getStatusLine(), response.getEntity());
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:20,代码来源:CatalogConvertorControllerTest.java

示例2: getSubgroups

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Gets a list of groups for a given group ID
 * 
 * @param groupId
 *            to fetch subgroups for
 * @return {@link List}<{@link Group}> belonging to a parent group.
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public List<Group> getSubgroups(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
    final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getsubgroups");
    uri.setParameter("group_id", groupId.toString());
    uri.setParameter("limit", MAX_RESULTS);
    final HttpRequestBase request = new HttpGet();
    request.setURI(uri.build());
    
    Page page = callApi(request, Page.class);
    final List<Group> subgroups = Arrays.asList(OM.convertValue(page.getData(), Group[].class));
    
    while (page.getHasMore())
    {
        uri.setParameter("page_token", page.getNextPageToken().toString());
        request.setURI(uri.build());
        page = callApi(request, Page.class);
        subgroups.addAll(Arrays.asList(OM.convertValue(page.getData(), Group[].class)));
    }
    
    return subgroups;
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:32,代码来源:GroupResource.java

示例3: getMemberInGroup

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Gets a user's {@link Subscription} for the specified group and member IDs
 * 
 * @return the user's {@link Subscription} for the specified group ID
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public Subscription getMemberInGroup(final Integer groupId, final Integer memberId)
        throws URISyntaxException, IOException, GroupsIOApiException
{
    if (apiClient.group().getPermissions(groupId).getViewMembers())
    {
        final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getmember");
        uri.setParameter("group_id", groupId.toString());
        uri.setParameter("sub_id", memberId.toString());
        final HttpRequestBase request = new HttpGet();
        request.setURI(uri.build());
        
        return callApi(request, Subscription.class);
    }
    else
    {
        final Error error = new Error();
        error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
        throw new GroupsIOApiException(error);
    }
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:29,代码来源:MemberResource.java

示例4: getSubscriptions

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Gets a list of {@link Subscription}s that the current user is subscribed
 * to.
 * 
 * @return {@link List}<{@link Subscription}> representing the subscriptions
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public List<Subscription> getSubscriptions() throws URISyntaxException, IOException, GroupsIOApiException
{
    final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getsubs");
    uri.setParameter("limit", MAX_RESULTS);
    final HttpGet request = new HttpGet();
    request.setURI(uri.build());
    
    Page page = callApi(request, Page.class);
    
    final List<Subscription> subscriptions = Arrays.asList(OM.convertValue(page.getData(), Subscription[].class));
    
    while (page.getHasMore())
    {
        uri.setParameter("page_token", page.getNextPageToken().toString());
        request.setURI(uri.build());
        page = callApi(request, Page.class);
        subscriptions.addAll(Arrays.asList(OM.convertValue(page.getData(), Subscription[].class)));
    }
    
    return subscriptions;
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:31,代码来源:UserResource.java

示例5: buildUri

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
URI buildUri(URI baseUri, Map<String, String> params) {

            String schemaAfterReplacements = replaceParamsInTemplate(schema, params);

            URIBuilder builder = new URIBuilder();
            builder.setScheme(baseUri.getScheme());
            builder.setHost(baseUri.getHost());
            builder.setPort(baseUri.getPort());
            String path = baseUri.normalize().getPath() + schemaAfterReplacements;
            builder.setPath(path.replaceAll("//", "/")); // Replace double slashes

            for (String templateParamKey : templateParams.keySet()) {
                String templateParamKeyAfterReplacements = replaceParamsInTemplate(templateParamKey, params);
                String templateParamValueAfterReplacements = replaceParamsInTemplate(templateParams.get(templateParamKey), params);
                builder.setParameter(templateParamKeyAfterReplacements, templateParamValueAfterReplacements);
            }


            URI result;
            try {
                result = builder.build();
            } catch (URISyntaxException e) {
                throw new WebmateApiClientException("Could not build valid API URL", e);
            }
            return result;
        }
 
开发者ID:webmate-io,项目名称:webmate-sdk-java,代码行数:27,代码来源:WebmateApiClient.java

示例6: approveMember

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Approve a member to a group
 * 
 * @param groupId
 *            of the group they should belong to
 * @param subscriptionId
 *            of the subscription they have
 * @return the user's {@link Subscription}
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public Subscription approveMember(final Integer groupId, final Integer subscriptionId)
        throws URISyntaxException, IOException, GroupsIOApiException
{
    if (apiClient.group().getPermissions(groupId).getManagePendingMembers())
    {
        final URIBuilder uri = new URIBuilder().setPath(baseUrl + "approvemember");
        uri.setParameter("group_id", groupId.toString());
        uri.setParameter("sub_id", subscriptionId.toString());
        final HttpRequestBase request = new HttpGet();
        request.setURI(uri.build());
        
        return callApi(request, Subscription.class);
    }
    else
    {
        final Error error = new Error();
        error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
        throw new GroupsIOApiException(error);
    }
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:33,代码来源:MemberResource.java

示例7: getGroup

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Gets a {@link Group} for the specified group ID
 * 
 * @return the {@link Group} for the specified group ID
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public Group getGroup(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
    if (apiClient.group().getPermissions(groupId).getManageGroupSettings())
    {
        final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getgroup");
        uri.setParameter("group_id", groupId.toString());
        final HttpRequestBase request = new HttpGet();
        request.setURI(uri.build());
        
        return callApi(request, Group.class);
    }
    else
    {
        final Error error = new Error();
        error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
        throw new GroupsIOApiException(error);
    }
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:27,代码来源:GroupResource.java

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

示例9: testEdit

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Test
public void testEdit() throws URISyntaxException, ClientProtocolException, IOException {
    String url = "http://127.0.0.1:8080/sjk-market-appsvr/app/api/cdn/tagapp/tagtopic/0/9.json";
    URIBuilder urlb = new URIBuilder(url);
    // 参数
    urlb.setParameter("tabId", "0");
    urlb.setParameter("tagId", "9");
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(urlb.build());
    HttpResponse response = httpClient.execute(httpGet);
    logger.debug("URL:{}\n{}\n{}", url, response.getStatusLine(), response.getEntity());
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:TestTagAppController.java

示例10: testBrokenLink

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Test
public void testBrokenLink() throws URISyntaxException, ClientProtocolException, IOException {
    String url = "http://127.0.0.1:8080/sjk-market-admin/market/brokenLink.d";
    URIBuilder urlb = new URIBuilder(url);
    String test = "";
    urlb.setParameter("c", test);
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httPost = new HttpPost(urlb.build());
    HttpResponse response = httpClient.execute(httPost);
    logger.debug("URL:{}\n{}\n", url, response.getStatusLine());
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:12,代码来源:MarketControllerTest.java

示例11: getMediaPath

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
protected URI getMediaPath(String action) {
    try {
        URIBuilder builder = getMediaPathBuilder(action);
        builder.setParameter("access_token", getAccessTokenOrThrow());
        return builder.build();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:10,代码来源:AMatrixHttpClient.java

示例12: getSubscription

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Gets a user's {@link Subscription} for the specified group ID
 * 
 * @return the user's {@link Subscription} for the specified group ID
 * @throws URISyntaxException
 * @throws IOException
 * @throws GroupsIOApiException
 */
public Subscription getSubscription(final Integer groupId) throws URISyntaxException, IOException, GroupsIOApiException
{
    final URIBuilder uri = new URIBuilder().setPath(baseUrl + "getsub");
    uri.setParameter("group_id", groupId.toString());
    final HttpGet request = new HttpGet();
    request.setURI(uri.build());
    
    return callApi(request, Subscription.class);
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:18,代码来源:UserResource.java

示例13: testbrokenLink

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Test
public void testbrokenLink() throws IOException, URISyntaxException {

    JSONObject object = new JSONObject();
    object.put("key", "sprSCKKWf8xUeXxEo6Bv0lE1sSjWRDkO");
    object.put("marketName", "eoemarket");
    object.put("count", 1);
    JSONArray data = new JSONArray();
    JSONObject o = new JSONObject();
    o.put("id", -1);
    o.put("link", "http://testsssssss");
    o.put("statusCode", 404);
    data.add(o);
    object.put("data", data);

    Reader input = new StringReader(object.toJSONString());
    byte[] binaryData = IOUtils.toByteArray(input, "UTF-8");
    String encodeBase64 = Base64.encodeBase64String(binaryData);

    String url = "http://localhost:8080/sjk-market/market/brokenLink.d";
    url = "http://app-t.sjk.ijinshan.com/market/brokenLink.d";
    URIBuilder builder = new URIBuilder(url);
    builder.setParameter("c", encodeBase64);
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(builder.build());
    HttpResponse response = httpclient.execute(httpPost);
    logger.debug("URI: {} , {}", url, response.getStatusLine());

    HttpEntity entity = response.getEntity();
    InputStream is = entity.getContent();
    // be convinient to debug
    String rspJSON = IOUtils.toString(is, "UTF-8");
    System.out.println(rspJSON);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:35,代码来源:ControllerTest.java

示例14: testEdit

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
@Test
public void testEdit() throws URISyntaxException, ClientProtocolException, IOException {
    String url = "http://127.0.0.1:8080/sjk-market-admin/admin/ijinshan/shift-to-ijinshan.json";
    URIBuilder urlb = new URIBuilder(url);
    // 318840 378460 hiapk 雨夜壁纸桌面主题
    // 318839 378435 hiapk APO极限滑板

    urlb.setParameter("ids", "318840,318839");
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(urlb.build());
    HttpResponse response = httpClient.execute(httpPost);
    logger.debug("URL:{}\n{}\n{}", url, response.getStatusLine(), response.getEntity());
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:14,代码来源:MarketAppControllerTest.java

示例15: LandmarkImage

import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
 * Encapsulates the Microsoft Cognitive Services REST API call to identify a landmark in an image.
 * @param imageUrl: The string URL of the image to process.
 * @return: A JSONObject describing the image, or null if a runtime error occurs.
 */
private JSONObject LandmarkImage(String imageUrl) {
    try (CloseableHttpClient httpclient = HttpClientBuilder.create().build())
    {
        // Create the URI to access the REST API call to identify a Landmark in an image.
        String uriString = uriBasePreRegion + 
                String.valueOf(subscriptionRegionComboBox.getSelectedItem()) + 
                uriBasePostRegion + uriBaseLandmark;
        URIBuilder builder = new URIBuilder(uriString);

        // Request parameters. All of them are optional.
        builder.setParameter("visualFeatures", "Categories,Description,Color");
        builder.setParameter("language", "en");

        // Prepare the URI for the REST API call.
        URI uri = builder.build();
        HttpPost request = new HttpPost(uri);

        // Request headers.
        request.setHeader("Content-Type", "application/json");
        request.setHeader("Ocp-Apim-Subscription-Key", subscriptionKeyTextField.getText());

        // Request body.
        StringEntity reqEntity = new StringEntity("{\"url\":\"" + imageUrl + "\"}");
        request.setEntity(reqEntity);

        // Execute the REST API call and get the response entity.
        HttpResponse response = httpclient.execute(request);
        HttpEntity entity = response.getEntity();

        // If we got a response, parse it and display it.
        if (entity != null)
        {
            // Return the JSONObject.
            String jsonString = EntityUtils.toString(entity);
            return new JSONObject(jsonString);
        } else {
            // No response. Return null.
            return null;
        }
    }
    catch (Exception e)
    {
        // Display error message.
        System.out.println(e.getMessage());
        return null;
    }
}
 
开发者ID:Azure-Samples,项目名称:cognitive-services-java-computer-vision-tutorial,代码行数:53,代码来源:MainFrame.java


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