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

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

Introduction

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

Prototype

@Override
public void setPath(String path) 

Source Link

Document

Sets the path of the HTTP method.

Usage

From source file:org.apache.cloudstack.network.element.SspClient.java

public boolean deleteTenantNetwork(String tenantNetworkUuid) {
    DeleteMethod method = deleteMethod;
    method.setPath("/ssp.v1/tenant-networks/" + tenantNetworkUuid);

    executeMethod(method);/* ww  w. j a v  a 2 s .co m*/
    if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
        return true;
    }
    return false;
}

From source file:org.apache.cloudstack.network.element.SspClient.java

public boolean deleteTenantPort(String tenantPortUuid) {
    DeleteMethod method = deleteMethod;
    method.setPath("/ssp.v1/tenant-ports/" + tenantPortUuid);

    executeMethod(method);//from  w  w w  .j  a  v  a  2 s .  c  o  m
    if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
        return true;
    }
    return false;
}

From source file:org.nuxeo.ecm.core.storage.sql.ScalityBinaryManager.java

/**
 * Deletes an object using its digest string.
 *
 * @param objectID/*from   w w w .j  a  va  2  s.  c o  m*/
 */
protected void removeBinary(String objectID) {
    String url = PROTOCOL_PREFIX + this.bucketName + "." + this.hostBase;
    log.debug(url);
    DeleteMethod deleteMethod = new DeleteMethod(url);
    String contentMD5 = "";

    // date to be provided to the cloud server
    Date currentDate = new Date();

    String cloudDateString = StringGenerator.getCloudFormattedDateString(currentDate);

    String stringToSign = StringGenerator.getStringToSign(HTTPMethod.DELETE, contentMD5, DEFAULT_CONTENT_TYPE,
            this.bucketName, objectID, currentDate);
    try {
        deleteMethod.addRequestHeader("Authorization",
                StringGenerator.getAuthorizationString(stringToSign, awsID, awsSecret));
        deleteMethod.addRequestHeader("x-amz-date", cloudDateString);
        deleteMethod.setPath("/" + objectID);

        HttpClient client = new HttpClient();
        int returnCode = client.executeMethod(deleteMethod);
        log.debug(deleteMethod.getResponseBodyAsString());
        // only for logging
        if (returnCode == HttpStatus.SC_NO_CONTENT) {
            log.info("Object " + objectID + " deleted");
        } else if (returnCode == HttpStatus.SC_NOT_FOUND) {
            log.debug("Object " + objectID + " does not exist");
        } else {
            String connectionMsg = "Scality connection problem. Object could not be verified";
            log.debug(connectionMsg);
            throw new RuntimeException(connectionMsg);
        }
        deleteMethod.releaseConnection();
    } catch (SignatureException e) {
        throw new RuntimeException(e);
    } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.xwiki.test.webdav.AbstractWebDAVTest.java

/**
 * Tests the DELETE method on the given url.
 * //from   ww w  .jav  a  2s . c o m
 * @param url the target url.
 * @param expect the return status expected.
 * @return the {@link HttpMethod} which contains the response.
 */
protected HttpMethod delete(String url, int expect) {
    DeleteMethod deleteMethod = new DeleteMethod();
    deleteMethod.setDoAuthentication(true);
    deleteMethod.setPath(url);
    testMethod(deleteMethod, expect);
    return deleteMethod;
}

From source file:org.xwiki.webdav.test.AbstractWebDAVTest.java

/**
 * Tests the DELETE method on the given url.
 * //ww  w  .jav a  2  s.c  o m
 * @param url the target url.
 * @param expect the return status expected.
 * @return the {@link HttpMethod} which contains the response.
 */
protected HttpMethod delete(String url, int expect) throws Exception {
    DeleteMethod deleteMethod = new DeleteMethod();
    deleteMethod.setDoAuthentication(true);
    deleteMethod.setPath(url);
    testMethod(deleteMethod, expect);
    return deleteMethod;
}