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


Java HttpPatch.releaseConnection方法代碼示例

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


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

示例1: setProperty

import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected HttpResponse setProperty(final String pid, final String txId,
                                   final String propertyUri,
                                   final String value) throws IOException {
    final HttpPatch postProp = new HttpPatch(serverAddress
            + (txId != null ? txId + "/" : "") + pid);
    postProp.setHeader(CONTENT_TYPE, "application/sparql-update");
    final String updateString =
            "INSERT { <"
                    + serverAddress + pid
                    + "> <" + propertyUri + "> \"" + value + "\" } WHERE { }";
    postProp.setEntity(new StringEntity(updateString));
    final HttpResponse dcResp = execute(postProp);
    assertEquals(dcResp.getStatusLine().toString(),
            204, dcResp.getStatusLine().getStatusCode());
    postProp.releaseConnection();
    return dcResp;
}
 
開發者ID:fcrepo4,項目名稱:fcrepo4,代碼行數:18,代碼來源:AbstractResourceIT.java

示例2: patch

import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
public static TransportResponse patch(TransportTools nuts)
		throws ClientProtocolException, IOException {

	DefaultHttpClient httpclient = new DefaultHttpClient();
	HttpPatch httppatch = new HttpPatch(nuts.urlString());

	if (nuts.headers() != null) {
		for (Map.Entry<String, String> headerEntry : nuts.headers().entrySet()) {
			httppatch.addHeader(headerEntry.getKey(), headerEntry.getValue());
		}
	}
	
	if (nuts.pairs() != null && (nuts.contentType() ==null)) {
		httppatch.setEntity(new UrlEncodedFormEntity(nuts.pairs()));
	}
	
	if (nuts.contentType() !=null) {
		httppatch.setEntity(new StringEntity(nuts.contentString(),nuts.contentType()));
	}

	TransportResponse transportResp = null;
	try {
		  httpclient.execute(httppatch);
		//transportResp = new TransportResponse(httpResp.getStatusLine(), httpResp.getEntity(), httpResp.getLocale());
	} finally {
		httppatch.releaseConnection();
	}
	return transportResp;

}
 
開發者ID:megamsys,項目名稱:megam_api_jvm,代碼行數:31,代碼來源:TransportMachinery.java

示例3: executeUpdateObject

import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected <T> boolean executeUpdateObject(T newObject, String uri) throws BrocadeVcsApiException {

        final boolean result = true;

        if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
            throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
        }

        final HttpPatch pm = (HttpPatch)createMethod("patch", uri);
        pm.setHeader("Accept", "application/vnd.configuration.resource+xml");

        pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));

        final HttpResponse response = executeMethod(pm);

        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {

            String errorMessage;
            try {
                errorMessage = responseToErrorMessage(response);
            } catch (final IOException e) {
                s_logger.error("Failed to update object : " + e.getMessage());
                throw new BrocadeVcsApiException("Failed to update object : " + e.getMessage());
            }

            pm.releaseConnection();
            s_logger.error("Failed to update object : " + errorMessage);
            throw new BrocadeVcsApiException("Failed to update object : " + errorMessage);
        }

        pm.releaseConnection();

        return result;
    }
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:35,代碼來源:BrocadeVcsApi.java

示例4: setProperty

import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected CloseableHttpResponse setProperty(final String id, final String txId, final String propertyUri,
        final String value) throws IOException {
    final HttpPatch postProp = new HttpPatch(serverAddress + (txId != null ? txId + "/" : "") + id);
    postProp.setHeader(CONTENT_TYPE, "application/sparql-update");
    final String updateString =
            "INSERT { <" + serverAddress + id + "> <" + propertyUri + "> \"" + value + "\" } WHERE { }";
    postProp.setEntity(new StringEntity(updateString));
    final CloseableHttpResponse dcResp = execute(postProp);
    assertEquals(dcResp.getStatusLine().toString(), NO_CONTENT.getStatusCode(), getStatus(dcResp));
    postProp.releaseConnection();
    return dcResp;
}
 
開發者ID:fcrepo4,項目名稱:fcrepo4,代碼行數:13,代碼來源:AbstractResourceIT.java


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