當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestBuilder.get方法代碼示例

本文整理匯總了Java中org.apache.http.client.methods.RequestBuilder.get方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestBuilder.get方法的具體用法?Java RequestBuilder.get怎麽用?Java RequestBuilder.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.client.methods.RequestBuilder的用法示例。


在下文中一共展示了RequestBuilder.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNextPage

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public <T> Page<T> getNextPage(Page<T> currentPage) throws IOException {
    Pagination pagination = currentPage.getPagination();
    if (pagination.getNextPage() == null || pagination.getNextPage().isEmpty()) {
        return null;
    }
    RequestBuilder requestBuilder = RequestBuilder.get(pagination.getNextPage());
    requestBuilder = addHeaders(requestBuilder);
    HttpUriRequest httpUriRequest = requestBuilder.build();
    ContentItemsListingResponse response = executeRequest(httpUriRequest, ContentItemsListingResponse.class);
    RichTextElementConverter converter = new RichTextElementConverter(
            getContentLinkUrlResolver(),
            getBrokenLinkUrlResolver(),
            getRichTextElementResolver(),
            templateEngineConfig,
            stronglyTypedContentItemConverter
    );
    converter.process(response.getItems());
    return new Page<>(response, currentPage.getType(), this);
}
 
開發者ID:Kentico,項目名稱:delivery-sdk-java,代碼行數:20,代碼來源:DeliveryClient.java

示例2: createRequest

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/**
 * Creates a HttpUriRequest based on the metadata configuration.
 * @param metadata The metadata configuration.
 * @return A configured request object.
 */
private HttpUriRequest createRequest(Map<String, String> metadata) {
    String verb = metadata.getOrDefault(VERB_KEY, DEFAULT_VERB);
    String url = metadata.get(URL_KEY);
    if (url == null || url.isEmpty()) {
        throw new IllegalArgumentException("The " + URL_KEY + " must be provided and contain a valid url.");
    }
    RequestBuilder builder;
    if (GET.equals(verb)) {
        builder = RequestBuilder.get(url);
    } else if (POST.equals(verb)) {
        builder = RequestBuilder.post(url);
        String body = metadata.getOrDefault(BODY_KEY, EMPTY_BODY);
        builder.setEntity(new StringEntity(body, Charset.defaultCharset()));
    } else {
        throw new UnsupportedOperationException("This HTTP method is not currently supported: " + verb);
    }
    // Everything else is assumed to be a header
    metadata.entrySet().stream().filter(entry -> !KNOWN_KEYS.contains(entry.getKey()))
                                .forEach(entry -> builder.addHeader(entry.getKey(), entry.getValue()));
    return builder.build();
}
 
開發者ID:yahoo,項目名稱:validatar,代碼行數:27,代碼來源:JSON.java

示例3: selectRequestMethod

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder selectRequestMethod(Request request) {
    String method = request.getMethod();
    if (method == null || method.equalsIgnoreCase(HttpConstant.Method.GET)) {
        //default get
        return RequestBuilder.get();
    } else if (method.equalsIgnoreCase(HttpConstant.Method.POST)) {
        RequestBuilder requestBuilder = RequestBuilder.post();
        NameValuePair[] nameValuePair = (NameValuePair[]) request.getExtra("nameValuePair");
        if (nameValuePair != null && nameValuePair.length > 0) {
            requestBuilder.addParameters(nameValuePair);
        }
        return requestBuilder;
    } else if (method.equalsIgnoreCase(HttpConstant.Method.HEAD)) {
        return RequestBuilder.head();
    } else if (method.equalsIgnoreCase(HttpConstant.Method.PUT)) {
        return RequestBuilder.put();
    } else if (method.equalsIgnoreCase(HttpConstant.Method.DELETE)) {
        return RequestBuilder.delete();
    } else if (method.equalsIgnoreCase(HttpConstant.Method.TRACE)) {
        return RequestBuilder.trace();
    }
    throw new IllegalArgumentException("Illegal HTTP Method " + method);
}
 
開發者ID:zongtui,項目名稱:zongtui-webcrawler,代碼行數:24,代碼來源:HttpClientDownloader.java

示例4: buildGetRequest

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected HttpUriRequest buildGetRequest(String apiCall, List<NameValuePair> nameValuePairs) {
    RequestBuilder requestBuilder = RequestBuilder.get(String.format(URL_CONCAT, getBaseUrl(), apiCall));
    requestBuilder = addHeaders(requestBuilder);
    for (NameValuePair nameValuePair : nameValuePairs) {
        requestBuilder.addParameter(nameValuePair);
    }
    return requestBuilder.build();
}
 
開發者ID:Kentico,項目名稱:delivery-sdk-java,代碼行數:9,代碼來源:DeliveryClient.java

示例5: buildTokenAuthURI

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
static URI buildTokenAuthURI(final String clientId, final String authRedirect, final String... authScopes) {
	final RequestBuilder rb = RequestBuilder.get(BASE_URL_TOKEN_AUTH);

	rb.addParameter("response_type", "token");
	rb.addParameter("client_id", clientId);
	rb.addParameter("redirect_uri", authRedirect);
	rb.addParameter("scope", String.join(" ", authScopes));

	return rb.build().getURI();
}
 
開發者ID:JanStrauss,項目名稱:cathode,代碼行數:11,代碼來源:AuthUtil.java

示例6: get

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/**
 * Executes a GET request against the partner service.
 * 
 * @return The GET response.
 * @throws PartnerException
 */
@Override
public TResponse get()
{
    RequestBuilder request = RequestBuilder.get( this.buildPartnerServiceApiUri() );
    return this.send( request );
}
 
開發者ID:PartnerCenterSamples,項目名稱:Partner-Center-Java-SDK,代碼行數:13,代碼來源:PartnerServiceProxy.java

示例7: getFileContent

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
/***
 * Executes a file content request against the partner service.
 * 
 * @return: The file content stream.
 */
public InputStream getFileContent()
{
    try
    {
        // ensure the credentials are not expired
        this.validateCredentials();
        RetryableHttpCall retryableHttpCall = new RetryableHttpCall();
        CloseableHttpClient httpClient =  buildHttpClient();
        
        CloseableHttpResponse response;
        
        try
        {
            RequestBuilder request = RequestBuilder.get( this.buildPartnerServiceApiUri() );
        	response = retryableHttpCall.execute( httpClient, request.build() );
        }
        catch ( IOException e )
        {
            throw new PartnerException( e.getMessage(), this.requestContext, PartnerErrorCategory.NOT_SPECIFIED, e );
        }
        
        if ( response.getStatusLine().getStatusCode() < 400 )
        {
            return response.getEntity().getContent() == null ? null : response.getEntity().getContent();
        }
        else
        {
        	// handle the failure according to the configured policy
            throw this.getErrorHandler().handleFailedResponse( response, this.requestContext );
        }
    }
    catch ( Exception error )
    {
        throw new PartnerException( error.getMessage(), error );
    }
}
 
開發者ID:PartnerCenterSamples,項目名稱:Partner-Center-Java-SDK,代碼行數:42,代碼來源:PartnerServiceProxy.java

示例8: listLogicalNets

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listLogicalNets()
{
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(String.format(LOGICAL_NETS, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber()));
    return requestBuilder;
}
 
開發者ID:dasein-cloud,項目名稱:dasein-cloud-azurepack,代碼行數:8,代碼來源:AzurePackNetworkRequests.java

示例9: run

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
@Override
public void run(Webhook webhook, String login, String email, String name, String subject, String content) {

    SimpleWebhookApp webhookApp = (SimpleWebhookApp) webhook.getWebhookApp();
    String method = webhookApp.getMethod();
    String uri = webhookApp.getUri();
    String authorization = webhookApp.getAuthorization();

    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpUriRequest request;

    try {

        switch (method) {
            case "POST":
                request = new HttpPost(uri);
                ((HttpPost) request).setEntity(getEntity(login, email, name, subject, content));
                break;
            case "PUT":
                request = new HttpPut(uri);
                ((HttpPut) request).setEntity(getEntity(login, email, name, subject, content));
                break;
            case "GET":
                RequestBuilder requestBuilder = RequestBuilder.get(uri);
                request = addGetParams(requestBuilder, login, email, name, subject, content);
                break;
            default:
                LOGGER.log(Level.SEVERE, "Unsupported method " + method);
                return;
        }

        request.addHeader("authorization", authorization);
        HttpResponse response = httpClient.execute(request);
        try (InputStream is = response.getEntity().getContent()) {
            String s = ConverterUtils.inputStreamToString(is);
            LOGGER.log(Level.INFO, "Webhook response status " + response.getStatusLine() + " \n\t " + s);
        }

    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    } finally {
        LOGGER.log(Level.SEVERE, "Webhook runner terminated");
    }

}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:46,代碼來源:SimpleWebhookRunner.java

示例10: createRequestBuilder

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder createRequestBuilder() {
    return RequestBuilder.get();
}
 
開發者ID:yjmyzz,項目名稱:spring-oauth-client,代碼行數:4,代碼來源:HttpClientExecutor.java

示例11: get

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
protected RequestBuilder get(final URIBuilder uri) {
    return RequestBuilder.get(build(uri));
}
 
開發者ID:hashicorp,項目名稱:nomad-java-sdk,代碼行數:4,代碼來源:ApiBase.java

示例12: listVirtualDisks

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualDisks(){
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(String.format(LIST_VOLUMES, this.provider.getContext().getCloud().getEndpoint(), this.provider.getContext().getAccountNumber()));
    return requestBuilder;
}
 
開發者ID:dasein-cloud,項目名稱:dasein-cloud-azurepack,代碼行數:7,代碼來源:AzurePackVolumeRequests.java

示例13: listVMsWithVDD

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVMsWithVDD(){
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(String.format(LIST_VMS_WITH_VDD, this.provider.getContext().getCloud().getEndpoint(), this.provider.getContext().getAccountNumber()));
    return requestBuilder;
}
 
開發者ID:dasein-cloud,項目名稱:dasein-cloud-azurepack,代碼行數:7,代碼來源:AzurePackVolumeRequests.java

示例14: listVirtualMachines

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualMachines(){
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(String.format(LIST_VM_RESOURCES, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber()));
    return requestBuilder;
}
 
開發者ID:dasein-cloud,項目名稱:dasein-cloud-azurepack,代碼行數:7,代碼來源:AzurePackVMRequests.java

示例15: listVirtualMachineNetAdapters

import org.apache.http.client.methods.RequestBuilder; //導入方法依賴的package包/類
public RequestBuilder listVirtualMachineNetAdapters(String vmId, String stampId) {
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(String.format(VM_NETWORK_ADAPTERS, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber(), stampId, vmId));
    return requestBuilder;
}
 
開發者ID:dasein-cloud,項目名稱:dasein-cloud-azurepack,代碼行數:7,代碼來源:AzurePackVMRequests.java


注:本文中的org.apache.http.client.methods.RequestBuilder.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。