Example usage for org.apache.http.client.methods HttpDelete HttpDelete

List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpDelete HttpDelete.

Prototype

public HttpDelete(final String uri) 

Source Link

Usage

From source file:org.elasticsearch.shell.command.HttpDeleteCommand.java

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url) throws IOException {
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(new HttpDelete(url)));
}

From source file:stormy.pythian.features.web.support.Clusters.java

private void undeploy(String clusterName, String topologyId) {
    try {/*from  ww  w.j a v  a 2  s .  c om*/
        HttpClient httpClient = HttpClientBuilder.create().build();
        HttpDelete delete = new HttpDelete(
                BASE_API_PATH + "clusters/" + clusterName + "/topologies/" + topologyId);
        httpClient.execute(delete);
    } catch (Exception ex) {
        // Nothing to do
    }
}

From source file:org.fcrepo.serialization.bagit.BagItSerializerIT.java

@Test
public void tryOneObject() throws ClientProtocolException, IOException {
    client.execute(postObjMethod("BagIt1"));
    client.execute(postDSMethod("BagIt1", "testDS", "stuff"));
    final HttpGet getObjMethod = new HttpGet(serverAddress + "objects/BagIt1/fcr:export?format=bagit");
    HttpResponse response = client.execute(getObjMethod);
    assertEquals(200, response.getStatusLine().getStatusCode());
    final String content = EntityUtils.toString(response.getEntity());
    logger.debug("Found exported object: " + content);
    client.execute(new HttpDelete(serverAddress + "objects/BagIt1"));
    logger.debug("Deleted test object.");
    final HttpPost importMethod = new HttpPost(serverAddress + "objects/fcr:import?format=bagit");
    importMethod.setEntity(new StringEntity(content));
    assertEquals("Couldn't import!", 201, getStatus(importMethod));
    final HttpGet httpGet = new HttpGet(serverAddress + "objects/BagIt1");
    httpGet.setHeader("Accepts", "application/n3");
    response = client.execute(httpGet);//ww  w  .jav  a  2 s .  c o  m
    assertEquals("Couldn't find reimported object!", 200, response.getStatusLine().getStatusCode());
    response = client.execute(new HttpGet(serverAddress + "objects/BagIt1/testDS"));
    assertEquals("Couldn't find reimported datastream!", 200, response.getStatusLine().getStatusCode());
    logger.debug("Successfully reimported!");
}

From source file:org.apache.marmotta.client.clients.ContextClient.java

public boolean delete(String uri) {
    boolean result = false;
    HttpClient httpClient = HTTPUtil.createClient(config);

    HttpDelete delete = new HttpDelete(uri);

    try {//from  ww w  .  jav a  2s.  co m

        HttpResponse response = httpClient.execute(delete);

        switch (response.getStatusLine().getStatusCode()) {
        case 200:
            log.debug(uri + "cleanned");
            result = true;
            break;
        case 404:
            log.error(uri + " is not a suitable context");
            result = false;
        default:
            log.error("error cleanning context: {} {}", new Object[] { response.getStatusLine().getStatusCode(),
                    response.getStatusLine().getReasonPhrase() });
        }

    } catch (ClientProtocolException e) {
        log.error(e.getMessage(), e);
        result = false;
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        result = false;
    } finally {
        delete.releaseConnection();
    }
    return result;

}

From source file:com.threatconnect.sdk.conn.HttpRequestExecutor.java

private HttpRequestBase getBase(String fullPath, HttpMethod type) {

    switch (type) {
    case GET://w w  w . jav a  2s .  c om
        return new HttpGet(fullPath);
    case PUT:
        return new HttpPut(fullPath);
    case POST:
        return new HttpPost(fullPath);
    case DELETE:
        return new HttpDelete(fullPath);
    }

    return null;
}

From source file:com.alignace.chargeio.net.Requestor.java

public ServerResponse delete(String url, Map<String, String> headers) {

    HttpDelete delete = new HttpDelete(url);

    for (String key : headers.keySet())
        delete.setHeader(key, headers.get(key));

    return executeRequest(delete);
}

From source file:com.agile_coder.poker.client.android.MessageSender.java

public void resetEstimates() {
    HttpClient client = new DefaultHttpClient();
    String message = host + "/poker";
    HttpDelete delete = new HttpDelete(message);
    try {//from  www  .  j  a  v a 2  s  .co  m
        HttpResponse resp = client.execute(delete);
        if (resp.getStatusLine().getStatusCode() != 204) {
            throw new IllegalStateException();
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.apache.vysper.xmpp.extension.xep0124.inttests.MethodsNotAllowedIntegrationTest.java

@Test
public void doNotAllowDelete() throws Exception {
    HttpResponse response = httpclient.execute(new HttpDelete(getServerUrl()));

    Assert.assertEquals(405, response.getStatusLine().getStatusCode());
}

From source file:org.neo4j.ogm.drivers.http.transaction.HttpTransaction.java

@Override
public void rollback() {

    try {//from w  w  w .ja v a  2  s  .  c o  m
        if (transactionManager.canRollback()) {
            HttpDelete request = new HttpDelete(url);
            request.setHeader(new BasicHeader("X-WRITE", driver.readOnly() ? "0" : "1"));
            driver.executeHttpRequest(request);
        }
    } catch (Exception e) {
        LOGGER.warn(e.getLocalizedMessage());
    } finally {
        super.rollback(); // must always be done to keep extension depth correct
    }
}