Source:
private void verifyDeletePermissionForUserToFeedbackResponseComment(FeedbackSessionAttributes session, FeedbackResponseAttributes response, Long commentId) { if (isModeration) { InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId); gateKeeper.verifyAccessible(instructor, session, false, response.giverSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS); gateKeeper.verifyAccessible(instructor, session, false, response.recipientSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS); return; } FeedbackResponseCommentAttributes frc = logic.getFeedbackResponseComment(commentId); if (frc.isCommentFromFeedbackParticipant) { InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId); StudentAttributes student = logic.getStudentForGoogleId(courseId, account.googleId); switch (frc.commentGiverType) { case INSTRUCTORS: gateKeeper.verifyAccessible(instructor, session, false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION); gateKeeper.verifyAccessibleForDeletion(frc, instructor.email); break; case STUDENTS: gateKeeper.verifyAccessible(student, session); gateKeeper.verifyAccessibleForDeletion(frc, student.email); break; case TEAMS: gateKeeper.verifyAccessible(student, session); gateKeeper.verifyAccessibleForDeletion(frc, student.team); break; default: Assumption.fail("Invalid comment giver type"); break; } } else { throw new UnauthorizedAccessException("Comment [" + frc.getId() + "] not given by feedback participant."); } }

Target:
private void verifyDeletePermissionForUserToFeedbackResponseComment(FeedbackSessionAttributes session, FeedbackResponseAttributes response, Long commentId) { if (isModeration) { InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId); gateKeeper.verifyAccessible(instructor, session, false, response.giverSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS); gateKeeper.verifyAccessible(instructor, session, false, response.recipientSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS); return; } FeedbackResponseCommentAttributes frc = logic.getFeedbackResponseComment(commentId); if (frc == null) { return; } if (!frc.isCommentFromFeedbackParticipant) { throw new UnauthorizedAccessException("Comment [" + frc.getId() + "] not given by feedback participant."); } switch (frc.commentGiverType) { case INSTRUCTORS: InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId); if (instructor == null) { throw new UnauthorizedAccessException("Trying to access system using a non-existent instructor entity"); } gateKeeper.verifyOwnership(frc, instructor.email); break; case STUDENTS: StudentAttributes student = getStudent(); if (student == null) { throw new UnauthorizedAccessException("Trying to access system using a non-existent student entity"); } gateKeeper.verifyOwnership(frc, student.email); break; case TEAMS: StudentAttributes studentOfTeam = getStudent(); if (studentOfTeam == null) { throw new UnauthorizedAccessException("Trying to access system using a non-existent student entity"); } gateKeeper.verifyOwnership(frc, studentOfTeam.team); break; default: Assumption.fail("Invalid comment giver type"); break; } }