Interface DatabaseAdapter

All Known Implementing Classes:
JdbcDatabaseAdapter

public interface DatabaseAdapter
This class is responsible for storing the groups plugin options.
  • Method Details

    • addGroup

      boolean addGroup(Group group) throws DatabaseException
      Adds a group to the database if it doesn't exist already.
      Parameters:
      group - the group that should be added
      Returns:
      true if the group was added, false if it already exist
      Throws:
      DatabaseException - if an error occurs during the execution
    • addGroupMember

      boolean addGroupMember(Membership membership) throws DatabaseException
      Adds or updates the given groupMember#member to the given groupMember#group.
      Parameters:
      membership - the entry that should be added or updated
      Returns:
      true if the member was inserted and not updated
      Throws:
      DatabaseException - if an error occurs during the execution
    • getGroup

      Group getGroup(String name) throws DatabaseException
      Returns the group with the specified name or null if it could not be found.
      Parameters:
      name - the name of the group
      Returns:
      group or null if it could not be found
      Throws:
      DatabaseException - if an error occurs during the deletion
    • getGroups

      Set<Group> getGroups() throws DatabaseException
      Lists all groups.
      Returns:
      List with all groups
      Throws:
      DatabaseException - if an error occurs during the execution
    • deleteGroup

      boolean deleteGroup(String name) throws DatabaseException
      Deleted the group with the specified name.
      Parameters:
      name - the name of the group
      Returns:
      true if group was deleted. Otherwise false.
      Throws:
      DatabaseException - if an error occurs during removal
    • updateGroup

      boolean updateGroup(Group group) throws DatabaseException
      Updates the specified group.
      Parameters:
      group - the new desired group state (name is unchangeable)
      Returns:
      true if group was updated. Otherwise false.
      Throws:
      DatabaseException - if an error occurs during update
    • getGroupMembers

      Set<Membership> getGroupMembers(String name) throws DatabaseException
      Returns the members of the group name as set.
      Parameters:
      name - the group name
      Returns:
      members of the group as set
      Throws:
      DatabaseException - if an error occurs during the execution
    • removeGroupMember

      boolean removeGroupMember(IdentityPublicKey member, String groupName) throws DatabaseException
      Removes the member from the given group.
      Parameters:
      member - the member to remove
      groupName - the group
      Returns:
      true if memberships was deleted. Otherwise false.
      Throws:
      DatabaseException - if an exception occurs during removal
    • close

      void close() throws DatabaseException
      Closes the connection to the database.
      Throws:
      DatabaseException - if an error occurs during closing
    • deleteStaleMemberships

      Set<Membership> deleteStaleMemberships() throws DatabaseException
      Deletes all stale memberships from all groups and returns the deleted members.
      Throws:
      DatabaseException - if an error occurred during deletion