Class JdbcDatabaseAdapter
java.lang.Object
org.drasyl.node.plugin.groups.manager.database.jdbc.JdbcDatabaseAdapter
- All Implemented Interfaces:
DatabaseAdapter
DatabaseAdapter implementation that supports SQL databases.-
Field Summary
Fields -
Constructor Summary
Constructors -
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.
-
Field Details
-
QUERY_TIMEOUT
public static final int QUERY_TIMEOUT- See Also:
-
SCHEME
- See Also:
-
-
Constructor Details
-
JdbcDatabaseAdapter
- Throws:
DatabaseException
-
-
Method Details
-
addGroup
Description copied from interface:DatabaseAdapterAdds a group to the database if it doesn't exist already.- Specified by:
addGroupin interfaceDatabaseAdapter- 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
Description copied from interface:DatabaseAdapterAdds or updates the givengroupMember#memberto the givengroupMember#group.- Specified by:
addGroupMemberin interfaceDatabaseAdapter- 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
Description copied from interface:DatabaseAdapterReturns the group with the specifiednameornullif it could not be found.- Specified by:
getGroupin interfaceDatabaseAdapter- 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
Description copied from interface:DatabaseAdapterLists all groups.- Specified by:
getGroupsin interfaceDatabaseAdapter- Returns:
- List with all groups
- Throws:
DatabaseException- if an error occurs during the execution
-
deleteGroup
Description copied from interface:DatabaseAdapterDeleted the group with the specifiedname.- Specified by:
deleteGroupin interfaceDatabaseAdapter- Parameters:
name- the name of the group- Returns:
trueif group was deleted. Otherwisefalse.- Throws:
DatabaseException- if an error occurs during removal
-
updateGroup
Description copied from interface:DatabaseAdapterUpdates the specifiedgroup.- Specified by:
updateGroupin interfaceDatabaseAdapter- 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
Description copied from interface:DatabaseAdapterReturns the members of the groupnameas set.- Specified by:
getGroupMembersin interfaceDatabaseAdapter- Parameters:
name- the group name- Returns:
- members of the group as set
- Throws:
DatabaseException- if an error occurs during the execution
-
removeGroupMember
public boolean removeGroupMember(IdentityPublicKey member, String groupName) throws DatabaseException Description copied from interface:DatabaseAdapterRemoves thememberfrom the givengroup.- Specified by:
removeGroupMemberin interfaceDatabaseAdapter- Parameters:
member- the member to removegroupName- the group- Returns:
trueif memberships was deleted. Otherwisefalse.- Throws:
DatabaseException- if an exception occurs during removal
-
close
Description copied from interface:DatabaseAdapterCloses the connection to the database.- Specified by:
closein interfaceDatabaseAdapter- Throws:
DatabaseException- if an error occurs during closing
-
deleteStaleMemberships
Description copied from interface:DatabaseAdapterDeletes all stale memberships from all groups and returns the deleted members.- Specified by:
deleteStaleMembershipsin interfaceDatabaseAdapter- Throws:
DatabaseException- if an error occurred during deletion
-