PrefixResource extends AbstractSubResource { @DELETE @Path("/{prefix}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.prefixes.object.delete", absolute = true) public Response deleteSinglePrefix(@PathParam("graphname") String graphName, @PathParam("prefix") String prefix) { final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName); try { final SailGraph graph = ((SailGraph) rag.getUnwrappedGraph()); graph.removeNamespace(prefix); rag.tryCommit(); this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch()); return Response.ok(this.resultObject).build(); } catch (JSONException ex) { logger.error(ex); rag.tryRollback(); JSONObject error = generateErrorObjectJsonFail(ex); throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); } catch (RuntimeException re) { logger.error(re); rag.tryRollback(); JSONObject error = generateErrorObject(re.getMessage(), re); throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); } } PrefixResource();  PrefixResource(final UriInfo ui, final HttpServletRequest req, final RexsterApplication ra); @OPTIONS Response optionsPrefixes(); @GET @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.prefixes.collection.get", absolute = true) Response getPrefixes(@PathParam("graphname") String graphName); @OPTIONS @Path("/{prefix}") Response optionsSinglePrefix(); @GET @Path("/{prefix}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.prefixes.object.get", absolute = true) Response getSinglePrefix(@PathParam("graphname") String graphName, @PathParam("prefix") String prefix); @DELETE @Path("/{prefix}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.prefixes.object.delete", absolute = true) Response deleteSinglePrefix(@PathParam("graphname") String graphName, @PathParam("prefix") String prefix); @POST @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.prefixes.object.post", absolute = true) Response postSinglePrefix(@PathParam("graphname") String graphName, JSONObject json); @POST @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.prefixes.object.post", absolute = true) Response postSinglePrefix(@PathParam("graphname") String graphName);  }
@Test public void deleteSinglePrefixValid() { final ResourceHolder<PrefixResource> holder = this.constructPrefixResource(); final PrefixResource resource = holder.getResource(); Response response = resource.deleteSinglePrefix(graphName, "tg"); Assert.assertNotNull(response); Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final JSONObject jsonObject = (JSONObject) response.getEntity(); Assert.assertNotNull(jsonObject); Assert.assertTrue(jsonObject.has(Tokens.QUERY_TIME)); }