@Test public void testListKeys() throws IOException { String network = "network1"; String snapshot = "snapshot1"; Main.getWorkMgr().initNetwork(network, null); WorkMgrTestUtils.initSnapshotWithTopology(network, snapshot, ImmutableSet.of()); String key = "foo/bar"; String content = "baz"; InputStream inputStream = new ByteArrayInputStream(content.getBytes()); Main.getWorkMgr().putSnapshotExtendedObject(inputStream, network, snapshot, key); try (Response response = listKeysTarget(network, snapshot).get()) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); assertThat( response.readEntity(new GenericType<List<StoredObjectMetadata>>() {}), equalTo(ImmutableList.of(new StoredObjectMetadata(key, content.getBytes().length)))); } }
@Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull public Response listKeys() throws IOException { List<StoredObjectMetadata> keys = Main.getWorkMgr().getSnapshotExtendedObjectsMetadata(_network, _snapshot); if (keys == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(keys).build(); }
SnapshotObjectsResource { @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull public Response listKeys() throws IOException { List<StoredObjectMetadata> keys = Main.getWorkMgr().getSnapshotExtendedObjectsMetadata(_network, _snapshot); if (keys == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(keys).build(); } }
SnapshotObjectsResource { @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull public Response listKeys() throws IOException { List<StoredObjectMetadata> keys = Main.getWorkMgr().getSnapshotExtendedObjectsMetadata(_network, _snapshot); if (keys == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(keys).build(); } SnapshotObjectsResource(String network, String snapshot); }
SnapshotObjectsResource { @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull public Response listKeys() throws IOException { List<StoredObjectMetadata> keys = Main.getWorkMgr().getSnapshotExtendedObjectsMetadata(_network, _snapshot); if (keys == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(keys).build(); } SnapshotObjectsResource(String network, String snapshot); @DELETE Response delete(@QueryParam(QP_KEY) String key); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. Response get(@QueryParam(QP_KEY) String key); @PUT @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response put(InputStream inputStream, @QueryParam(QP_KEY) String key); @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull Response listKeys(); }
SnapshotObjectsResource { @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull public Response listKeys() throws IOException { List<StoredObjectMetadata> keys = Main.getWorkMgr().getSnapshotExtendedObjectsMetadata(_network, _snapshot); if (keys == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(keys).build(); } SnapshotObjectsResource(String network, String snapshot); @DELETE Response delete(@QueryParam(QP_KEY) String key); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. Response get(@QueryParam(QP_KEY) String key); @PUT @Consumes(MediaType.APPLICATION_OCTET_STREAM) Response put(InputStream inputStream, @QueryParam(QP_KEY) String key); @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull Response listKeys();  }