当前位置: 首页>>代码示例>>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;未经允许,请勿转载。