Class CourseStaffCSVController

java.lang.Object
edu.ucsb.cs156.frontiers.controllers.ApiController
edu.ucsb.cs156.frontiers.controllers.CourseStaffCSVController

@RequestMapping("/api/coursestaff") @RestController("CourseStaffCSVController") public class CourseStaffCSVController extends ApiController
  • Field Details

  • Constructor Details

    • CourseStaffCSVController

      public CourseStaffCSVController()
  • Method Details

    • uploadStaffCSV

      @PreAuthorize("@CourseSecurity.hasInstructorPermissions(#root, #courseId)") @PostMapping(value="/upload/csv", consumes="multipart/form-data") public org.springframework.http.ResponseEntity<Map<String,Object>> uploadStaffCSV(@RequestParam Long courseId, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) throws IOException, com.opencsv.exceptions.CsvException
      Upload course staff from a CSV file with the headers firstName,lastName,email. Rows whose email is already on the course's staff, or that repeat an email from an earlier row of the same file, are not added (emails are compared ignoring upper and lower case); every other row is still added. If any row was rejected, the response status is 409 (Conflict) and the body lists the rejected emails.
      Parameters:
      courseId - id of the course
      file - the CSV file
      Returns:
      the number of staff added, and the rejected emails if there were any
      Throws:
      IOException
      com.opencsv.exceptions.CsvException