List of usage examples for org.apache.http.client.fluent Request Delete
public static Request Delete(final String uri)
From source file:com.softinstigate.restheart.integrationtest.DeleteDocumentIT.java
@Test public void testDeleteDocument() throws Exception { try {/* w w w.j a va 2 s . com*/ Response resp; // *** PUT tmpdb resp = adminExecutor.execute(Request.Put(dbTmpUri).bodyString("{a:1}", halCT) .addHeader(Headers.CONTENT_TYPE_STRING, Representation.HAL_JSON_MEDIA_TYPE)); check("check put db", resp, HttpStatus.SC_CREATED); // *** PUT tmpcoll resp = adminExecutor.execute(Request.Put(collectionTmpUri).bodyString("{a:1}", halCT) .addHeader(Headers.CONTENT_TYPE_STRING, Representation.HAL_JSON_MEDIA_TYPE)); check("check put coll1", resp, HttpStatus.SC_CREATED); // *** PUT tmpdoc resp = adminExecutor.execute(Request.Put(documentTmpUri).bodyString("{a:1}", halCT) .addHeader(Headers.CONTENT_TYPE_STRING, Representation.HAL_JSON_MEDIA_TYPE)); check("check put tmp doc", resp, HttpStatus.SC_CREATED); // try to delete without etag resp = adminExecutor.execute(Request.Delete(documentTmpUri)); check("check delete tmp doc without etag", resp, HttpStatus.SC_CONFLICT); // try to delete with wrong etag resp = adminExecutor .execute(Request.Delete(documentTmpUri).addHeader(Headers.IF_MATCH_STRING, "pippoetag")); check("check delete tmp doc with wrong etag", resp, HttpStatus.SC_PRECONDITION_FAILED); resp = adminExecutor.execute(Request.Get(documentTmpUri).addHeader(Headers.CONTENT_TYPE_STRING, Representation.HAL_JSON_MEDIA_TYPE)); //check("getting etag of tmp doc", resp, HttpStatus.SC_OK); JsonObject content = JsonObject.readFrom(resp.returnContent().asString()); String etag = content.get("_etag").asString(); // try to delete with correct etag resp = adminExecutor.execute(Request.Delete(documentTmpUri).addHeader(Headers.IF_MATCH_STRING, etag)); check("check delete tmp doc with correct etag", resp, HttpStatus.SC_NO_CONTENT); resp = adminExecutor.execute(Request.Get(documentTmpUri).addHeader(Headers.CONTENT_TYPE_STRING, Representation.HAL_JSON_MEDIA_TYPE)); check("check get deleted tmp doc", resp, HttpStatus.SC_NOT_FOUND); } finally { mongoClient.dropDatabase(dbTmpName); } }
From source file:com.qwazr.graph.GraphSingleClient.java
@Override public GraphResult deleteGraph(String graphName) { UBuilder uBuilder = new UBuilder(GRAPH_PREFIX, graphName); Request request = Request.Delete(uBuilder.build()); return commonServiceRequest(request, null, null, GraphResult.class, 200); }
From source file:org.exist.security.RestApiSecurityTest.java
@Override protected void removeCol(final String collectionName, final String uid, final String pwd) throws ApiException { final String collectionUri = REST_URI + baseUri + "/" + collectionName; final Executor exec = getExecutor(uid, pwd); try {//w ww . j a va2s. com final HttpResponse resp = exec.execute(Request.Delete(collectionUri)).returnResponse(); if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new ApiException( "Could not remove collection: " + collectionUri + ". " + getResponseBody(resp.getEntity())); } } catch (final IOException ioe) { throw new ApiException(ioe); } }
From source file:com.qwazr.cluster.client.ClusterSingleClient.java
@Override public Response unregister(String address) { try {/*from www . java2 s. c om*/ UBuilder uriBuilder = new UBuilder("/cluster"); uriBuilder.setParameter("address", address); Request request = Request.Delete(uriBuilder.build()); HttpResponse response = execute(request, null, null); HttpUtils.checkStatusCodes(response, 200); return Response.status(response.getStatusLine().getStatusCode()).build(); } catch (IOException e) { throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR); } }
From source file:com.qwazr.crawler.web.client.WebCrawlerSingleClient.java
@Override public Response abortSession(String session_name, String reason, Boolean local, String group, Integer msTimeout) {/*from w w w .j a v a2s .c om*/ try { UBuilder uriBuilder = new UBuilder("/crawler/web/sessions/", session_name) .setParameters(local, group, msTimeout).setParameterObject("reason", reason); Request request = Request.Delete(uriBuilder.build()); HttpResponse response = execute(request, null, null); HttpUtils.checkStatusCodes(response, 200, 202); return Response.status(response.getStatusLine().getStatusCode()).build(); } catch (HttpResponseEntityException e) { throw e.getWebApplicationException(); } catch (IOException e) { throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR); } }
From source file:com.jaspersoft.studio.server.utils.HttpUtils.java
public static Request delete(String url, ServerProfile sp) throws HttpException, IOException { System.out.println(url);/*from w w w.ja va 2s . co m*/ return HttpUtils.setRequest(Request.Delete(url), sp); }
From source file:com.qwazr.search.index.IndexSingleClient.java
@Override public Response deleteSchema(String schema_name) { try {//from www. jav a 2s .c o m UBuilder uriBuilder = new UBuilder("/indexes/", schema_name); Request request = Request.Delete(uriBuilder.build()); HttpResponse response = execute(request, null, null); HttpUtils.checkStatusCodes(response, 200); return Response.status(response.getStatusLine().getStatusCode()).build(); } catch (HttpResponseEntityException e) { throw e.getWebApplicationException(); } catch (IOException e) { throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR); } }
From source file:org.exist.http.urlrewrite.URLRewritingTest.java
@AfterClass public static void cleanup() throws IOException { final HttpResponse response = executor.execute(Request.Delete(getRestUri() + TEST_COLLECTION)) .returnResponse();/* w w w . jav a 2s . co m*/ assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); }
From source file:com.qwazr.database.TableSingleClient.java
@Override public Boolean deleteTable(String table_name) { try {/*ww w . j a v a2s .c o m*/ UBuilder uriBuilder = new UBuilder("/table/", table_name); Request request = Request.Delete(uriBuilder.build()); HttpResponse response = execute(request, null, null); HttpUtils.checkStatusCodes(response, 200); return true; } catch (HttpResponseEntityException e) { throw e.getWebApplicationException(); } catch (IOException e) { throw new WebApplicationException(e.getMessage(), e, Response.Status.INTERNAL_SERVER_ERROR); } }
From source file:org.elasticsearch.packaging.util.ServerUtils.java
public static void runElasticsearchTests() throws IOException { makeRequest(Request.Post("http://localhost:9200/library/book/1?refresh=true&pretty") .bodyString("{ \"title\": \"Book #1\", \"pages\": 123 }", ContentType.APPLICATION_JSON)); makeRequest(Request.Post("http://localhost:9200/library/book/2?refresh=true&pretty") .bodyString("{ \"title\": \"Book #2\", \"pages\": 456 }", ContentType.APPLICATION_JSON)); String count = makeRequest(Request.Get("http://localhost:9200/_count?pretty")); assertThat(count, containsString("\"count\" : 2")); makeRequest(Request.Delete("http://localhost:9200/_all")); }