Response checkAndDelete(final CellSetModel model) {
    Table table = null;
    Delete delete = null;
    try {
      table = servlet.getTable(tableResource.getName());
      if (model.getRows().size() != 1) {
        servlet.getMetrics().incrementFailedDeleteRequests(1);
        return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
          .entity("Bad request: Number of rows specified is not 1." + CRLF).build();
      }
      RowModel rowModel = model.getRows().get(0);
      byte[] key = rowModel.getKey();
      if (key == null) {
        key = rowspec.getRow();
      }
      if (key == null) {
        servlet.getMetrics().incrementFailedDeleteRequests(1);
        return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
          .entity("Bad request: Row key found to be null." + CRLF).build();
      }

      List<CellModel> cellModels = rowModel.getCells();
      int cellModelCount = cellModels.size();

      delete = new Delete(key);
      boolean retValue;
      CellModel valueToDeleteCell = rowModel.getCells().get(cellModelCount - 1);
      byte[] valueToDeleteColumn = valueToDeleteCell.getColumn();
      if (valueToDeleteColumn == null) {
        try {
          valueToDeleteColumn = rowspec.getColumns()[0];
        } catch (final ArrayIndexOutOfBoundsException e) {
          servlet.getMetrics().incrementFailedDeleteRequests(1);
          return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
            .entity("Bad request: Column not specified for check." + CRLF).build();
        }
      }

      byte[][] parts;
      // Copy all the cells to the Delete request if extra cells are sent
      if (cellModelCount > 1) {
        for (int i = 0, n = cellModelCount - 1; i < n; i++) {
          CellModel cell = cellModels.get(i);
          byte[] col = cell.getColumn();

          if (col == null) {
            servlet.getMetrics().incrementFailedPutRequests(1);
            return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
              .entity("Bad request: Column found to be null." + CRLF).build();
          }

          parts = CellUtil.parseColumn(col);

          if (parts.length == 1) {
            // Only Column Family is specified
            delete.addFamily(parts[0], cell.getTimestamp());
          } else if (parts.length == 2) {
            delete.addColumn(parts[0], parts[1], cell.getTimestamp());
          } else {
            servlet.getMetrics().incrementFailedDeleteRequests(1);
            return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
              .entity("Bad request: Column to delete incorrectly specified." + CRLF).build();
          }
        }
      }

      parts = CellUtil.parseColumn(valueToDeleteColumn);
      if (parts.length == 2) {
        if (parts[1].length != 0) {
          // To support backcompat of deleting a cell
          // if that is the only cell passed to the rest api
          if (cellModelCount == 1) {
            delete.addColumns(parts[0], parts[1]);
          }
          retValue = table.checkAndMutate(key, parts[0]).qualifier(parts[1])
            .ifEquals(valueToDeleteCell.getValue()).thenDelete(delete);
        } else {
          // The case of empty qualifier.
          if (cellModelCount == 1) {
            delete.addColumns(parts[0], Bytes.toBytes(StringUtils.EMPTY));
          }
          retValue = table.checkAndMutate(key, parts[0]).ifEquals(valueToDeleteCell.getValue())
            .thenDelete(delete);
        }
      } else {
        servlet.getMetrics().incrementFailedDeleteRequests(1);
        return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
          .entity("Bad request: Column to check incorrectly specified." + CRLF).build();
      }

      if (LOG.isTraceEnabled()) {
        LOG.trace("CHECK-AND-DELETE " + delete.toString() + ", returns " + retValue);
      }

      if (!retValue) {
        servlet.getMetrics().incrementFailedDeleteRequests(1);
        return Response.status(Response.Status.NOT_MODIFIED).type(MIMETYPE_TEXT)
          .entity(" Delete check failed." + CRLF).build();
      }
      ResponseBuilder response = Response.ok();
      servlet.getMetrics().incrementSucessfulDeleteRequests(1);
      return response.build();
    } catch (Exception e) {
      servlet.getMetrics().incrementFailedDeleteRequests(1);
      return processException(e);
    } finally {
      if (table != null) {
        try {
          table.close();
        } catch (IOException ioe) {
          LOG.debug("Exception received while closing the table", ioe);
        }
      }
    }
  }
Validates the input request parameters, parses columns from CellSetModel, and invokes
checkAndDelete on HTable.
@param model instance of CellSetModel
@return Response 200 OK, 304 Not modified, 400 Bad request
hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java