Class UCSBArticlesController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBArticlesController
@RequestMapping("/api/ucsbarticles")
@RestController
public class UCSBArticlesController
extends ApiController
This is a REST controller for UCSBArticles
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionList all UCSB articlesDelete a UCSBArticlesGet a single article by idpostUCSBArticles(String title, String url, String explanation, String email, LocalDateTime dateAdded) Create a new articleupdateUCSBArticles(Long id, @Valid UCSBArticles incoming) Update a single articleMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException 
- 
Constructor Details
- 
UCSBArticlesController
public UCSBArticlesController() 
 - 
 - 
Method Details
- 
allUCSBArticles
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBArticles> allUCSBArticles()List all UCSB articles- Returns:
 - an iterable of UCSBArticles
 
 - 
postUCSBArticles
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBArticles postUCSBArticles(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam("dateAdded") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateAdded) throws com.fasterxml.jackson.core.JsonProcessingException Create a new article- Parameters:
 title- the title of the articleurl- the url of the articleexplanation- a summary of the articleemail- an email addressdateAdded- the date- Returns:
 - the saved ucsbarticle
 - Throws:
 com.fasterxml.jackson.core.JsonProcessingException
 - 
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBArticles getById(@RequestParam Long id) Get a single article by id- Parameters:
 id- the id of the article- Returns:
 - a UCSBArticles
 
 - 
deleteUCSBArticles
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBArticles(@RequestParam Long id) Delete a UCSBArticles- Parameters:
 id- the id of the article to delete- Returns:
 - a message indicating the article was deleted
 
 - 
updateUCSBArticles
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBArticles updateUCSBArticles(@RequestParam Long id, @RequestBody @Valid @Valid UCSBArticles incoming) Update a single article- Parameters:
 id- id of the article to updateincoming- the new article- Returns:
 - the updated article object
 
 
 -