List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getResponseBody
@Override public byte[] getResponseBody() throws IOException
From source file:net.sf.ufsc.http.HttpFile.java
/** * @see net.sf.ufsc.File#delete()/* www . jav a 2s .co m*/ */ public void delete() throws java.io.IOException { DeleteMethod method = new DeleteMethod(this.uri.toString()); try { this.execute(method); method.getResponseBody(); } finally { method.releaseConnection(); } }
From source file:com.sa.npopa.samples.hbase.rest.client.Client.java
/** * Send a DELETE request/* ww w . ja v a 2 s. c o m*/ * @param cluster the cluster definition * @param path the path or URI * @return a Response object with response detail * @throws IOException */ public Response delete(Cluster cluster, String path) throws IOException { DeleteMethod method = new DeleteMethod(); try { int code = execute(cluster, method, null, path); Header[] headers = method.getResponseHeaders(); byte[] content = method.getResponseBody(); return new Response(code, headers, content); } finally { method.releaseConnection(); } }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation1() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation1"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);//from w ww . j a v a 2s . c om }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation2() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation2"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);/*ww w. j av a 2s.c om*/ }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation3() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation3"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);//w w w .jav a2s . co m }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation4() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation4/4/5"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);/*from ww w .ja va 2 s . com*/ }
From source file:muki.tool.JavaCompilationDeploymentTestCase.java
@Test public void testDeleteOperation5() throws Exception { String url = URL_RESOURCE1 + "/pathDeleteOperation5/55?date=2010-07-08"; DeleteMethod method = new DeleteMethod(url); int statusCode = this.getHttpClient().executeMethod(method); assertTrue("Method failed: " + method.getStatusLine(), statusCode == HttpStatus.SC_NO_CONTENT); byte[] responseBody = method.getResponseBody(); assertNull(responseBody);//from w w w. j a v a 2s .c o m }
From source file:org.alfresco.module.vti.handler.alfresco.ShareUtils.java
/** * Deletes site using REST API, http method is sent to appropriate web script * /* w ww. j av a 2 s.c o m*/ * @param user current user * @param shortName shortName of site we are going to delete * @throws HttpException * @throws IOException */ public void deleteSite(SessionUser user, String shortName) throws HttpException, IOException { HttpClient httpClient = new HttpClient(); DeleteMethod deleteSiteMethod = new DeleteMethod(getAlfrescoHostWithPort() + getAlfrescoContext() + "/s/api/sites/" + shortName + "?alf_ticket=" + user.getTicket()); try { if (logger.isDebugEnabled()) logger.debug("Trying to delete site with name: " + shortName); int status = httpClient.executeMethod(deleteSiteMethod); if (logger.isDebugEnabled()) logger.debug("Delete site method returned status: " + status); if (status != HttpStatus.SC_OK) { throw new RuntimeException( "Failed to delete site with name: " + shortName + ". Returned status is: " + status + ". \n Response from server :\n" + deleteSiteMethod.getResponseBodyAsString()); } deleteSiteMethod.getResponseBody(); } catch (Exception e) { if (logger.isDebugEnabled()) logger.debug("Fail to delete site with name: " + shortName); throw new RuntimeException(e); } finally { deleteSiteMethod.releaseConnection(); } // deletes site dashboard deleteSiteDashboard(httpClient, shortName, user); // deletes title component deleteSiteComponent(httpClient, shortName, user, "title"); // deletes navigation component deleteSiteComponent(httpClient, shortName, user, "navigation"); // deletes component-2-2 component deleteSiteComponent(httpClient, shortName, user, "component-2-2"); // deletes component-1-1 component deleteSiteComponent(httpClient, shortName, user, "component-1-1"); // deletes component-2-1 component deleteSiteComponent(httpClient, shortName, user, "component-2-1"); // deletes component-1-2 component deleteSiteComponent(httpClient, shortName, user, "component-1-2"); }
From source file:org.alfresco.module.vti.handler.alfresco.ShareUtils.java
/** * Deletes component from site//ww w . j a v a2 s.c om * * @param httpClient HTTP client * @param siteName name of the site * @param user current user * @param componentName name of the component */ private void deleteSiteComponent(HttpClient httpClient, String siteName, SessionUser user, String componentName) { DeleteMethod deleteTitleMethod = new DeleteMethod(getAlfrescoHostWithPort() + getAlfrescoContext() + "/s/remoteadm/delete/alfresco/site-data/components/page." + componentName + ".site~" + siteName + "~dashboard.xml?s=sitestore&alf_ticket=" + user.getTicket()); try { if (logger.isDebugEnabled()) logger.debug("Trying to delete site component with name: " + siteName); int status = httpClient.executeMethod(deleteTitleMethod); deleteTitleMethod.getResponseBody(); if (logger.isDebugEnabled()) logger.debug("Delete site component method returned status: " + status); } catch (Exception e) { if (logger.isDebugEnabled()) logger.debug("Fail to delete component from site with name: " + siteName); throw new RuntimeException(e); } finally { deleteTitleMethod.releaseConnection(); } }
From source file:org.alfresco.module.vti.handler.alfresco.ShareUtils.java
/** * Deletes site dashboard//from w w w .j av a2 s . c o m * * @param httpClient HTTP client * @param siteName name of the site * @param user current user */ private void deleteSiteDashboard(HttpClient httpClient, String siteName, SessionUser user) { DeleteMethod deleteDashboardMethod = new DeleteMethod(getAlfrescoHostWithPort() + getAlfrescoContext() + "/s/remoteadm/delete/alfresco/site-data/pages/site/" + siteName + "/dashboard.xml?s=sitestore&alf_ticket=" + user.getTicket()); try { if (logger.isDebugEnabled()) logger.debug("Trying to delete dashboard from site with name: " + siteName); int status = httpClient.executeMethod(deleteDashboardMethod); deleteDashboardMethod.getResponseBody(); if (logger.isDebugEnabled()) logger.debug("Delete dashboard from site method returned status: " + status); } catch (Exception e) { if (logger.isDebugEnabled()) logger.debug("Fail to delete dashboard from site with name: " + siteName); throw new RuntimeException(e); } finally { deleteDashboardMethod.releaseConnection(); } }