List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getStatusText
@Override
public String getStatusText()
From source file:org.sonatype.nexus.restlight.common.AbstractRESTLightClient.java
/** * <p>//from w ww. j a va 2 s . com * Low-level DELETE implementation. * </p> * <p> * Submit a DELETE request to the URL given (absolute or relative-to-base-URL depends on urlIsAbsolute flag), and * parse the response as an XML {@link Document} (JDOM) instance <b>if</b> expectResponseBody == true. Use the given * requestParams map to inject into the HTTP DELETE method. * </p> */ protected Document doDelete(final String url, final Map<String, ? extends Object> requestParams, final boolean urlIsAbsolute, final boolean expectResponseBody) throws RESTLightClientException { DeleteMethod method = urlIsAbsolute ? new DeleteMethod(url) : new DeleteMethod(baseUrl + url); addRequestParams(method, requestParams); try { client.executeMethod(method); } catch (HttpException e) { throw new RESTLightClientException("DELETE request execution failed. Reason: " + e.getMessage(), e); } catch (IOException e) { throw new RESTLightClientException("DELETE request execution failed. Reason: " + e.getMessage(), e); } int status = method.getStatusCode(); String statusText = method.getStatusText(); if (status != 200) { throw new RESTLightClientException("DELETE request failed; HTTP status: " + status + ": " + statusText); } if (expectResponseBody) { try { return new SAXBuilder().build(method.getResponseBodyAsStream()); } catch (JDOMException e) { throw new RESTLightClientException("Failed to parse response body as XML for DELETE request.", e); } catch (IOException e) { throw new RESTLightClientException("Could not retrieve body as a String from DELETE request.", e); } finally { method.releaseConnection(); } } else { method.releaseConnection(); return null; } }