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