Class GroupController

java.lang.Object
vaultWeb.controllers.GroupController

@RestController @RequestMapping("/api/groups") public class GroupController extends Object
Controller for managing groups within the application.

Provides endpoints to list public groups, get details of a group, manage group membership, and create, update, or delete groups. Some operations require the user to have admin privileges.

  • Constructor Details

    • GroupController

      public GroupController()
  • Method Details

    • getGroups

      @GetMapping("") public org.springframework.http.ResponseEntity<List<Group>> getGroups()
      Retrieves all public groups.
      Returns:
      a list of public groups
    • getGroupById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<Group> getGroupById(@PathVariable Long id)
      Retrieves a group by its ID.
      Parameters:
      id - the ID of the group
      Returns:
      the group if found, or 404 if not found
    • getGroupMembers

      @GetMapping("/{id}/members") public org.springframework.http.ResponseEntity<List<User>> getGroupMembers(@PathVariable Long id)
      Retrieves all members of a given group.
      Parameters:
      id - the ID of the group
      Returns:
      a list of users in the group
    • createGroup

      @PostMapping("") public org.springframework.http.ResponseEntity<Group> createGroup(@RequestBody GroupDto groupDto)
      Creates a new group.
      Parameters:
      groupDto - the data for the new group
      Returns:
      the created group
    • joinGroup

      @PostMapping("/{id}/join") public org.springframework.http.ResponseEntity<Group> joinGroup(@PathVariable Long id)
      Current user joins a group.
      Parameters:
      id - the ID of the group to join
      Returns:
      the updated group
    • updateGroup

      @PutMapping("/{id}") public org.springframework.http.ResponseEntity<Group> updateGroup(@PathVariable Long id, @RequestBody GroupDto updatedGroup)
      Updates a group. Admin privileges required.
      Parameters:
      id - the ID of the group to update
      updatedGroup - the updated group data
      Returns:
      the updated group
    • deleteGroup

      @DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> deleteGroup(@PathVariable Long id)
      Deletes a group. Admin privileges required.
      Parameters:
      id - the ID of the group to delete
    • leaveGroup

      @DeleteMapping("/{id}/leave") public org.springframework.http.ResponseEntity<Group> leaveGroup(@PathVariable Long id)
      Current user leaves a group.
      Parameters:
      id - the ID of the group to leave
      Returns:
      the updated group
    • removeMemberFromGroup

      @DeleteMapping("/{groupId}/members/{userId}") public org.springframework.http.ResponseEntity<Group> removeMemberFromGroup(@PathVariable Long groupId, @PathVariable Long userId)
      Removes a member from a group. Admin privileges required.
      Parameters:
      groupId - the ID of the group
      userId - the ID of the user to remove
      Returns:
      the updated group