Class CommonsController

java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.CommonsController

@RequestMapping("/api/commons") @RestController public class CommonsController extends ApiController
  • Constructor Details

    • CommonsController

      public CommonsController()
  • Method Details

    • getCommons

      @GetMapping("/all") public org.springframework.http.ResponseEntity<String> getCommons() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getCommonsPlus

      @GetMapping("/allplus") public org.springframework.http.ResponseEntity<String> getCommonsPlus() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getCommonsPlusById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/plus") public CommonsPlus getCommonsPlusById(@RequestParam long id) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • updateCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("/update") public org.springframework.http.ResponseEntity<String> updateCommons(@RequestParam long id, @RequestBody CreateCommonsParams params)
    • getCommonsById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Commons getCommonsById(@RequestParam Long id) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • createCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping(value="/new", produces="application/json") public org.springframework.http.ResponseEntity<String> createCommons(@RequestBody CreateCommonsParams params) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • listCowHealthUpdateStrategies

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all-health-update-strategies") public org.springframework.http.ResponseEntity<String> listCowHealthUpdateStrategies() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • joinCommon

      @PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping(value="/join", produces="application/json") public org.springframework.http.ResponseEntity<String> joinCommon(@RequestParam Long commonsId) throws Exception
      Throws:
      Exception
    • deleteCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteCommons(@RequestParam Long id)
    • deleteUserFromCommon

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("/{commonsId}/users/{userId}") public Object deleteUserFromCommon(@PathVariable("commonsId") Long commonsId, @PathVariable("userId") Long userId) throws Exception
      Throws:
      Exception
    • toCommonsPlus

      public CommonsPlus toCommonsPlus(Commons c)
    • downloadCommonStats

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/{commonsId}/download") public org.springframework.http.ResponseEntity<org.springframework.core.io.InputStreamResource> downloadCommonStats(@RequestParam Long commonsId) throws IOException
      Throws:
      IOException