Source:
public StreamingOutput syncComponent(@PathParam("id") final String componentId, @PathParam("status") final Status status) { if (UserDirectoryService.getAnonymousUser().equals(UserDirectoryService.getCurrentUser())) { throw new WebAppForbiddenException(); } return new StreamingOutput() { public void write(OutputStream output) throws IOException, WebApplicationException { Collection<CourseComponent> courseComponents = new ArrayList<CourseComponent>(); if ("all".equals(componentId)) { courseComponents = courseService.getAllComponents(); } else { courseComponents.add(courseService.getCourseComponent(componentId)); } Set<Status> statuses = new HashSet<Status>(); if (null != status) { statuses = Collections.singleton(status); } else { statuses.add(Status.CONFIRMED); statuses.add(Status.WITHDRAWN); } AttendanceWriter attendance = new AttendanceWriter(output); for (CourseComponent courseComponent : courseComponents) { try { List<CourseSignup> signups = courseService.getComponentSignups( courseComponent.getPresentationId(), statuses); Collections.sort(signups, new Comparator<CourseSignup>() { public int compare(CourseSignup s1,CourseSignup s2) { Person p1 = s1.getUser(); Person p2 = s2.getUser(); int ret = s1.getGroup().getCourseId().compareTo(s2.getGroup().getCourseId()); if (ret != 0) { return ret; } if (p1 == null) { return (p2 == null) ? 0 : -1; } if (p2 == null) { return 1; } if (p1.getLastName() == null) { return (p2.getLastName() == null) ? 0 : -1; } if (p2.getLastName() == null) { return 1; } return p1.getLastName().compareTo(p2.getLastName()); } }); attendance.writeTeachingInstance(courseComponent, signups); } catch (WebAppNotFoundException e) { throw new WebApplicationException(Response.Status.NOT_FOUND); } } attendance.close(); } }; }

Target:
public StreamingOutput syncComponent(@PathParam("id") final String componentId, @PathParam("status") final Status status) { if (UserDirectoryService.getAnonymousUser().equals(UserDirectoryService.getCurrentUser())) { throw new WebAppForbiddenException(); } return new StreamingOutput() { public void write(OutputStream output) throws IOException, WebApplicationException { Collection<CourseComponent> courseComponents = new ArrayList<CourseComponent>(); if ("all".equals(componentId)) { courseComponents = courseService.getAllComponents(); } else { courseComponents.add(courseService.getCourseComponent(componentId)); } Set<Status> statuses = new HashSet<Status>(); if (null != status) { statuses = Collections.singleton(status); } else { statuses.add(Status.CONFIRMED); statuses.add(Status.WITHDRAWN); } AttendanceWriter attendance = new AttendanceWriter(output); for (CourseComponent courseComponent : courseComponents) { try { List<CourseSignup> signups = courseService.getComponentSignups( courseComponent.getPresentationId(), statuses); Collections.sort(signups, new Comparator<CourseSignup>() { public int compare(CourseSignup s1,CourseSignup s2) { Person p1 = s1.getUser(); Person p2 = s2.getUser(); int ret = s1.getGroup().getCourseId().compareTo(s2.getGroup().getCourseId()); if (ret != 0) { return ret; } if (p1 == null) { return (p2 == null) ? 0 : -1; } if (p2 == null) { return 1; } if (p1.getLastName() == null) { return (p2.getLastName() == null) ? 0 : -1; } if (p2.getLastName() == null) { return 1; } return p1.getLastName().compareTo(p2.getLastName()); } }); attendance.writeTeachingInstance(courseComponent, signups); } catch (NotFoundException e) { throw new WebApplicationException(Response.Status.NOT_FOUND); } } attendance.close(); } }; }