Class JobsController

java.lang.Object
edu.ucsb.cs156.jobs.controllers.JobsController

@RequestMapping("/api/jobs") @RestController public class JobsController extends Object
Admin REST API for job records: list (all or paginated, filterable, sortable by any field), fetch one, fetch logs (full or incremental tail), delete one or all. Launch endpoints stay in each app's own controllers. Requires ROLE_ADMIN, which consuming apps must support via method security (@EnableMethodSecurity).
  • Field Details

    • ALLOWED_SORT_FIELDS

      public static final List<String> ALLOWED_SORT_FIELDS
    • LOG_PREVIEW_LINES

      public static final int LOG_PREVIEW_LINES
      Number of trailing log lines included as a preview on list/paginated responses.
      See Also:
  • Constructor Details

    • JobsController

      public JobsController()
  • Method Details

    • allJobs

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/all") public Iterable<Job> allJobs()
    • paginatedJobs

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping(value="/paginated", produces="application/json") public org.springframework.data.domain.Page<Job> paginatedJobs(@RequestParam int page, @RequestParam int pageSize, @RequestParam(defaultValue="status") String sortField, @RequestParam(defaultValue="DESC") String sortDirection, @RequestParam(required=false) String status, @RequestParam(required=false) String jobName, @RequestParam(required=false) String createdByEmail, @RequestParam(required=false) String scopeType, @RequestParam(required=false) Long scopeId)
    • getJobById

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("") public Job getJobById(@RequestParam Long id)
    • getJobLogs

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/logs/{id}") public String getJobLogs(@PathVariable Long id)
    • getJobLogTail

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/logs/{id}/tail") public List<JobLog> getJobLogTail(@PathVariable Long id, @RequestParam(defaultValue="0") Long afterId)
    • deleteJob

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Map<String,String> deleteJob(@RequestParam Long id)
    • deleteAllJobs

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("/all") public Map<String,String> deleteAllJobs()
    • handleEntityNotFoundException

      @ExceptionHandler(EntityNotFoundException.class) @ResponseStatus(NOT_FOUND) public Object handleEntityNotFoundException(Throwable e)
      The apps map these exceptions in an app-level base controller; the library controller cannot extend that, so it carries its own handlers with the same response shape.
    • handleIllegalArgument

      @ExceptionHandler(java.lang.IllegalArgumentException.class) @ResponseStatus(BAD_REQUEST) public Object handleIllegalArgument(Throwable e)