Source:
public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String studentEmail = getNonNullRequestParamValue(Const.ParamsNames.STUDENT_EMAIL); StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail); if (student == null) { return new JsonResult(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, HttpStatus.SC_NOT_FOUND); } StudentUpdateRequest updateRequest = getAndValidateRequestBody(StudentUpdateRequest.class); try { logic.validateSectionsAndTeams(Arrays.asList(student), student.course); logic.validateSectionsAndTeams(Arrays.asList(student), student.course); logic.updateStudentCascade( StudentAttributes.updateOptionsBuilder(courseId, studentEmail) .withName(updateRequest.getName()) .withNewEmail(updateRequest.getEmail()) .withTeamName(updateRequest.getTeam()) .withSectionName(updateRequest.getSection()) .withComment(updateRequest.getComments()) .build()); StringBuilder responseMessage = new StringBuilder("Student has been updated"); if (!student.email.equals(updateRequest.getEmail())) { logic.resetStudentGoogleId(updateRequest.getEmail(), courseId); boolean isSessionSummarySendEmail = getBooleanRequestParamValue(Const.ParamsNames.SESSION_SUMMARY_EMAIL_SEND_CHECK); if (isSessionSummarySendEmail && sendEmail(courseId, updateRequest.getEmail())) { responseMessage.append(" and email sent"); } } return new JsonResult(responseMessage.toString()); } catch (EnrollException | InvalidParametersException | EntityDoesNotExistException e) { return new JsonResult(e.getMessage(), HttpStatus.SC_BAD_REQUEST); } catch (EntityAlreadyExistsException e) { return new JsonResult("Trying to update to an email that is already used", HttpStatus.SC_BAD_REQUEST); } }

Target:
public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String studentEmail = getNonNullRequestParamValue(Const.ParamsNames.STUDENT_EMAIL); StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail); if (student == null) { return new JsonResult(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, HttpStatus.SC_NOT_FOUND); } StudentUpdateRequest updateRequest = getAndValidateRequestBody(StudentUpdateRequest.class); boolean emailSent = false; try { logic.validateSectionsAndTeams(Arrays.asList(student), student.course); logic.validateTeams(Arrays.asList(student), student.course); logic.updateStudentCascade( StudentAttributes.updateOptionsBuilder(courseId, studentEmail) .withName(updateRequest.getName()) .withNewEmail(updateRequest.getEmail()) .withTeamName(updateRequest.getTeam()) .withSectionName(updateRequest.getSection()) .withComment(updateRequest.getComments()) .build()); if (!student.email.equals(updateRequest.getEmail())) { logic.resetStudentGoogleId(updateRequest.getEmail(), courseId); if (updateRequest.getIsSessionSummarySendEmail()) { emailSent = sendEmail(courseId, updateRequest.getEmail()); String statusMessage = emailSent ? SUCCESSFUL_UPDATE_WITH_EMAIL : SUCCESSFUL_UPDATE_BUT_EMAIL_FAILED; return new JsonResult(statusMessage); } } } catch (EnrollException | InvalidParametersException e) { return new JsonResult(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR); } catch (EntityDoesNotExistException ednee) { return new JsonResult(ednee.getMessage(), HttpStatus.SC_NOT_FOUND); } catch (EntityAlreadyExistsException e) { return new JsonResult("Trying to update to an email that is already in use", HttpStatus.SC_CONFLICT); } return new JsonResult(SUCCESSFUL_UPDATE); }