@Path("/my") @GET @Produces(MediaType.APPLICATION_JSON) public StreamingOutput getMySignups() { checkAuthenticated(); final List<CourseSignup> signups = courseService.getMySignups(null); return new StreamingOutput() { public void write(OutputStream output) throws IOException, WebApplicationException { objectMapper .typedWriter(TypeFactory.collectionType(List.class, CourseSignup.class)) .writeValue(output, signups); } }; }
@Path("/my/course/{id}") @GET @Produces(MediaType.APPLICATION_JSON) public StreamingOutput getMyCourseSignups(@PathParam("id") String courseId) { checkAuthenticated(); final List<CourseSignup> signups = courseService.getMySignups(null); final List<CourseSignup> courseSignups = new ArrayList<CourseSignup>(); for (CourseSignup signup : signups) { if (courseId.equals(signup.getGroup().getCourseId())) { courseSignups.add(signup); } } return new StreamingOutput() { public void write(OutputStream output) throws IOException, WebApplicationException { objectMapper .typedWriter(TypeFactory.collectionType(List.class, CourseSignup.class)) .writeValue(output, courseSignups); } }; }