List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete
public HttpDelete(final String uri)
From source file:com.cloud.network.brocade.BrocadeVcsApi.java
protected HttpRequestBase createMethod(String type, String uri) throws BrocadeVcsApiException { String url;/*from w w w. j a v a2 s . c o m*/ try { url = new URL(Constants.PROTOCOL, _host, Constants.PORT, uri).toString(); } catch (MalformedURLException e) { s_logger.error("Unable to build Brocade Switch API URL", e); throw new BrocadeVcsApiException("Unable to build Brocade Switch API URL", e); } if ("post".equalsIgnoreCase(type)) { return new HttpPost(url); } else if ("get".equalsIgnoreCase(type)) { return new HttpGet(url); } else if ("delete".equalsIgnoreCase(type)) { return new HttpDelete(url); } else if ("patch".equalsIgnoreCase(type)) { return new HttpPatch(url); } else { throw new BrocadeVcsApiException("Requesting unknown method type"); } }
From source file:com.spotify.helios.serviceregistration.skydns.MiniEtcdClient.java
Future<HttpResponse> delete(final String key) { final URI uri = URI.create(baseUri + key); return httpClient.execute(new HttpDelete(uri), new FutureCallback<HttpResponse>() { @Override/*from w w w. j a v a 2s.c o m*/ public void cancelled() { log.warn("Attempt to delete {} to was cancelled", key); } @Override public void completed(HttpResponse arg0) { log.info("Succeeded deleting {}", key); } @Override public void failed(Exception e) { log.warn("Failed deleting {}", key, e); } }); }
From source file:org.flowable.rest.service.api.runtime.ProcessInstanceResourceTest.java
/** * Test deleting a single process instance. *//* w w w.jav a2s . co m*/ @Deployment(resources = { "org/flowable/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" }) public void testDeleteProcessInstance() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey"); closeResponse( executeRequest( new HttpDelete(SERVER_URL_PREFIX + RestUrls .createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_NO_CONTENT)); // Check if process-instance is gone assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()); }
From source file:com.volley.toolbox.HttpClientStack.java
/** * httprequest?httprequest?httpurlrequest * Creates the appropriate subclass of HttpUriRequest for passed in request. *//*from ww w.j ava2 s . c o m*/ @SuppressWarnings("deprecation") /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) throws AuthFailureError { switch (request.getMethod()) { case Method.DEPRECATED_GET_OR_POST: { // This is the deprecated way that needs to be handled for backwards compatibility. // If the request's post body is null, then the assumption is that the request is // GET. Otherwise, it is assumed that the request is a POST. byte[] postBody = request.getPostBody(); if (postBody != null) { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getPostBodyContentType()); HttpEntity entity; entity = new ByteArrayEntity(postBody); postRequest.setEntity(entity); return postRequest; } else { return new HttpGet(request.getUrl()); } } case Method.GET: return new HttpGet(request.getUrl()); case Method.DELETE: return new HttpDelete(request.getUrl()); case Method.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); // body? -? setEntityIfNonEmptyBody(postRequest, request); return postRequest; } case Method.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case Method.HEAD: return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl()); case Method.TRACE: return new HttpTrace(request.getUrl()); case Method.PATCH: { HttpPatch patchRequest = new HttpPatch(request.getUrl()); patchRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(patchRequest, request); return patchRequest; } default: throw new IllegalStateException("Unknown request method."); } }
From source file:org.craftercms.deployer.impl.processors.HttpMethodCallProcessor.java
protected HttpUriRequest createRequest() { if (method.equalsIgnoreCase("get")) { return new HttpGet(url); } else if (method.equalsIgnoreCase("post")) { return new HttpPost(url); } else if (method.equalsIgnoreCase("put")) { return new HttpPut(url); } else if (method.equalsIgnoreCase("delete")) { return new HttpDelete(url); } else if (method.equalsIgnoreCase("head")) { return new HttpHead(url); } else if (method.equalsIgnoreCase("options")) { return new HttpOptions(url); } else if (method.equalsIgnoreCase("trace")) { return new HttpTrace(url); } else {/*from w w w.j a v a2s . c o m*/ throw new DeploymentException("HTTP method '" + method + " not recognized"); } }
From source file:com.arcbees.vcs.stash.StashApi.java
@Override public void deleteComment(Integer pullRequestId, Long commentId) throws IOException { StashComment oldComment = getComment(pullRequestId, commentId); if (oldComment != null) { String requestUrl = apiPaths.pullRequestComment(repositoryOwner, repositoryName, pullRequestId, commentId) + "?version=" + oldComment.getVersion(); HttpDelete request = new HttpDelete(requestUrl); executeRequest(httpClient, request, credentials); }/* www.j av a2 s. c o m*/ }
From source file:org.metaeffekt.dcc.commons.ant.HttpRequestTask.java
/** * Executes the task.//from w w w . j a v a 2s. c om * * @see org.apache.tools.ant.Task#execute() */ @Override public void execute() { StringBuilder sb = new StringBuilder(); sb.append(serverScheme).append("://").append(serverHostName).append(':').append(serverPort); sb.append("/").append(uri); String url = sb.toString(); BasicCredentialsProvider credentialsProvider = null; if (username != null) { log("User: " + username, Project.MSG_DEBUG); credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(new AuthScope(serverHostName, serverPort), new UsernamePasswordCredentials(username, password)); } HttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider) .build(); try { switch (httpMethod) { case GET: HttpGet get = new HttpGet(url); doRequest(httpClient, get); break; case PUT: HttpPut put = new HttpPut(url); if (body == null) { body = ""; } log("Setting body: " + body, Project.MSG_DEBUG); put.setEntity(new StringEntity(body, ContentType.create(contentType))); doRequest(httpClient, put); break; case POST: HttpPost post = new HttpPost(url); if (body == null) { body = ""; } log("Setting body: " + body, Project.MSG_DEBUG); post.setEntity(new StringEntity(body, ContentType.create(contentType))); doRequest(httpClient, post); break; case DELETE: HttpDelete delete = new HttpDelete(url); doRequest(httpClient, delete); break; default: throw new IllegalArgumentException("HttpMethod " + httpMethod + " not supported!"); } } catch (IOException e) { throw new BuildException(e); } }