Class RosterStudentsController
java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.RosterStudentsController
@RequestMapping("/api/rosterstudents")
@RestController
public class RosterStudentsController
extends ApiController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<String> deleteRosterStudent
(Long id, boolean removeFromOrg) org.springframework.http.ResponseEntity
<String> joinCourseOnGitHub
(Long rosterStudentId) org.springframework.http.ResponseEntity
<UpsertResponse> postRosterStudent
(String studentId, String firstName, String lastName, String email, Long courseId, String section) This method creates a new RosterStudent.rosterStudentForCourse
(Long courseId) This method returns a list of roster students for a given course.updateCourseMembership
(Long courseId) static UpsertResponse
upsertStudent
(RosterStudent student, Course course, RosterStatus rosterStatus) Methods inherited from class edu.ucsb.cs156.frontiers.controllers.ApiController
doesCurrentUserHaveRole, genericMessage, getCurrentUser, handleEntityNotFoundException, handleIllegalArgument, handleNoLinkedOrgException, handleUnsupportedOperation, isCurrentUserAdmin
-
Constructor Details
-
RosterStudentsController
public RosterStudentsController()
-
-
Method Details
-
postRosterStudent
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/post") public org.springframework.http.ResponseEntity<UpsertResponse> postRosterStudent(@RequestParam String studentId, @RequestParam String firstName, @RequestParam String lastName, @RequestParam String email, @RequestParam Long courseId, @RequestParam(required=false) String section) throws EntityNotFoundException This method creates a new RosterStudent. It is important to keep the code in this method consistent with the code for adding multiple roster students from a CSV- Returns:
- the created RosterStudent
- Throws:
EntityNotFoundException
-
rosterStudentForCourse
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @GetMapping("/course/{courseId}") public Iterable<RosterStudentDTO> rosterStudentForCourse(@PathVariable Long courseId) throws EntityNotFoundException This method returns a list of roster students for a given course.- Returns:
- a list of all courses.
- Throws:
EntityNotFoundException
-
upsertStudent
public static UpsertResponse upsertStudent(RosterStudent student, Course course, RosterStatus rosterStatus) -
updateCourseMembership
@PreAuthorize("@CourseSecurity.hasManagePermissions(#root, #courseId)") @PostMapping("/updateCourseMembership") public Job updateCourseMembership(@RequestParam Long courseId) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
NoSuchAlgorithmException
InvalidKeySpecException
com.fasterxml.jackson.core.JsonProcessingException
-
joinCourseOnGitHub
@PreAuthorize("hasRole(\'ROLE_USER\')") @PutMapping("/joinCourse") public org.springframework.http.ResponseEntity<String> joinCourseOnGitHub(@RequestParam Long rosterStudentId) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException - Throws:
NoSuchAlgorithmException
InvalidKeySpecException
com.fasterxml.jackson.core.JsonProcessingException
-
getAssociatedRosterStudents
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/associatedRosterStudents") public Iterable<RosterStudent> getAssociatedRosterStudents() -
updateRosterStudent
@PreAuthorize("@CourseSecurity.hasRosterStudentManagementPermissions(#root, #id)") @PutMapping("/update") public RosterStudent updateRosterStudent(@RequestParam Long id, @RequestParam(required=false) String firstName, @RequestParam(required=false) String lastName, @RequestParam(required=false) String studentId, @RequestParam(required=false) String section) throws EntityNotFoundException - Throws:
EntityNotFoundException
-
restoreRosterStudent
@PreAuthorize("@CourseSecurity.hasRosterStudentManagementPermissions(#root, #id)") @PutMapping("/restore") public RosterStudent restoreRosterStudent(@RequestParam Long id) throws EntityNotFoundException - Throws:
EntityNotFoundException
-
deleteRosterStudent
@PreAuthorize("@CourseSecurity.hasRosterStudentManagementPermissions(#root, #id)") @DeleteMapping("/delete") @Transactional public org.springframework.http.ResponseEntity<String> deleteRosterStudent(@RequestParam Long id, @RequestParam(defaultValue="true") boolean removeFromOrg) throws EntityNotFoundException - Throws:
EntityNotFoundException
-