Class UCSBDatesController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBDatesController
@RequestMapping("/api/ucsbdates")
@RestController
public class UCSBDatesController
extends ApiController
This is a REST controller for UCSBDates
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionList all UCSB datesorg.springframework.http.ResponseEntity<String> deleteUCSBDate(Long id) Delete a UCSBDateedu.ucsb.cs156.example.controllers.UCSBDatesController.UCSBDateOrErrordoesUCSBDateExist(edu.ucsb.cs156.example.controllers.UCSBDatesController.UCSBDateOrError uoe) Pre-conditions: uoe.id is value to look up, uoe.ucsbDate and uoe.error are null Post-condition: if UCSBDate with id uoe.id exists, uoe.ucsbDate now refers to it, and error is null.org.springframework.http.ResponseEntity<String> Get a single date by idorg.springframework.http.ResponseEntity<String> postUCSBDate(String quarterYYYYQ, String name, LocalDateTime localDateTime) Create a new dateorg.springframework.http.ResponseEntity<String> updateUCSBDate(Long id, @Valid UCSBDate incoming) Update a single dateMethods inherited from class edu.ucsb.cs156.example.controllers.ApiControllergenericMessage, getCurrentUser, handleGenericException
- 
Constructor Details- 
UCSBDatesControllerpublic UCSBDatesController()
 
- 
- 
Method Details- 
allUCSBDates@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBDate> allUCSBDates()List all UCSB dates- Returns:
- an iterable of UCSBDate
 
- 
getById@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public org.springframework.http.ResponseEntity<String> getById(@RequestParam Long id) throws com.fasterxml.jackson.core.JsonProcessingException Get a single date by id- Parameters:
- id- the id of the date
- Returns:
- a UCSBDate
- Throws:
- com.fasterxml.jackson.core.JsonProcessingException- if there is an error processing the JSON
 
- 
postUCSBDate@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public org.springframework.http.ResponseEntity<String> postUCSBDate(@RequestParam String quarterYYYYQ, @RequestParam String name, @RequestParam("localDateTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime localDateTime) throws com.fasterxml.jackson.core.JsonProcessingException Create a new date- Parameters:
- quarterYYYYQ- the quarter in the format YYYYQ
- name- the name of the date
- localDateTime- the date
- Returns:
- a ResponseEntity with the new date
- Throws:
- com.fasterxml.jackson.core.JsonProcessingException- if there is an error processing the JSON
 
- 
deleteUCSBDate@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public org.springframework.http.ResponseEntity<String> deleteUCSBDate(@RequestParam Long id) Delete a UCSBDate- Parameters:
- id- the id of the date to delete
- Returns:
- a ResponseEntity with a message
 
- 
updateUCSBDate@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public org.springframework.http.ResponseEntity<String> updateUCSBDate(@RequestParam Long id, @RequestBody @Valid @Valid UCSBDate incoming) throws com.fasterxml.jackson.core.JsonProcessingException Update a single date- Parameters:
- id- id of the date to update
- incoming- the new date
- Returns:
- response entity with the updated date
- Throws:
- com.fasterxml.jackson.core.JsonProcessingException- if there is an error processing the JSON
 
- 
doesUCSBDateExistpublic edu.ucsb.cs156.example.controllers.UCSBDatesController.UCSBDateOrError doesUCSBDateExist(edu.ucsb.cs156.example.controllers.UCSBDatesController.UCSBDateOrError uoe) Pre-conditions: uoe.id is value to look up, uoe.ucsbDate and uoe.error are null Post-condition: if UCSBDate with id uoe.id exists, uoe.ucsbDate now refers to it, and error is null. Otherwise, UCSBDate with id uoe.id does not exist, and error is a suitable return value to report this error condition.- Parameters:
- uoe- the UCSBDateOrError object
- Returns:
- the UCSBDateOrError object
 
 
-