Commit 89aecbad authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added #updateMember to be able to update the privileges of a group user. JM-254


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1236 b35dd754-fafc-0310-a699-88a17e54d16e
parent 0f35b6c1
...@@ -57,6 +57,8 @@ public class DefaultGroupProvider implements GroupProvider { ...@@ -57,6 +57,8 @@ public class DefaultGroupProvider implements GroupProvider {
"DELETE FROM jiveGroupUser WHERE groupName=? AND username=?"; "DELETE FROM jiveGroupUser WHERE groupName=? AND username=?";
private static final String ADD_USER = private static final String ADD_USER =
"INSERT INTO jiveGroupUser (groupName, username, administrator) VALUES (?, ?, ?)"; "INSERT INTO jiveGroupUser (groupName, username, administrator) VALUES (?, ?, ?)";
private static final String UPDATE_USER =
"UPDATE jiveGroupUser SET administrator=? WHERE groupName=? AND username=?";
private static final String USER_GROUPS = private static final String USER_GROUPS =
"SELECT groupName FROM jiveGroupUser WHERE username=?"; "SELECT groupName FROM jiveGroupUser WHERE username=?";
private static final String ALL_GROUPS = "SELECT groupName FROM jiveGroup ORDER BY groupName"; private static final String ALL_GROUPS = "SELECT groupName FROM jiveGroup ORDER BY groupName";
...@@ -362,6 +364,28 @@ public class DefaultGroupProvider implements GroupProvider { ...@@ -362,6 +364,28 @@ public class DefaultGroupProvider implements GroupProvider {
} }
} }
public void updateMember(String groupName, String username, boolean administrator) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(UPDATE_USER);
pstmt.setInt(1, administrator ? 1 : 0);
pstmt.setString(2, groupName);
pstmt.setString(3, username);
pstmt.executeUpdate();
}
catch (SQLException e) {
Log.error(e);
}
finally {
try { if (pstmt != null) pstmt.close(); }
catch (Exception e) { Log.error(e); }
try { if (con != null) con.close(); }
catch (Exception e) { Log.error(e); }
}
}
public void deleteMember(String groupName, String username) { public void deleteMember(String groupName, String username) {
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
......
...@@ -132,6 +132,18 @@ public interface GroupProvider { ...@@ -132,6 +132,18 @@ public interface GroupProvider {
void addMember(String groupName, String username, boolean administrator) void addMember(String groupName, String username, boolean administrator)
throws UnsupportedOperationException; throws UnsupportedOperationException;
/**
* Updates the privileges of a user in a group.
*
* @param groupName the group where the change happened
* @param username the username to of the user with new privileges
* @param administrator True if the member is an administrator of the group
* @throws UnsupportedOperationException if the provider does not
* support the operation.
*/
void updateMember(String groupName, String username, boolean administrator)
throws UnsupportedOperationException;
/** /**
* Deletes a user from a group (optional operation). * Deletes a user from a group (optional operation).
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment