@GET @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF}) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null); if (!generator.hasNext()) { throw new WebApplicationException(Response.Status.NOT_FOUND); } KeyValue value = null; RowModel rowModel = new RowModel(rk); while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(value.getFamily(), value.getQualifier(), value.getTimestamp(), value.getValue())); } model.addRow(rowModel); } return Response.ok(model).build(); } catch (IOException e) { throw new WebApplicationException(e, Response.Status.SERVICE_UNAVAILABLE); } }
@GET @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context UriInfo uriInfo) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); servlet.getMetrics().incrementRequests(1); try { CellSetModel model = new CellSetModel(); for (String rk : params.get(ROW_KEYS_PARAM_NAME)) { RowSpec rowSpec = new RowSpec(rk); if (this.versions != null) { rowSpec.setMaxVersions(this.versions); } ResultGenerator generator = ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null); if (!generator.hasNext()) { return Response.status(Response.Status.NOT_FOUND) .type(MIMETYPE_TEXT).entity("Not found" + CRLF) .build(); } KeyValue value = null; RowModel rowModel = new RowModel(rk); while ((value = generator.next()) != null) { rowModel.addCell(new CellModel(value.getFamily(), value.getQualifier(), value.getTimestamp(), value.getValue())); } model.addRow(rowModel); } servlet.getMetrics().incrementSucessfulGetRequests(1); return Response.ok(model).build(); } catch (IOException e) { servlet.getMetrics().incrementFailedGetRequests(1); return Response.status(Response.Status.SERVICE_UNAVAILABLE) .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF) .build(); } }