Exemplo n.º 1
0
 @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);
     }
   };
 }
Exemplo n.º 2
0
 @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);
     }
   };
 }