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

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

Introduction

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

Prototype

@Override
public URI getURI() throws URIException 

Source Link

Document

Returns the URI of the HTTP method

Usage

From source file:com.zimbra.cs.store.triton.TritonBlobStoreManager.java

@Override
public boolean deleteFromStore(String locator, Mailbox mbox) throws IOException {
    HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
    DeleteMethod delete = new DeleteMethod(blobApiUrl + locator);
    delete.addRequestHeader(TritonHeaders.HASH_TYPE, hashType.toString());
    try {//from w  w  w .  j av a  2 s. co m
        ZimbraLog.store.info("deleting %s", delete.getURI());
        int statusCode = HttpClientUtil.executeMethod(client, delete);
        if (statusCode == HttpStatus.SC_OK) {
            return true;
        } else {
            throw new IOException("unexpected return code during blob DELETE: " + delete.getStatusText());
        }
    } finally {
        delete.releaseConnection();
    }
}

From source file:org.apache.sling.discovery.impl.topology.connector.TopologyConnectorClient.java

/** Disconnect this connector **/
public void disconnect() {
    final String uri = connectorUrl.toString() + "." + clusterViewService.getSlingId() + ".json";
    if (logger.isDebugEnabled()) {
        logger.debug("disconnect: connectorUrl=" + connectorUrl + ", complete uri=" + uri);
    }//from w w  w .j av  a  2  s  .c  o m

    if (lastInheritedAnnouncement != null) {
        announcementRegistry.unregisterAnnouncement(lastInheritedAnnouncement.getOwnerId());
    }

    HttpClient httpClient = new HttpClient();
    final DeleteMethod method = new DeleteMethod(uri);

    try {
        String userInfo = connectorUrl.getUserInfo();
        if (userInfo != null) {
            Credentials c = new UsernamePasswordCredentials(userInfo);
            httpClient.getState()
                    .setCredentials(new AuthScope(method.getURI().getHost(), method.getURI().getPort()), c);
        }

        requestValidator.trustMessage(method, null);
        httpClient.executeMethod(method);
        if (logger.isDebugEnabled()) {
            logger.debug("disconnect: done. code=" + method.getStatusCode() + " - " + method.getStatusText());
        }
        // ignoring the actual statuscode though as there's little we can
        // do about it after this point
    } catch (URIException e) {
        logger.warn("disconnect: Got URIException: " + e);
    } catch (IOException e) {
        logger.warn("disconnect: got IOException: " + e);
    } catch (RuntimeException re) {
        logger.error("disconnect: got RuntimeException: " + re, re);
    } finally {
        method.releaseConnection();
    }
}

From source file:org.eclipsecon.e4rover.client.production.ProductionServer.java

public void leavePlayerQueue(String playerKey) throws IOException {
    DeleteMethod delete = new DeleteMethod(IServerConstants.QUEUE_RESTLET + "/" + playerKey);
    try {/*w ww  . j a  v a2s. c  o  m*/
        int resp = httpClient.executeMethod(delete);
        if (resp != HttpStatus.SC_OK) {
            throw new RobotServerException(resp, delete.getURI(), delete.getResponseBodyAsString());
        }
    } finally {
        delete.releaseConnection();
    }
}