List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getParams
@Override
public HttpMethodParams getParams()
From source file:net.bioclipse.opentox.api.Task.java
public static void delete(String task) throws IOException, GeneralSecurityException { HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod(task); method.getParams().setParameter("http.socket.timeout", new Integer(Activator.TIME_OUT)); client.executeMethod(method);//from w w w. ja v a 2 s . co m int status = method.getStatusCode(); switch (status) { case 200: // excellent, it worked break; case 401: throw new GeneralSecurityException("Not authorized"); case 404: // not found, well, I guess equals 'deleted' break; case 503: throw new IOException("Service unavailable"); default: throw new IOException("Unknown server state: " + status); } }
From source file:edu.northwestern.jcr.adapter.fedora.persistence.FedoraConnectorREST.java
/** * Sends an HTTP DELETE request and returns the status code. * * @param url URL of the resource//w w w . ja va 2 s .com * @return status code */ private int httpDelete(String url) { DeleteMethod deleteMethod = null; try { deleteMethod = new DeleteMethod(url); deleteMethod.setDoAuthentication(true); deleteMethod.getParams().setParameter("Connection", "Keep-Alive"); fc.getHttpClient().executeMethod(deleteMethod); return deleteMethod.getStatusCode(); } catch (Exception e) { e.printStackTrace(); log.warn("failed to delete!"); return -1; } finally { if (deleteMethod != null) { deleteMethod.releaseConnection(); } } }
From source file:com.cubeia.backoffice.wallet.client.WalletServiceClientHTTP.java
private DeleteMethod createDeleteMethod(String resource) { DeleteMethod method = new DeleteMethod(resource); // Provide custom retry handler method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(NUMBER_OF_RETRIES, false)); return method; }
From source file:com.xmlcalabash.library.HttpRequest.java
private DeleteMethod doDelete() { DeleteMethod method = new DeleteMethod(requestURI.toASCIIString()); // Provide custom retry handler is necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); for (Header header : headers) { method.addRequestHeader(header); }//w ww.j a v a2s . c o m return method; }
From source file:org.eclipse.osee.framework.core.util.HttpProcessor.java
public static String delete(URL url) throws Exception { String response = null;// ww w.jav a 2s .co m int statusCode = -1; DeleteMethod method = new DeleteMethod(url.toString()); InputStream responseInputStream = null; try { method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); statusCode = executeMethod(url, method); if (statusCode == HttpStatus.SC_ACCEPTED) { responseInputStream = method.getResponseBodyAsStream(); response = Lib.inputStreamToString(responseInputStream); } } catch (Exception ex) { throw new Exception(String.format("Error deleting resource: [%s] - status code: [%s]", url, statusCode), ex); } finally { Lib.close(responseInputStream); method.releaseConnection(); } return response; }
From source file:org.infoscoop.request.ProxyRequest.java
public int executeDelete() throws Exception { DeleteMethod method = null; try {//from w ww.j a v a2 s . c o m HttpClient client = this.newHttpClient(); method = new DeleteMethod(this.getTargetURL()); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false)); ProxyFilterContainer filterContainer = (ProxyFilterContainer) SpringUtil.getBean(filterType); return filterContainer.invoke(client, method, this); } catch (ProxyAuthenticationException e) { if (e.isTraceOn()) { log.error(this.getTargetURL()); log.error("", e); } else { log.warn(this.getTargetURL() + " : " + e.getMessage()); } return 401; } }
From source file:org.olat.test.OlatJerseyTestCase.java
public DeleteMethod createDelete(final URI requestURI, final String accept, final boolean cookie) { final DeleteMethod method = new DeleteMethod(requestURI.toString()); if (cookie) { method.getParams().setCookiePolicy(CookiePolicy.RFC_2109); }/*from w w w. j a va 2 s . co m*/ if (StringHelper.containsNonWhitespace(accept)) { method.addRequestHeader("Accept", accept); } return method; }
From source file:org.wso2.iot.integration.common.IOTHttpClient.java
public IOTResponse delete(String endpoint) { HttpClient client = new HttpClient(); try {/*from ww w .j a va 2 s .com*/ ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); Protocol https = new Protocol(Constants.HTTPS, socketFactory, Constants.HTTPS_GATEWAY_PORT); Protocol.registerProtocol(Constants.HTTPS, https); String url = backEndUrl + endpoint; DeleteMethod method = new DeleteMethod(url); method.setRequestHeader(AUTHORIZATION, authorizationString); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); IOTResponse iotResponse = new IOTResponse(); iotResponse.setStatus(client.executeMethod(method)); iotResponse.setBody(method.getResponseBodyAsString()); return iotResponse; } catch (GeneralSecurityException e) { log.error("Failure occurred at IOTResponse delete for GeneralSecurityException", e); } catch (IOException e) { log.error("Failure occurred at IOTResponse delete for IOException", e); } return null; }
From source file:org.wso2.mdm.integration.common.MDMHttpClient.java
public MDMResponse delete(String endpoint) { HttpClient client = new HttpClient(); try {/*from w ww. j a v a 2 s .co m*/ ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); Protocol https = new Protocol("https", socketFactory, 9443); Protocol.registerProtocol("https", https); String url = backEndUrl + endpoint; DeleteMethod method = new DeleteMethod(url); method.setRequestHeader(AUTHORIZATION, authrizationString); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); MDMResponse mdmResponse = new MDMResponse(); mdmResponse.setStatus(client.executeMethod(method)); mdmResponse.setBody(method.getResponseBodyAsString()); return mdmResponse; } catch (GeneralSecurityException e) { log.error("Failure occurred at MDMResponse delete for GeneralSecurityException", e); } catch (IOException e) { log.error("Failure occurred at MDMResponse delete for IOException", e); } return null; }