@Test public void downloadPatientData() { Response response = researcherResource.downloadPatientData("foo"); assertNotNull(response); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertNotNull(response.getEntity()); }
@Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET public Response downloadPatientData(@PathParam("fileName") final String fileName) { final String filePath = appResources.getStringResource(FILE_LOCATION_KEY); StreamingOutput output = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException { try { InputStream input = FileUtils.openInputStream(FileUtils.getFile(filePath, fileName + ".zip")); IOUtils.copyLarge(input, output); } catch (Exception e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } } }; return Response.ok(output, "application/zip") .header("content-disposition", "attachment; filename = patientData.zip").build(); }
ResearcherResource { @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET public Response downloadPatientData(@PathParam("fileName") final String fileName) { final String filePath = appResources.getStringResource(FILE_LOCATION_KEY); StreamingOutput output = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException { try { InputStream input = FileUtils.openInputStream(FileUtils.getFile(filePath, fileName + ".zip")); IOUtils.copyLarge(input, output); } catch (Exception e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } } }; return Response.ok(output, "application/zip") .header("content-disposition", "attachment; filename = patientData.zip").build(); } }
ResearcherResource { @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET public Response downloadPatientData(@PathParam("fileName") final String fileName) { final String filePath = appResources.getStringResource(FILE_LOCATION_KEY); StreamingOutput output = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException { try { InputStream input = FileUtils.openInputStream(FileUtils.getFile(filePath, fileName + ".zip")); IOUtils.copyLarge(input, output); } catch (Exception e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } } }; return Response.ok(output, "application/zip") .header("content-disposition", "attachment; filename = patientData.zip").build(); } @Inject  ResearcherResource(ResearchEntityDao researchEntityDao, TokenDao tokenDao,
            PatientDataService patientDataService, PLCApplicationResources appResources); }
ResearcherResource { @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET public Response downloadPatientData(@PathParam("fileName") final String fileName) { final String filePath = appResources.getStringResource(FILE_LOCATION_KEY); StreamingOutput output = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException { try { InputStream input = FileUtils.openInputStream(FileUtils.getFile(filePath, fileName + ".zip")); IOUtils.copyLarge(input, output); } catch (Exception e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } } }; return Response.ok(output, "application/zip") .header("content-disposition", "attachment; filename = patientData.zip").build(); } @Inject  ResearcherResource(ResearchEntityDao researchEntityDao, TokenDao tokenDao,
            PatientDataService patientDataService, PLCApplicationResources appResources); @RolesAllowed({OAuthToken.PLC_ROLE }) @POST @Path("qualification_request") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_JSON) String qualificationRequest(ResearchEntity re); @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @POST @Path("shared/summary") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Summary dataSummary(Filter filter); @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @POST @Path("shared") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) DownloadDetails requestData(Filter filter); @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET Response downloadPatientData(@PathParam("fileName") final String fileName); }
ResearcherResource { @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET public Response downloadPatientData(@PathParam("fileName") final String fileName) { final String filePath = appResources.getStringResource(FILE_LOCATION_KEY); StreamingOutput output = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException { try { InputStream input = FileUtils.openInputStream(FileUtils.getFile(filePath, fileName + ".zip")); IOUtils.copyLarge(input, output); } catch (Exception e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } } }; return Response.ok(output, "application/zip") .header("content-disposition", "attachment; filename = patientData.zip").build(); } @Inject  ResearcherResource(ResearchEntityDao researchEntityDao, TokenDao tokenDao,
            PatientDataService patientDataService, PLCApplicationResources appResources); @RolesAllowed({OAuthToken.PLC_ROLE }) @POST @Path("qualification_request") @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_JSON) String qualificationRequest(ResearchEntity re); @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @POST @Path("shared/summary") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Summary dataSummary(Filter filter); @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @POST @Path("shared") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) DownloadDetails requestData(Filter filter); @Path("shared/download/{fileName}") @RolesAllowed({OAuthToken.RESEARCHER_ROLE }) @GET Response downloadPatientData(@PathParam("fileName") final String fileName);  }