Class ArticlesController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.ArticlesController
@RequestMapping("/api/articles")
@RestController
public class ArticlesController
extends ApiController
This is a Rest Controller for Articles
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionList all ArticlesdeletaArticle(Long id) Delete an articleGet an article by idpostArticle(String title, String url, String explanation, String email, ZonedDateTime dateAdded) Create a new ArticleupdateArticle(Long id, @Valid Article incoming) Update a single articleMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException 
- 
Constructor Details
- 
ArticlesController
public ArticlesController() 
 - 
 - 
Method Details
- 
allArticles
List all Articles- Returns:
 - an iterable of Article
 
 - 
postArticle
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Article postArticle(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam("dateAdded") @DateTimeFormat(iso=DATE_TIME) ZonedDateTime dateAdded) throws com.fasterxml.jackson.core.JsonProcessingException Create a new Article- Parameters:
 title- the title of the articleurl- the url of the articleexplanation- explanation for the articleemail- the email of the authordateAdded- the date- Returns:
 - the saved article
 - Throws:
 com.fasterxml.jackson.core.JsonProcessingException
 - 
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Article getById(@RequestParam Long id) Get an article by id- Parameters:
 id- the id of the article- Returns:
 - an article
 
 - 
updateArticle
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Article updateArticle(@RequestParam Long id, @RequestBody @Valid @Valid Article incoming) Update a single article- Parameters:
 id- id of the article to updateincoming- the new article- Returns:
 - the updated article object
 
 - 
deletaArticle
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deletaArticle(@RequestParam Long id) Delete an article- Parameters:
 id- the id of the article to delete- Returns:
 - a message indicating the article was deleted
 
 
 -