Interface DatabaseAdapter
- All Known Implementing Classes:
JdbcDatabaseAdapter
public interface DatabaseAdapter
This class is responsible for storing the groups plugin options.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a group to the database if it doesn't exist already.booleanaddGroupMember(Membership membership) Adds or updates the givengroupMember#memberto the givengroupMember#group.voidclose()Closes the connection to the database.booleandeleteGroup(String name) Deleted the group with the specifiedname.Deletes all stale memberships from all groups and returns the deleted members.Returns the group with the specifiednameornullif it could not be found.getGroupMembers(String name) Returns the members of the groupnameas set.Lists all groups.booleanremoveGroupMember(IdentityPublicKey member, String groupName) Removes thememberfrom the givengroup.booleanupdateGroup(Group group) Updates the specifiedgroup.
-
Method Details
-
addGroup
Adds a group to the database if it doesn't exist already.- Parameters:
group- the group that should be added- Returns:
trueif the group was added,falseif it already exist- Throws:
DatabaseException- if an error occurs during the execution
-
addGroupMember
Adds or updates the givengroupMember#memberto the givengroupMember#group.- Parameters:
membership- the entry that should be added or updated- Returns:
trueif the member was inserted and not updated- Throws:
DatabaseException- if an error occurs during the execution
-
getGroup
Returns the group with the specifiednameornullif it could not be found.- Parameters:
name- the name of the group- Returns:
- group or
nullif it could not be found - Throws:
DatabaseException- if an error occurs during the deletion
-
getGroups
Lists all groups.- Returns:
- List with all groups
- Throws:
DatabaseException- if an error occurs during the execution
-
deleteGroup
Deleted the group with the specifiedname.- Parameters:
name- the name of the group- Returns:
trueif group was deleted. Otherwisefalse.- Throws:
DatabaseException- if an error occurs during removal
-
updateGroup
Updates the specifiedgroup.- Parameters:
group- the new desired group state (name is unchangeable)- Returns:
trueif group was updated. Otherwisefalse.- Throws:
DatabaseException- if an error occurs during update
-
getGroupMembers
Returns the members of the groupnameas set.- Parameters:
name- the group name- Returns:
- members of the group as set
- Throws:
DatabaseException- if an error occurs during the execution
-
removeGroupMember
Removes thememberfrom the givengroup.- Parameters:
member- the member to removegroupName- the group- Returns:
trueif memberships was deleted. Otherwisefalse.- Throws:
DatabaseException- if an exception occurs during removal
-
close
Closes the connection to the database.- Throws:
DatabaseException- if an error occurs during closing
-
deleteStaleMemberships
Deletes all stale memberships from all groups and returns the deleted members.- Throws:
DatabaseException- if an error occurred during deletion
-