IndexResource extends AbstractSubResource { @DELETE @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.delete", absolute = true) public Response deleteIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName, final JSONObject json) { this.setRequestObject(json); return this.deleteIndex(graphName, indexName); } IndexResource();  IndexResource(final UriInfo ui, final HttpServletRequest req, final RexsterApplication ra); @OPTIONS Response optionsAllIndices(); @GET @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.collection.get", absolute = true) Response getAllIndices(@PathParam("graphname") final String graphName); @OPTIONS @Path("/{indexName}") Response optionsElementsFromIndex(); @GET @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.indices.object.get", absolute = true) Response getElementsFromIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName); @GET @Path("/{indexName}") @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.get", absolute = true) Response getElementsFromIndexRexsterTypedJson(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName); @OPTIONS @Path("/{indexName}/count") @Timed(name = "http.rest.indices.count.get", absolute = true) Response optionsIndexCount(); @GET @Path("/{indexName}/count") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.count.get", absolute = true) Response getIndexCount(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName); @DELETE @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.delete", absolute = true) Response deleteIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName, final JSONObject json); @DELETE @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.delete", absolute = true) Response deleteIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName); @POST @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.post", absolute = true) Response postIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName, final JSONObject json); @POST @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.post", absolute = true) Response postIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName); @PUT @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.put", absolute = true) Response putElementInIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName, final JSONObject json); @PUT @Path("/{indexName}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.indices.object.put", absolute = true) Response putElementInIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName);  }
@Test(expected = WebApplicationException.class) public void deleteIndexNoIndexFound() { final IndexResource resource = constructIndexResourceWithToyGraph().getResource(); resource.deleteIndex(graphName, "index-name-90000"); }
@Test public void deleteIndexValid() { final IndexResource resource = constructIndexResourceWithToyGraph().getResource(); resource.deleteIndex(graphName, "index-name-9"); final Index<Vertex> idx = ((IndexableGraph) this.toyGraph).getIndex("index-name-9", Vertex.class); Assert.assertNull(idx); }
@Test public void deleteIndexVertexItem() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("key", "name"); parameters.put("value", "0"); parameters.put("id", "1"); final IndexResource resource = constructIndexResource(true, parameters).getResource(); resource.deleteIndex(graphName, "index-name-0"); final Index<Vertex> idx = ((IndexableGraph) this.toyGraph).getIndex("index-name-9", Vertex.class); final Iterable<Vertex> vertices = idx.get("name", "marko"); Assert.assertFalse(vertices.iterator().hasNext()); }
@Test public void deleteIndexEdgeItem() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("key", "weight"); parameters.put("value", "0.2"); parameters.put("id", "12"); final IndexResource resource = constructIndexResource(true, parameters).getResource(); resource.deleteIndex(graphName, "index-name-0"); final Index<Edge> idx = ((IndexableGraph) this.toyGraph).getIndex("index-name-5", Edge.class); final Iterable<Edge> edges = idx.get("weight", "0.2"); Assert.assertFalse(edges.iterator().hasNext()); }