Class UCSBOrganizationsController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBOrganizationsController

@RequestMapping("/api/ucsborganizations") @RestController public class UCSBOrganizationsController extends ApiController
This is a REST controller for UCSBOrganizations
  • Constructor Details

    • UCSBOrganizationsController

      public UCSBOrganizationsController()
  • Method Details

    • allOrganizations

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBOrganizations> allOrganizations()
      This method returns a list of all ucsb organizations.
      Returns:
      a list of all ucsb organizations
    • postCommons

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBOrganizations postCommons(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive)
      This method creates a new organization. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      orgCode - code of the organization
      orgTranslationShort - organization translation short
      orgTranslation - organization translation
      inactive - whether or not the organization is inactive
      Returns:
      the saved organization
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBOrganizations getById(@RequestParam String orgCode)
      This method returns a single organization.
      Parameters:
      orgCode - code of the organization
      Returns:
      a single organization
    • updateOrganization

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBOrganizations updateOrganization(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganizations incoming)
      Update a single organization. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      orgCode - code of the organization
      incoming - the new organization contents
      Returns:
      the updated organization object
    • deleteOrganization

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteOrganization(@RequestParam String orgCode)
      Delete an organization. Accessible only to users with the role "ROLE_ADMIN".
      Parameters:
      orgCode - code of the organization
      Returns:
      a message indicating the organization was deleted