Source:
public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); if (!hasStudentJoinedCourse(courseId)) { throw new UnauthorizedAccessException("The student is yet to join the course."); } CourseAttributes course = logic.getCourse(courseId); if (course == null) { return new JsonResult(String.format("Course with the given course id (%s) cannot be found.", courseId), HttpStatus.SC_NOT_FOUND); } gateKeeper.verifyAccessible(logic.getStudentForGoogleId(courseId, userInfo.id), course); StudentAttributes student = logic.getStudentForGoogleId(courseId, userInfo.id); if (student == null) { return new JsonResult(String.format("Student with id (%s) cannot be found.", userInfo.id), HttpStatus.SC_NOT_FOUND); } student.lastName = null; student.comments = null; student.key = null; List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId); List<InstructorDetails> instructorDetailss = new LinkedList<>(); if (instructors != null) { instructors.forEach( instructor -> instructorDetailss.add( new InstructorDetails(instructor.getName(), instructor.getEmail()))); } TeamDetailsBundle teamDetails = logic.getTeamDetailsForStudent(student); if (teamDetails == null) { return new JsonResult(String.format("Team for the student with id (%s) cannot be found.", userInfo.id), HttpStatus.SC_NOT_FOUND); } List<StudentProfileAttributes> teammateProfiles = new LinkedList<>(); if (teamDetails.students != null) { teamDetails.students.removeIf(st -> st.googleId.equals(userInfo.id)); teamDetails.students.forEach(teammate -> { StudentProfileAttributes teammateProfile = logic.getStudentProfile(teammate.googleId); if (teammateProfile != null) { teammateProfile.googleId = null; teammateProfile.modifiedDate = null; teammateProfiles.add(teammateProfile); } }); } StudentGetCourseDetailsResult result = new StudentGetCourseDetailsResult( student, course, instructorDetailss, teammateProfiles); return new JsonResult(result); }

Target:
public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); StudentAttributes student = logic.getStudentForGoogleId(courseId, userInfo.id); if (student == null) { return new JsonResult(String.format("Student with id (%s) cannot be found.", userInfo.id), HttpStatus.SC_NOT_FOUND); } student.lastName = null; student.comments = null; student.key = null; List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId); List<InstructorDetails> instructorDetails = new LinkedList<>(); instructors.forEach( instructor -> instructorDetails.add( new InstructorDetails(instructor.getName(), instructor.getEmail()))); TeamDetailsBundle teamDetails = logic.getTeamDetailsForStudent(student); if (teamDetails == null) { return new JsonResult(String.format("Team for the student with id (%s) cannot be found.", userInfo.id), HttpStatus.SC_NOT_FOUND); } List<StudentProfileAttributes> teammateProfiles = new LinkedList<>(); if (teamDetails.students != null) { teamDetails.students.removeIf(st -> st.googleId.equals(userInfo.id)); teamDetails.students.forEach(teammate -> { StudentProfileAttributes teammateProfile = logic.getStudentProfile(teammate.googleId); if (teammateProfile != null) { teammateProfile.googleId = null; teammateProfile.modifiedDate = null; teammateProfiles.add(teammateProfile); } }); } StudentGetCourseDetailsResult result = new StudentGetCourseDetailsResult( student, logic.getCourse(courseId), instructorDetails, teammateProfiles); return new JsonResult(result); }