List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete
public HttpDelete(final String uri)
From source file:org.flowable.admin.service.engine.DecisionTableDeploymentService.java
public void deleteDeployment(ServerConfig serverConfig, HttpServletResponse httpResponse, String appDeploymentId) { HttpDelete delete = new HttpDelete(clientUtil.getServerUrl(serverConfig, clientUtil.createUriBuilder("dmn-repository/deployments/" + appDeploymentId))); clientUtil.execute(delete, httpResponse, serverConfig); }
From source file:org.kymjs.kjframe.http.HttpClientStack.java
static HttpUriRequest createHttpRequest(Request<?> request, Map<String, String> additionalHeaders) { switch (request.getMethod()) { case HttpMethod.GET: return new HttpGet(request.getUrl()); case HttpMethod.DELETE: return new HttpDelete(request.getUrl()); case HttpMethod.POST: { HttpPost postRequest = new HttpPost(request.getUrl()); postRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(postRequest, request); return postRequest; }/*from w w w .j a v a2 s . c o m*/ case HttpMethod.PUT: { HttpPut putRequest = new HttpPut(request.getUrl()); putRequest.addHeader(HEADER_CONTENT_TYPE, request.getBodyContentType()); setEntityIfNonEmptyBody(putRequest, request); return putRequest; } case HttpMethod.HEAD: return new HttpHead(request.getUrl()); case HttpMethod.OPTIONS: return new HttpOptions(request.getUrl()); case HttpMethod.TRACE: return new HttpTrace(request.getUrl()); case HttpMethod.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.talend.dataprep.api.service.command.dataset.DataSetDelete.java
private HttpRequestBase onExecute(final String dataSetId) { final boolean isDatasetUsed = isDatasetUsed(dataSetId); // if the dataset is used by preparation(s), the deletion is forbidden if (isDatasetUsed) { LOG.debug("DataSet {} is used by {} preparation(s) and cannot be deleted", dataSetId); final ExceptionContext context = ExceptionContext.build().put("dataSetId", dataSetId); throw new TDPException(DATASET_STILL_IN_USE, context); }// w w w . j av a 2s . c o m return new HttpDelete(datasetServiceUrl + "/datasets/" + dataSetId); }
From source file:com.dv.sharer.android.rest.RestHttpOperations.java
protected HttpDelete getDELETE(String urlStr) throws IOException { HttpDelete httpDelete = new HttpDelete(urlStr); httpDelete.setHeader("Content-Type", "application/json"); httpDelete.addHeader("Accept", "application/json"); return httpDelete; }
From source file:geotag.core.HttpHelper.java
private HttpHelper(String url, String queryString) { clientDeleteRequest = new HttpDelete(url + queryString); clientPostRequest = new HttpPost(url); serverURL = url;/*from w w w .j a v a2s . c om*/ }
From source file:com.appdynamics.openstack.nova.RestClient.java
static String doDelete(String url, String token) throws Exception { HttpClient httpClient = httpClientWithTrustManager(); HttpDelete delete = new HttpDelete(url); delete.addHeader("accept", xmlContentType); delete.addHeader("X-Auth-Token", token); HttpResponse response = httpClient.execute(delete); return getResponseString(httpClient, response); }
From source file:com.yahoo.gondola.container.client.ApacheHttpComponentProxyClient.java
/** * Proxies the request to the destination host. * * @param request The original request/*from w w w. j a v a 2s . c o m*/ * @param baseUri The target App URL * @return the response of the proxied request */ @Override public Response proxyRequest(ContainerRequestContext request, String baseUri) throws IOException { String method = request.getMethod(); String requestURI = request.getUriInfo().getRequestUri().getPath(); CloseableHttpResponse proxiedResponse; switch (method) { case "GET": proxiedResponse = executeRequest(new HttpGet(baseUri + requestURI), request); break; case "PUT": proxiedResponse = executeRequest(new HttpPut(baseUri + requestURI), request); break; case "POST": proxiedResponse = executeRequest(new HttpPost(baseUri + requestURI), request); break; case "DELETE": proxiedResponse = executeRequest(new HttpDelete(baseUri + requestURI), request); break; case "PATCH": proxiedResponse = executeRequest(new HttpPatch(baseUri + requestURI), request); break; default: throw new IllegalStateException("Method not supported: " + method); } return getResponse(proxiedResponse); }
From source file:org.apache.manifoldcf.scriptengine.DELETECommand.java
/** Parse and execute. Parsing begins right after the command name, and should stop before the trailing semicolon. *@param sp is the script parser to use to help in the parsing. *@param currentStream is the current token stream. *@return true to send a break signal, false otherwise. *//*from w w w . ja v a 2s . c o m*/ public boolean parseAndExecute(ScriptParser sp, TokenStream currentStream) throws ScriptException { VariableReference result = sp.evaluateExpression(currentStream); if (result == null) sp.syntaxError(currentStream, "Missing result expression"); Token t = currentStream.peek(); if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals("=")) sp.syntaxError(currentStream, "Missing '=' sign"); currentStream.skip(); VariableReference url = sp.evaluateExpression(currentStream); if (url == null) sp.syntaxError(currentStream, "Missing URL expression"); // Perform the actual GET. String urlString = sp.resolveMustExist(currentStream, url).getStringValue(); try { HttpClient client = sp.getHttpClient(); HttpDelete method = new HttpDelete(urlString); try { HttpResponse httpResponse = client.execute(method); int resultCode = httpResponse.getStatusLine().getStatusCode(); String resultJSON = sp.convertToString(httpResponse); result.setReference(new VariableResult(resultCode, resultJSON)); return false; } finally { //method.releaseConnection(); } } catch (IOException e) { throw new ScriptException(e.getMessage(), e); } }
From source file:com.sparkplatform.api.core.ConnectionApacheHttp.java
@Override public Response delete(String path, Map<String, String> options) throws SparkAPIClientException { HttpRequest r = new HttpDelete(path); setHeaders(r);//from ww w . j a v a2 s . co m return request(r); }
From source file:org.activiti.rest.service.api.history.HistoricProcessInstanceResourceTest.java
/** * Test retrieval of historic process instance. GET history/historic-process-instances/{processInstanceId} *//* w ww. j a v a 2 s . c o m*/ @Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" }) public void testGetProcessInstance() throws Exception { ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder() .processDefinitionKey("oneTaskProcess").name("myProcessName").start(); CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls .createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_OK); assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertEquals(processInstance.getId(), responseNode.get("id").textValue()); assertEquals("myProcessName", responseNode.get("name").textValue()); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); taskService.complete(task.getId()); response = executeRequest( new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl( RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_NO_CONTENT); assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode()); closeResponse(response); }