@Test public void testDelete() throws IOException, JAXBException { Response response; response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); assertEquals(response.getCode(), 200); response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); assertEquals(response.getCode(), 200); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); response = deleteValue(TABLE, ROW_1, COLUMN_1); assertEquals(response.getCode(), 200); response = getValueXML(TABLE, ROW_1, COLUMN_1); assertEquals(response.getCode(), 404); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); response = deleteRow(TABLE, ROW_1); assertEquals(response.getCode(), 200); response = getValueXML(TABLE, ROW_1, COLUMN_1); assertEquals(response.getCode(), 404); response = getValueXML(TABLE, ROW_1, COLUMN_2); assertEquals(response.getCode(), 404); }
@DELETE public Response delete(final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); if (servlet.isReadOnly()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } Delete delete = null; if (rowspec.hasTimestamp()) delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null); else delete = new Delete(rowspec.getRow()); for (byte[] column: rowspec.getColumns()) { byte[][] split = KeyValue.parseColumn(column); if (rowspec.hasTimestamp()) { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1], rowspec.getTimestamp()); } else { delete.deleteFamily(split[0], rowspec.getTimestamp()); } } else { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1]); } else { delete.deleteFamily(split[0]); } } } HTablePool pool = servlet.getTablePool(); HTableInterface table = null; try { table = pool.getTable(tableResource.getName()); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + delete.toString()); } } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } finally { if (table != null) { pool.putTable(table); } } return Response.ok().build(); }
RowResource extends ResourceBase { @DELETE public Response delete(final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); if (servlet.isReadOnly()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } Delete delete = null; if (rowspec.hasTimestamp()) delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null); else delete = new Delete(rowspec.getRow()); for (byte[] column: rowspec.getColumns()) { byte[][] split = KeyValue.parseColumn(column); if (rowspec.hasTimestamp()) { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1], rowspec.getTimestamp()); } else { delete.deleteFamily(split[0], rowspec.getTimestamp()); } } else { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1]); } else { delete.deleteFamily(split[0]); } } } HTablePool pool = servlet.getTablePool(); HTableInterface table = null; try { table = pool.getTable(tableResource.getName()); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + delete.toString()); } } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } finally { if (table != null) { pool.putTable(table); } } return Response.ok().build(); } }
RowResource extends ResourceBase { @DELETE public Response delete(final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); if (servlet.isReadOnly()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } Delete delete = null; if (rowspec.hasTimestamp()) delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null); else delete = new Delete(rowspec.getRow()); for (byte[] column: rowspec.getColumns()) { byte[][] split = KeyValue.parseColumn(column); if (rowspec.hasTimestamp()) { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1], rowspec.getTimestamp()); } else { delete.deleteFamily(split[0], rowspec.getTimestamp()); } } else { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1]); } else { delete.deleteFamily(split[0]); } } } HTablePool pool = servlet.getTablePool(); HTableInterface table = null; try { table = pool.getTable(tableResource.getName()); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + delete.toString()); } } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } finally { if (table != null) { pool.putTable(table); } } return Response.ok().build(); } RowResource(TableResource tableResource, String rowspec,
      String versions); }
RowResource extends ResourceBase { @DELETE public Response delete(final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); if (servlet.isReadOnly()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } Delete delete = null; if (rowspec.hasTimestamp()) delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null); else delete = new Delete(rowspec.getRow()); for (byte[] column: rowspec.getColumns()) { byte[][] split = KeyValue.parseColumn(column); if (rowspec.hasTimestamp()) { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1], rowspec.getTimestamp()); } else { delete.deleteFamily(split[0], rowspec.getTimestamp()); } } else { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1]); } else { delete.deleteFamily(split[0]); } } } HTablePool pool = servlet.getTablePool(); HTableInterface table = null; try { table = pool.getTable(tableResource.getName()); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + delete.toString()); } } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } finally { if (table != null) { pool.putTable(table); } } return Response.ok().build(); } RowResource(TableResource tableResource, String rowspec,
      String versions); @GET @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response get(final @Context UriInfo uriInfo); @GET @Produces(MIMETYPE_BINARY) Response getBinary(final @Context UriInfo uriInfo); @PUT @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response put(final CellSetModel model,
      final @Context UriInfo uriInfo); @PUT @Consumes(MIMETYPE_BINARY) Response putBinary(final byte[] message,
      final @Context UriInfo uriInfo, final @Context HttpHeaders headers); @POST @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response post(final CellSetModel model,
      final @Context UriInfo uriInfo); @POST @Consumes(MIMETYPE_BINARY) Response postBinary(final byte[] message,
      final @Context UriInfo uriInfo, final @Context HttpHeaders headers); @DELETE Response delete(final @Context UriInfo uriInfo); }
RowResource extends ResourceBase { @DELETE public Response delete(final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + uriInfo.getAbsolutePath()); } servlet.getMetrics().incrementRequests(1); if (servlet.isReadOnly()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } Delete delete = null; if (rowspec.hasTimestamp()) delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null); else delete = new Delete(rowspec.getRow()); for (byte[] column: rowspec.getColumns()) { byte[][] split = KeyValue.parseColumn(column); if (rowspec.hasTimestamp()) { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1], rowspec.getTimestamp()); } else { delete.deleteFamily(split[0], rowspec.getTimestamp()); } } else { if (split.length == 2 && split[1].length != 0) { delete.deleteColumns(split[0], split[1]); } else { delete.deleteFamily(split[0]); } } } HTablePool pool = servlet.getTablePool(); HTableInterface table = null; try { table = pool.getTable(tableResource.getName()); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("DELETE " + delete.toString()); } } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } finally { if (table != null) { pool.putTable(table); } } return Response.ok().build(); } RowResource(TableResource tableResource, String rowspec,
      String versions); @GET @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response get(final @Context UriInfo uriInfo); @GET @Produces(MIMETYPE_BINARY) Response getBinary(final @Context UriInfo uriInfo); @PUT @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response put(final CellSetModel model,
      final @Context UriInfo uriInfo); @PUT @Consumes(MIMETYPE_BINARY) Response putBinary(final byte[] message,
      final @Context UriInfo uriInfo, final @Context HttpHeaders headers); @POST @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) Response post(final CellSetModel model,
      final @Context UriInfo uriInfo); @POST @Consumes(MIMETYPE_BINARY) Response postBinary(final byte[] message,
      final @Context UriInfo uriInfo, final @Context HttpHeaders headers); @DELETE Response delete(final @Context UriInfo uriInfo);  }