Package edu.ucsb.cs156.jobs.controllers
Class JobsController
java.lang.Object
edu.ucsb.cs156.jobs.controllers.JobsController
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of trailing log lines included as a preview on list/paginated responses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallJobs()getJobById(Long id) getJobLogs(Long id) getJobLogTail(Long id, Long afterId) 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.org.springframework.data.domain.Page<Job> paginatedJobs(int page, int pageSize, String sortField, String sortDirection, String status, String jobName, String createdByEmail, String scopeType, Long scopeId)
-
Field Details
-
ALLOWED_SORT_FIELDS
-
LOG_PREVIEW_LINES
public static final int LOG_PREVIEW_LINESNumber of trailing log lines included as a preview on list/paginated responses.- See Also:
-
-
Constructor Details
-
JobsController
public JobsController()
-
-
Method Details
-
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
-
getJobLogs
-
getJobLogTail
-
deleteJob
-
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)
-