List of usage examples for org.apache.http.client.methods HttpDelete toString
public String toString()
From source file:com.fatminds.cmis.AlfrescoCmisHelper.java
/** * This is here and needed because Alfresco CMIS and Chemistry don't play nice together for relationship deletes * as of Alfresco 3.4.2-5 & Chemistry 0.3.0. The problem is that for whatever reason Chemistry strips the "assoc:" prefix * off of the relationship ID that ends up on the end of the Delete URL, like this - /alfresco/service/cmis/rel/assoc:363. * Left to its own devices, Relationship.delete() will end up issuing a URL like /alfresco/service/cmis/rel/363, and Alfresco * will barf. This will hopefully be fixed in Alfesco 4.x. * @param proto// ww w . ja va2s.c o m * @param host * @param port * @param user * @param pass * @param assocId * @return */ public static boolean deleteRelationship(String proto, String host, int port, String user, String pass, String assocId) { DefaultHttpClient client = new DefaultHttpClient(); try { client.getCredentialsProvider().setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(user, pass)); HttpDelete delete = new HttpDelete( proto + "://" + host + ":" + port + "/alfresco/service/cmis/rel/" + assocId); log.info("Sending " + delete.toString()); HttpResponse resp = client.execute(delete); if (resp.getStatusLine().getStatusCode() > 299) { // Alf returns "204 No Content" for success... :-( throw new RuntimeException("Get failed (" + resp.getStatusLine().getStatusCode() + ") because " + resp.getStatusLine().getReasonPhrase()); } } catch (ClientProtocolException e) { e.printStackTrace(); throw new RuntimeException(e); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { client.getConnectionManager().shutdown(); } return true; }
From source file:dataServer.StorageRESTClientManager.java
public boolean deleteKPIStorage(String kpiID) { // Default HTTP response and common properties for responses HttpResponse response = null;/*from w ww . j a v a2 s. c o m*/ ResponseHandler<String> handler = null; int status = 0; String body = null; try { HttpDelete query = new HttpDelete(StreamPipes.concat("/").concat(kpiID)); System.out.println( "\n\n\n########################################################################################################\n\n\n"); System.out.println(query.toString()); System.out.println( "\n\n\n########################################################################################################\n\n\n"); response = client.execute(query); System.out.println("\n\n\nResponse:\n" + response.toString()); // Check status code status = response.getStatusLine().getStatusCode(); if (status != 200) { //throw new RuntimeException("Failed! HTTP error code: " + status); //keep the kpi in de DB System.out.println("Error accessing storage: " + status); return false; } // Get body handler = new BasicResponseHandler(); body = handler.handleResponse(response); //result return true; } catch (Exception e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); return false; } }
From source file:org.jenkinsci.plugins.skytap.SkytapUtils.java
/** * This method returns an http delete request object, given a url and the * encoded Skytap authorization token.//from ww w .java 2 s . com * * @param requestUrl * @param AuthToken * @return */ public static HttpDelete buildHttpDeleteRequest(String requestUrl, String AuthToken) { HttpDelete hd = new HttpDelete(requestUrl); String authHeaderValue = "Basic " + AuthToken; hd.addHeader("Authorization", authHeaderValue); hd.addHeader("Accept", "application/json"); hd.addHeader("Content-Type", "application/json"); JenkinsLogger.log("HTTP DELETE Request: " + hd.toString()); return hd; }