Class UCSBOrganizationController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.UCSBOrganizationController
@RequestMapping("/api/ucsborganizations")
@RestController
public class UCSBOrganizationController
extends ApiController
This is a REST controller for UCSBOrganization
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method returns a list of all UCSB organizations.deleteOrganization
(String orgCode) Delete a UCSBOrganization.This method returns a single UCSB organization.postOrganization
(String orgCode, String orgTranslationShort, String orgTranslation, boolean inactive) This method creates a new organization.updateOrganization
(String orgCode, @Valid UCSBOrganization incoming) Update a single UCSB organization.Methods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBOrganizationController
public UCSBOrganizationController()
-
-
Method Details
-
allOrganizations
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBOrganization> allOrganizations()This method returns a list of all UCSB organizations.- Returns:
- a list of all UCSB organizations
-
postOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBOrganization postOrganization(@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
- org code of the organizationorgTranslationShort
- short translation of the organizationorgTranslation
- translation of the organizationinactive
- whether or not the organization is inactive- Returns:
- the save organization
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBOrganization getById(@RequestParam String orgCode) This method returns a single UCSB organization.- Parameters:
orgCode
- orgCode of the UCSB organization- Returns:
- a single UCSB organization
-
updateOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBOrganization updateOrganization(@RequestParam String orgCode, @RequestBody @Valid @Valid UCSBOrganization incoming) Update a single UCSB organization. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- orgCode of the UCSB organizationincoming
- the new UCSB organization contents- Returns:
- the updated UCSB organization object
-
deleteOrganization
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteOrganization(@RequestParam String orgCode) Delete a UCSBOrganization. Accessible only to users with the role "ROLE_ADMIN".- Parameters:
orgCode
- orgCode of the organization- Returns:
- a message indiciating the organization was deleted
-