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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a group to the database if it doesn't exist already.boolean
addGroupMember
(Membership membership) Adds or updates the givengroupMember#member
to the givengroupMember#group
.void
close()
Closes the connection to the database.boolean
deleteGroup
(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 specifiedname
ornull
if it could not be found.getGroupMembers
(String name) Returns the members of the groupname
as set.Lists all groups.boolean
removeGroupMember
(IdentityPublicKey member, String groupName) Removes themember
from the givengroup
.boolean
updateGroup
(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:DatabaseAdapter
Adds a group to the database if it doesn't exist already.- Specified by:
addGroup
in interfaceDatabaseAdapter
- 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
Description copied from interface:DatabaseAdapter
Adds or updates the givengroupMember#member
to the givengroupMember#group
.- Specified by:
addGroupMember
in interfaceDatabaseAdapter
- 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
Description copied from interface:DatabaseAdapter
Returns the group with the specifiedname
ornull
if it could not be found.- Specified by:
getGroup
in interfaceDatabaseAdapter
- 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
Description copied from interface:DatabaseAdapter
Lists all groups.- Specified by:
getGroups
in interfaceDatabaseAdapter
- Returns:
- List with all groups
- Throws:
DatabaseException
- if an error occurs during the execution
-
deleteGroup
Description copied from interface:DatabaseAdapter
Deleted the group with the specifiedname
.- Specified by:
deleteGroup
in interfaceDatabaseAdapter
- Parameters:
name
- the name of the group- Returns:
true
if group was deleted. Otherwisefalse
.- Throws:
DatabaseException
- if an error occurs during removal
-
updateGroup
Description copied from interface:DatabaseAdapter
Updates the specifiedgroup
.- Specified by:
updateGroup
in interfaceDatabaseAdapter
- Parameters:
group
- the new desired group state (name is unchangeable)- Returns:
true
if group was updated. Otherwisefalse
.- Throws:
DatabaseException
- if an error occurs during update
-
getGroupMembers
Description copied from interface:DatabaseAdapter
Returns the members of the groupname
as set.- Specified by:
getGroupMembers
in 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:DatabaseAdapter
Removes themember
from the givengroup
.- Specified by:
removeGroupMember
in interfaceDatabaseAdapter
- Parameters:
member
- the member to removegroupName
- the group- Returns:
true
if memberships was deleted. Otherwisefalse
.- Throws:
DatabaseException
- if an exception occurs during removal
-
close
Description copied from interface:DatabaseAdapter
Closes the connection to the database.- Specified by:
close
in interfaceDatabaseAdapter
- Throws:
DatabaseException
- if an error occurs during closing
-
deleteStaleMemberships
Description copied from interface:DatabaseAdapter
Deletes all stale memberships from all groups and returns the deleted members.- Specified by:
deleteStaleMemberships
in interfaceDatabaseAdapter
- Throws:
DatabaseException
- if an error occurred during deletion
-