List of usage examples for org.apache.http.client.methods HttpDelete getMethod
@Override
public String getMethod()
From source file:de.unioninvestment.eai.portal.portlet.crud.scripting.domain.container.rest.ReSTDelegateImpl.java
private void sendDeleteRequest(GenericItem item) throws ClientProtocolException, IOException { URI uri = createURI(item, config.getDelete().getUrl()); HttpDelete request = new HttpDelete(uri); try {//from w ww . j a v a 2 s.c o m HttpResponse response = httpClient.execute(request); auditLogger.auditReSTRequest(request.getMethod(), uri.toString(), response.getStatusLine().toString()); expectAnyStatusCode(response, HttpStatus.SC_OK, HttpStatus.SC_ACCEPTED, // marked for deletion HttpStatus.SC_NO_CONTENT); } finally { request.releaseConnection(); } }
From source file:org.sahli.asciidoc.confluence.publisher.client.http.HttpRequestFactoryTest.java
@Test public void deletePageRequest_withValidParameters_returnsValidHttpDeleteRequest() throws Exception { // arrange/*from www . ja v a 2s . co m*/ String contentId = "1234"; // act HttpDelete deletePageRequest = this.httpRequestFactory.deletePageRequest(contentId); // assert assertThat(deletePageRequest.getMethod(), is("DELETE")); assertThat(deletePageRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + contentId)); }
From source file:org.sahli.asciidoc.confluence.publisher.client.http.HttpRequestFactoryTest.java
@Test public void deleteAttachmentRequest_withValidParameters_returnsValidHttpDelete() throws Exception { // arrange/*from w w w.j a va 2s .com*/ String attachmentId = "att1234"; // act HttpDelete deleteAttachmentRequest = this.httpRequestFactory.deleteAttachmentRequest(attachmentId); // assert assertThat(deleteAttachmentRequest.getMethod(), is("DELETE")); assertThat(deleteAttachmentRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + attachmentId)); }
From source file:org.sonatype.nexus.proxy.storage.remote.httpclient.HttpClientRemoteStorage.java
@Override public void deleteItem(final ProxyRepository repository, final ResourceStoreRequest request) throws ItemNotFoundException, UnsupportedStorageOperationException, RemoteStorageException { final URL remoteUrl = appendQueryString(getAbsoluteUrlFromBase(repository, request), repository); final HttpDelete method = new HttpDelete(remoteUrl.toExternalForm()); final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method); final int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT && statusCode != HttpStatus.SC_ACCEPTED) { throw new RemoteStorageException( "The response to HTTP " + method.getMethod() + " was unexpected HTTP Code " + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase() + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]"); }/* w ww . jav a 2s. c om*/ }