@Test public void testGetMissingNetwork() { String network = "network1"; String snapshot = "snapshot1"; String key = "foo/bar"; try (Response response = getTarget(network, snapshot, key).get()) { assertThat(response.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } }
@GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) public Response get(@QueryParam(QP_KEY) String key) throws IOException { InputStream inputStream = Main.getWorkMgr().getSnapshotInputObject(_network, _snapshot, key); if (inputStream == null) { return Response.status(Status.NOT_FOUND).build(); } String filename = Paths.get(FilenameUtils.separatorsToSystem(key)).getFileName().toString(); return Response.ok(inputStream, MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .header(CoordConsts.SVC_FILENAME_HDR, filename) .build(); }
SnapshotInputObjectsResource { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) public Response get(@QueryParam(QP_KEY) String key) throws IOException { InputStream inputStream = Main.getWorkMgr().getSnapshotInputObject(_network, _snapshot, key); if (inputStream == null) { return Response.status(Status.NOT_FOUND).build(); } String filename = Paths.get(FilenameUtils.separatorsToSystem(key)).getFileName().toString(); return Response.ok(inputStream, MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .header(CoordConsts.SVC_FILENAME_HDR, filename) .build(); } }
SnapshotInputObjectsResource { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) public Response get(@QueryParam(QP_KEY) String key) throws IOException { InputStream inputStream = Main.getWorkMgr().getSnapshotInputObject(_network, _snapshot, key); if (inputStream == null) { return Response.status(Status.NOT_FOUND).build(); } String filename = Paths.get(FilenameUtils.separatorsToSystem(key)).getFileName().toString(); return Response.ok(inputStream, MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .header(CoordConsts.SVC_FILENAME_HDR, filename) .build(); } SnapshotInputObjectsResource(String network, String snapshot); }
SnapshotInputObjectsResource { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) public Response get(@QueryParam(QP_KEY) String key) throws IOException { InputStream inputStream = Main.getWorkMgr().getSnapshotInputObject(_network, _snapshot, key); if (inputStream == null) { return Response.status(Status.NOT_FOUND).build(); } String filename = Paths.get(FilenameUtils.separatorsToSystem(key)).getFileName().toString(); return Response.ok(inputStream, MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .header(CoordConsts.SVC_FILENAME_HDR, filename) .build(); } SnapshotInputObjectsResource(String network, String snapshot); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. Response get(@QueryParam(QP_KEY) String key); @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull Response listKeys(); }
SnapshotInputObjectsResource { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) public Response get(@QueryParam(QP_KEY) String key) throws IOException { InputStream inputStream = Main.getWorkMgr().getSnapshotInputObject(_network, _snapshot, key); if (inputStream == null) { return Response.status(Status.NOT_FOUND).build(); } String filename = Paths.get(FilenameUtils.separatorsToSystem(key)).getFileName().toString(); return Response.ok(inputStream, MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .header(CoordConsts.SVC_FILENAME_HDR, filename) .build(); } SnapshotInputObjectsResource(String network, String snapshot); @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @SuppressWarnings({"MustBeClosedChecker", "PMD.CloseResource"}) // Response eventually closes it. Response get(@QueryParam(QP_KEY) String key); @Path(RSC_LIST) @GET @Produces(MediaType.APPLICATION_JSON) @Nonnull Response listKeys();  }