Ticket #269: Actually add to removed permissions set, actually create removed/added permissions sets (MySQLUser).

This commit is contained in:
Michael Jumper
2013-02-25 21:56:04 -08:00
parent fa6479ddac
commit 60a8d753c3

View File

@@ -75,23 +75,23 @@ public class MySQLUser implements User {
/** /**
* The set of current permissions a user has. * The set of current permissions a user has.
*/ */
Set<Permission> permissions; private Set<Permission> permissions;
/** /**
* Any newly added permissions that have yet to be committed. * Any newly added permissions that have yet to be committed.
*/ */
Set<Permission> newPermissions; private Set<Permission> newPermissions = new HashSet<Permission>();
/** /**
* Any newly deleted permissions that have yet to be deleted. * Any newly deleted permissions that have yet to be deleted.
*/ */
Set<Permission> removedPermissions; private Set<Permission> removedPermissions = new HashSet<Permission>();
/** /**
* Get the current set of permissions this user has. * Get the current set of permissions this user has.
* @return the current set of permissions. * @return the current set of permissions.
*/ */
Set<Permission> getCurrentPermissions() { public Set<Permission> getCurrentPermissions() {
return permissions; return permissions;
} }
@@ -99,7 +99,7 @@ public class MySQLUser implements User {
* Get any new permissions that have yet to be inserted. * Get any new permissions that have yet to be inserted.
* @return the new set of permissions. * @return the new set of permissions.
*/ */
Set<Permission> getNewPermissions() { public Set<Permission> getNewPermissions() {
return newPermissions; return newPermissions;
} }
@@ -107,7 +107,7 @@ public class MySQLUser implements User {
* Get any permissions that have not yet been deleted. * Get any permissions that have not yet been deleted.
* @return the permissions that need to be deleted. * @return the permissions that need to be deleted.
*/ */
Set<Permission> getRemovedPermissions() { public Set<Permission> getRemovedPermissions() {
return removedPermissions; return removedPermissions;
} }
@@ -115,7 +115,7 @@ public class MySQLUser implements User {
* Reset the new and removed permission sets after they are * Reset the new and removed permission sets after they are
* no longer needed. * no longer needed.
*/ */
void resetPermissions() { public void resetPermissions() {
newPermissions.clear(); newPermissions.clear();
removedPermissions.clear(); removedPermissions.clear();
} }
@@ -258,12 +258,14 @@ public class MySQLUser implements User {
public void addPermission(Permission permission) throws GuacamoleException { public void addPermission(Permission permission) throws GuacamoleException {
permissions.add(permission); permissions.add(permission);
newPermissions.add(permission); newPermissions.add(permission);
removedPermissions.remove(permission);
} }
@Override @Override
public void removePermission(Permission permission) throws GuacamoleException { public void removePermission(Permission permission) throws GuacamoleException {
permissions.remove(permission); permissions.remove(permission);
removedPermissions.remove(permission); newPermissions.remove(permission);
removedPermissions.add(permission);
} }
@Override @Override