Class GroupController
java.lang.Object
edu.cnm.deepdive.teamassignments.controller.GroupController
controller for group with Spring annotation mapping.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
delete(long id, Authentication auth)
delete mapping for group.get(long id, Authentication auth)
get mapping for group.getGroups(boolean ownedOnly, Authentication auth)
Iterable group object used to get all groups created.boolean
getMembership(long groupId, long userId, Authentication auth)
get mapping for checking membership.post(Group group, Authentication auth)
Post mapping for adding a group.boolean
putMembership(long groupId, long userId, boolean inGroup, Authentication auth)
Put mapping for membership.replaceName(long id, String name, Authentication auth)
put mapping for renaming group.
-
Constructor Details
-
GroupController
Constructor for group.- Parameters:
service
- - GroupService class, used for repository work.
-
-
Method Details
-
post
@PostMapping(consumes="application/json", produces="application/json") public ResponseEntity<Group> post(@RequestBody Group group, Authentication auth)Post mapping for adding a group.- Parameters:
group
- group object from group entity class.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- provides new group object via Json.
-
putMembership
@PutMapping(value="/{groupId:\\d+}/members/{userId:\\d+}", consumes="application/json", produces="application/json") public boolean putMembership(@PathVariable long groupId, @PathVariable long userId, @RequestBody boolean inGroup, Authentication auth)Put mapping for membership.- Parameters:
groupId
- path variable for group iduserId
- path variable for user idinGroup
- boolean valuable used to verify if individual is in group that is added to body of request.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- provides boolean value verifying group membership.
-
getMembership
@GetMapping(value="/{groupId:\\d+}/members/{userId:\\d+}", produces="application/json") public boolean getMembership(@PathVariable long groupId, @PathVariable long userId, Authentication auth)get mapping for checking membership.- Parameters:
groupId
- path variable for group iduserId
- path variable for user idauth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- provides userId boolean value via JSON.
-
get
@GetMapping(value="/{id:\\d+}", produces="application/json") public Group get(@PathVariable long id, Authentication auth)get mapping for group.- Parameters:
id
- group id.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- provides Group object via JSON.
-
replaceName
@PutMapping(value="/{id:\\d+}/name", consumes="text/plain", produces="text/plain") public String replaceName(@PathVariable long id, @RequestBody String name, Authentication auth)put mapping for renaming group.- Parameters:
id
- parent group id.name
- String value in body used to update name.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- provides String object via Json.
-
getGroups
@GetMapping(produces="application/json") public Iterable<Group> getGroups(@RequestParam(required=false,defaultValue="false") boolean ownedOnly, Authentication auth)Iterable group object used to get all groups created.- Parameters:
ownedOnly
- Iterable list for owned groups.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.- Returns:
- Group Iterable via Json.
-
delete
@DeleteMapping("/{id:\\d+}") @ResponseStatus(NO_CONTENT) public void delete(@PathVariable long id, Authentication auth)delete mapping for group.- Parameters:
id
- group id to delete.auth
- token for an authenticated principal once the request has been processed by the AuthenticationManager.authenticate(Authentication) method.
-