List of usage examples for org.apache.commons.httpclient.methods DeleteMethod releaseConnection
@Override public void releaseConnection()
From source file:org.iavante.sling.s3backend.S3BackendTestIT.java
private void deleteContent(String content) { // Delete the content DeleteMethod post_delete = new DeleteMethod(content); post_delete.setDoAuthentication(true); // post_delete.setRequestBody(data_delete); try {//from w w w . ja v a 2 s . com client.executeMethod(post_delete); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(204, post_delete.getStatusCode()); log.info("Borrado contenido: " + content); post_delete.releaseConnection(); }
From source file:org.intalio.tempo.workflow.tas.nuxeo.NuxeoStorageStrategy.java
/** * Implement the interface for deleting a file *///from w w w. ja v a 2 s . c o m public void deleteAttachment(Property[] props, String url) throws UnavailableAttachmentException { try { // if (!init) init(); String fileUrl = url.substring(0, url.indexOf(this.REST_DOWNLOAD)); String newUri = fileUrl + REST_DELETE; log.debug("NUXEO DELETE:" + newUri); DeleteMethod method = new DeleteMethod(newUri); httpclient.executeMethod(method); // needed for proper httpclient handling // but we do not return the value // method.getResponseBodyAsString(); method.releaseConnection(); } catch (Exception e) { throw new UnavailableAttachmentException(e); } }
From source file:org.jboss.wise.core.client.jaxrs.impl.RSDynamicClientImpl.java
public InvocationResult invoke(RequestEntity requestEntity, WiseMapper mapper) { InvocationResult result = null;//w w w . j ava 2s . co m Map<String, Object> responseHolder = new HashMap<String, Object>(); if (HttpMethod.GET == httpMethod) { GetMethod get = new GetMethod(resourceURI); setRequestHeaders(get); try { int statusCode = httpClient.executeMethod(get); // TODO: Use InputStream String response = get.getResponseBodyAsString(); responseHolder.put(InvocationResult.STATUS, Integer.valueOf(statusCode)); result = new InvocationResultImpl(InvocationResult.RESPONSE, null, response, responseHolder); // System.out.print(response); } catch (IOException e) { // TODO: } finally { get.releaseConnection(); } } else if (HttpMethod.POST == httpMethod) { PostMethod post = new PostMethod(resourceURI); setRequestHeaders(post); post.setRequestEntity(requestEntity); try { int statusCode = httpClient.executeMethod(post); String response = post.getResponseBodyAsString(); responseHolder.put(InvocationResult.STATUS, Integer.valueOf(statusCode)); result = new InvocationResultImpl(InvocationResult.RESPONSE, null, response, responseHolder); // System.out.print(response); } catch (IOException e) { // TODO: } finally { post.releaseConnection(); } } else if (HttpMethod.PUT == httpMethod) { PutMethod put = new PutMethod(resourceURI); setRequestHeaders(put); put.setRequestEntity(requestEntity); try { int statusCode = httpClient.executeMethod(put); String response = put.getResponseBodyAsString(); responseHolder.put(InvocationResult.STATUS, Integer.valueOf(statusCode)); result = new InvocationResultImpl(InvocationResult.RESPONSE, null, response, responseHolder); // System.out.print(response); } catch (IOException e) { // TODO: } finally { put.releaseConnection(); } } else if (HttpMethod.DELETE == httpMethod) { DeleteMethod delete = new DeleteMethod(resourceURI); setRequestHeaders(delete); try { int statusCode = httpClient.executeMethod(delete); String response = delete.getResponseBodyAsString(); responseHolder.put(InvocationResult.STATUS, Integer.valueOf(statusCode)); result = new InvocationResultImpl(InvocationResult.RESPONSE, null, response, responseHolder); // System.out.print(response); } catch (IOException e) { // TODO: } finally { delete.releaseConnection(); } } return result; }
From source file:org.jbpm.formbuilder.server.file.GuvnorFileService.java
@Override public void deleteFile(String packageName, String fileName) throws FileException { HttpClient client = helper.getHttpClient(); String assetName = stripFileExtension(fileName); //String assetType = extractFileExtension(fileName); DeleteMethod deleteAsset = null; try {/*from w w w. j av a 2 s . c om*/ String deleteUrl = helper.getRestBaseUrl() + URLEncoder.encode(packageName, GuvnorHelper.ENCODING) + "/assets/" + URLEncoder.encode(assetName, GuvnorHelper.ENCODING); deleteAsset = helper.createDeleteMethod(deleteUrl); helper.setAuth(client, deleteAsset); client.executeMethod(deleteAsset); } catch (IOException e) { throw new FileException("Problem deleting guvnor file", e); } catch (Exception e) { throw new FileException("Unexpected error", e); } finally { if (deleteAsset != null) { deleteAsset.releaseConnection(); } } }
From source file:org.jbpm.formbuilder.server.form.GuvnorFormDefinitionService.java
@Override public void deleteForm(String pkgName, String formId) throws FormServiceException { HttpClient client = helper.getHttpClient(); if (formId != null && !"".equals(formId)) { DeleteMethod method = null; try {//from w w w.j ava 2 s .co m String deleteUrl = helper.getApiSearchUrl(pkgName) + URLEncoder.encode(formId, GuvnorHelper.ENCODING) + ".formdef"; method = helper.createDeleteMethod(deleteUrl); helper.setAuth(client, method); client.executeMethod(method); } catch (IOException e) { throw new FormServiceException(e); } catch (Exception e) { throw new FormServiceException("Unexpected error", e); } finally { if (method != null) { method.releaseConnection(); } } } }
From source file:org.jbpm.formbuilder.server.form.GuvnorFormDefinitionService.java
@Override public void deleteFormItem(String pkgName, String formItemId) throws FormServiceException { HttpClient client = helper.getHttpClient(); if (formItemId != null && !"".equals(formItemId)) { DeleteMethod method = null; try {//from www . j a v a 2s .c o m String deleteUrl = helper.getApiSearchUrl(pkgName) + URLEncoder.encode(formItemId, GuvnorHelper.ENCODING) + ".json"; method = helper.createDeleteMethod(deleteUrl); helper.setAuth(client, method); client.executeMethod(method); } catch (IOException e) { throw new FormServiceException(e); } catch (Exception e) { throw new FormServiceException("Unexpected error", e); } finally { if (method != null) { method.releaseConnection(); } } } }
From source file:org.nuxeo.ecm.core.storage.sql.ScalityBinaryManager.java
/** * Deletes an object using its digest string. * * @param objectID//from w ww.ja va2 s .c o m */ protected void removeBinary(String objectID) { String url = PROTOCOL_PREFIX + this.bucketName + "." + this.hostBase; log.debug(url); DeleteMethod deleteMethod = new DeleteMethod(url); String contentMD5 = ""; // date to be provided to the cloud server Date currentDate = new Date(); String cloudDateString = StringGenerator.getCloudFormattedDateString(currentDate); String stringToSign = StringGenerator.getStringToSign(HTTPMethod.DELETE, contentMD5, DEFAULT_CONTENT_TYPE, this.bucketName, objectID, currentDate); try { deleteMethod.addRequestHeader("Authorization", StringGenerator.getAuthorizationString(stringToSign, awsID, awsSecret)); deleteMethod.addRequestHeader("x-amz-date", cloudDateString); deleteMethod.setPath("/" + objectID); HttpClient client = new HttpClient(); int returnCode = client.executeMethod(deleteMethod); log.debug(deleteMethod.getResponseBodyAsString()); // only for logging if (returnCode == HttpStatus.SC_NO_CONTENT) { log.info("Object " + objectID + " deleted"); } else if (returnCode == HttpStatus.SC_NOT_FOUND) { log.debug("Object " + objectID + " does not exist"); } else { String connectionMsg = "Scality connection problem. Object could not be verified"; log.debug(connectionMsg); throw new RuntimeException(connectionMsg); } deleteMethod.releaseConnection(); } catch (SignatureException e) { throw new RuntimeException(e); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.olat.restapi.CatalogTest.java
@Test public void testDeleteCatalogEntry() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()) .build();/*from w w w. jav a 2s. c o m*/ final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); assertEquals(200, code); method.releaseConnection(); final CatalogManager catalogManager = CatalogManager.getInstance(); final List<CatalogEntry> entries = catalogManager.getChildrenOf(root1); for (final CatalogEntry entry : entries) { assertFalse(entry.getKey().equals(entry2.getKey())); } }
From source file:org.olat.restapi.CatalogTest.java
@Test public void testRemoveOwner() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()) .path("owners").path(id1.getUser().getKey().toString()).build(); final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); method.releaseConnection(); assertEquals(200, code);/*from w w w . j a va 2 s.c o m*/ final CatalogManager catalogManager = CatalogManager.getInstance(); final CatalogEntry entry = catalogManager.loadCatalogEntry(entry1.getKey()); final List<Identity> identities = BaseSecurityManager.getInstance() .getIdentitiesOfSecurityGroup(entry.getOwnerGroup()); boolean found = false; for (final Identity identity : identities) { if (identity.getKey().equals(id1.getKey())) { found = true; } } assertFalse(found); }
From source file:org.olat.restapi.CourseGroupMgmtTest.java
@Test public void testDeleteCourseGroup() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final String request = "/repo/courses/" + course.getResourceableId() + "/groups/" + g1.getKey(); final DeleteMethod method = createDelete(request, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); method.releaseConnection(); assertEquals(200, code);// ww w.j a va 2 s . c o m final BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance(); final BusinessGroup bg = bgm.loadBusinessGroup(g1.getKey(), false); assertNull(bg); }