Class UCSBOrganizationController

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

@RequestMapping("/api/UCSBOrganization") @RestController public class UCSBOrganizationController extends ApiController
REST endpoints for UCSB organizations.
  • Constructor Details

    • UCSBOrganizationController

      public UCSBOrganizationController()
  • Method Details

    • allOrganizations

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<UCSBOrganization> allOrganizations()
      Returns all organizations for a logged-in user.
      Returns:
      all organizations in the database
    • getById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public UCSBOrganization getById(@RequestParam String orgCode)
      Returns a single organization by its organization code.
      Parameters:
      orgCode - the organization's unique code
      Returns:
      the matching organization
    • postOrganization

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public UCSBOrganization postOrganization(@RequestParam String orgCode, @RequestParam String orgTranslationShort, @RequestParam String orgTranslation, @RequestParam boolean inactive)
      Creates an organization. Only administrators may create organizations.
      Parameters:
      orgCode - the organization's unique code
      orgTranslationShort - the organization's abbreviated name
      orgTranslation - the organization's full name
      inactive - whether the organization is inactive
      Returns:
      the saved organization
    • deleteOrganization

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("") public Object deleteOrganization(@RequestParam String orgCode)
      Deletes an organization. Only administrators may delete organizations.
      Parameters:
      orgCode - the code of the organization to delete
      Returns:
      a confirmation message
    • updateOrganization

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("") public UCSBOrganization updateOrganization(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganization incoming)
      Updates an organization's fields while retaining its organization code.
      Parameters:
      orgCode - the code of the organization to update
      incoming - the new organization field values
      Returns:
      the updated organization