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

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

Introduction

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

Prototype

@Override
public void releaseConnection() 

Source Link

Document

Releases the connection being used by this HTTP method.

Usage

From source file:com.assemblade.client.AbstractClient.java

protected void delete(String path) throws ClientException {
    DeleteMethod delete = new DeleteMethod(baseUrl + path);
    try {//  w ww.j  ava2s  .  c  o m
        int statusCode = executeMethod(delete);
        if (statusCode != 204) {
            throw new InvalidStatusException(204, statusCode);
        }
    } finally {
        delete.releaseConnection();
    }
}

From source file:au.edu.usq.fascinator.harvester.fedora.restclient.FedoraRestClient.java

public void purgeObject(String pid, boolean force) throws IOException {
    StringBuilder uri = new StringBuilder(getBaseUrl());
    uri.append("/objects/");
    uri.append(pid);//ww w  .  j a  va2  s. co m
    uri.append("?force=");
    uri.append(force);
    DeleteMethod method = new DeleteMethod(uri.toString());
    executeMethod(method);
    method.releaseConnection();
}

From source file:com.wandisco.s3hdfs.rewrite.redirect.MultiPartFileRedirect.java

public void sendComplete() throws IOException, ServletException {
    //STEP 1. Get listing of .part's.
    GetMethod httpGet = (GetMethod) getHttpMethod(request.getScheme(), request.getServerName(),
            request.getServerPort(), "LISTSTATUS", path.getUserName(),
            ADD_WEBHDFS(path.getHdfsRootUploadPath()), GET);
    httpClient.executeMethod(httpGet);/*w  w w. j a va2  s . c o  m*/

    // STEP 2. Parse sources from listing.
    String sourceStr = readInputStream(httpGet.getResponseBodyAsStream());

    List<String> sources = parseSources(path.getHdfsRootUploadPath(), sourceStr);
    httpGet.releaseConnection();
    assert httpGet.getStatusCode() == 200;

    //STEP 3. Perform concatenation of other .part's into 1.part.
    if (sources.size() > 1) {
        Collections.sort(sources, new PartComparator(path.getHdfsRootUploadPath()));
        if (!partsAreInOrder(sources)) {
            response.setStatus(400);
            return;
        }
        doIncrementalConcat(sources);
    }

    //STEP 3. Rename concat'd 1.part as .obj
    PutMethod httpPut = (PutMethod) getHttpMethod(request.getScheme(), request.getServerName(),
            request.getServerPort(), "RENAME&destination=" + path.getFullHdfsObjPath(), path.getUserName(),
            ADD_WEBHDFS(path.getHdfsRootUploadPath() + "1" + PART_FILE_NAME), PUT);
    httpClient.executeMethod(httpPut);
    httpPut.releaseConnection();
    assert httpPut.getStatusCode() == 200;

    //STEP 4. Delete upload directory
    DeleteMethod httpDelete = (DeleteMethod) getHttpMethod(request.getScheme(), request.getServerName(),
            request.getServerPort(), "DELETE", path.getUserName(), path.getHdfsRootUploadPath(), DELETE);
    httpClient.executeMethod(httpDelete);
    httpDelete.releaseConnection();
    assert httpDelete.getStatusCode() == 200;
}

From source file:com.sun.syndication.propono.atom.client.ClientEntry.java

/**
 * Remove entry from server.// w ww  . j  a  v  a  2s .  co m
 */
public void remove() throws ProponoException {
    if (getEditURI() == null) {
        throw new ProponoException("ERROR: cannot delete unsaved entry");
    }
    DeleteMethod method = new DeleteMethod(getEditURI());
    addAuthentication(method);
    try {
        getHttpClient().executeMethod(method);
    } catch (IOException ex) {
        throw new ProponoException("ERROR: removing entry, HTTP code", ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.rometools.propono.atom.client.ClientEntry.java

/**
 * Remove entry from server./*from www.j  av a 2  s  .  c  o  m*/
 */
public void remove() throws ProponoException {
    if (getEditURI() == null) {
        throw new ProponoException("ERROR: cannot delete unsaved entry");
    }
    final DeleteMethod method = new DeleteMethod(getEditURI());
    addAuthentication(method);
    try {
        getHttpClient().executeMethod(method);
    } catch (final IOException ex) {
        throw new ProponoException("ERROR: removing entry, HTTP code", ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.atlassian.jira.web.action.setup.SetupProductBundleHelper.java

public void destroySession() {
    final HttpClient httpClient = prepareClient();
    final DeleteMethod method = new DeleteMethod(getAuthenticationUrl());
    method.setRequestHeader("Content-Type", "application/json");

    try {/* w w  w. j av  a2  s . co m*/
        httpClient.executeMethod(method);
    } catch (final IOException e) {
        log.warn("Problem with destroying session during product bundle license installation", e);
    } finally {
        method.releaseConnection();
        removeCookies();
        clearWebSudoToken();
    }
}

From source file:com.zimbra.cs.store.http.HttpStoreManager.java

@Override
public boolean deleteFromStore(String locator, Mailbox mbox) throws IOException {
    HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
    DeleteMethod delete = new DeleteMethod(getDeleteUrl(mbox, locator));
    try {/*from   w  w w  . ja  va  2s. c om*/
        int statusCode = HttpClientUtil.executeMethod(client, delete);
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
            return true;
        } else if (statusCode == HttpStatus.SC_NOT_FOUND) {
            return false;
        } else {
            throw new IOException("unexpected return code during blob DELETE: " + delete.getStatusText());
        }
    } finally {
        delete.releaseConnection();
    }
}

From source file:com.cloud.network.bigswitch.BigSwitchBcfApi.java

protected String executeDeleteObject(final String uri) throws BigSwitchBcfApiException {
    checkInvariants();//w w w  .j  a  v a  2 s  .co  m

    DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, _port);

    setHttpHeader(dm);

    executeMethod(dm);

    String hash = checkResponse(dm, "BigSwitch HTTP delete failed: ");

    dm.releaseConnection();

    return hash;
}

From source file:com.cloud.utils.rest.RESTServiceConnector.java

public void executeDeleteObject(final String uri) throws CloudstackRESTException {
    final DeleteMethod dm = (DeleteMethod) createMethod(DELETE_METHOD_TYPE, uri);
    dm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);

    executeMethod(dm);//from   w  w w  . ja va  2s . co m

    if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
        final String errorMessage = responseToErrorMessage(dm);
        dm.releaseConnection();
        s_logger.error("Failed to delete object : " + errorMessage);
        throw new CloudstackRESTException("Failed to delete object : " + errorMessage);
    }
    dm.releaseConnection();
}

From source file:com.cloud.network.bigswitch.BigSwitchVnsApi.java

protected void executeDeleteObject(String uri) throws BigSwitchVnsApiException {
    if (_host == null || _host.isEmpty()) {
        throw new BigSwitchVnsApiException("Hostname is null or empty");
    }//from  ww  w  .  j av  a 2  s  .  c o  m

    DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, 80);
    dm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
    dm.setRequestHeader(ACCEPT, CONTENT_JSON);
    dm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);

    executeMethod(dm);

    if (dm.getStatusCode() != HttpStatus.SC_OK) {
        String errorMessage = responseToErrorMessage(dm);
        dm.releaseConnection();
        s_logger.error("Failed to delete object : " + errorMessage);
        throw new BigSwitchVnsApiException("Failed to delete object : " + errorMessage);
    }
    dm.releaseConnection();
}