Example usage for org.apache.commons.httpclient.methods DeleteMethod getName

List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getName

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods DeleteMethod getName.

Prototype

public String getName() 

Source Link

Usage

From source file:org.dasein.persist.riak.RiakCache.java

@Override
public void remove(Transaction xaction, T item) throws PersistenceException {
    startCall("remove");
    try {//w  w  w  . j a  v a2  s  .c  o m
        StringBuilder url = new StringBuilder();

        url.append(getEndpoint());
        url.append("buckets/");
        url.append(getBucket());
        url.append("/keys/");
        url.append(getKeyValue(item));

        HttpClient client = getClient();
        DeleteMethod delete = new DeleteMethod(url.toString());
        int code;

        try {
            if (wire.isDebugEnabled()) {
                try {
                    wire.debug(delete.getName() + " " + url.toString());
                    wire.debug("");
                    for (Header h : delete.getRequestHeaders()) {
                        wire.debug(h.getName() + ": " + h.getValue());
                    }
                    wire.debug("");
                } catch (Throwable ignore) {
                    // ignore
                }
            }
            code = client.executeMethod(delete);
        } catch (HttpException e) {
            throw new PersistenceException("HttpException during GET: " + e.getMessage());
        } catch (IOException e) {
            throw new PersistenceException("IOException during GET: " + e.getMessage());
        }
        try {
            String body = delete.getResponseBodyAsString();

            if (wire.isDebugEnabled()) {
                try {
                    wire.debug("----------------------------------------");
                    wire.debug("");
                    wire.debug(delete.getStatusLine().getStatusCode() + " "
                            + delete.getStatusLine().getReasonPhrase());
                    wire.debug("");
                    if (body != null) {
                        wire.debug(body);
                        wire.debug("");
                    }
                } catch (Throwable ignore) {
                    // ignore
                }
            }
            if (code != HttpStatus.SC_NO_CONTENT && code != HttpStatus.SC_NOT_FOUND) {
                throw new PersistenceException(code + ": " + body);
            }
            getCache().release(item);
        } catch (IOException e) {
            throw new PersistenceException(e);
        }
    } finally {
        endCall("remove");
    }
}

From source file:org.sonatype.nexus.proxy.storage.remote.commonshttpclient.CommonsHttpClientRemoteStorage.java

@Override
public void deleteItem(ProxyRepository repository, ResourceStoreRequest request)
        throws ItemNotFoundException, UnsupportedStorageOperationException, RemoteStorageException {
    URL remoteURL = getAbsoluteUrlFromBase(repository, request);

    DeleteMethod method = new DeleteMethod(remoteURL.toString());

    try {//from w  w w .java 2  s.  c o m
        int response = executeMethod(repository, request, method, remoteURL);

        if (response != HttpStatus.SC_OK && response != HttpStatus.SC_NO_CONTENT
                && response != HttpStatus.SC_ACCEPTED) {
            throw new RemoteStorageException("The response to HTTP " + method.getName()
                    + " was unexpected HTTP Code " + response + " : " + HttpStatus.getStatusText(response)
                    + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath()
                    + "\", remoteUrl=\"" + remoteURL.toString() + "\"]");
        }
    } finally {
        method.releaseConnection();
    }
}