Skip to content
Snippets Groups Projects
Commit 9db00f37 authored by Brian Major's avatar Brian Major
Browse files

nep110 - Rework: actions don't get persistent member objects before group update

parent 5baae280
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,6 @@ import ca.nrc.cadc.ac.GroupAlreadyExistsException;
import ca.nrc.cadc.ac.server.GroupPersistence;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class AddGroupMemberAction extends GroupsAction
{
......@@ -93,7 +92,7 @@ public class AddGroupMemberAction extends GroupsAction
{
GroupPersistence groupPersistence = getGroupPersistence();
Group group = groupPersistence.getGroup(this.groupName);
Group toAdd = groupPersistence.getGroup(this.groupMemberName);
Group toAdd = new Group(this.groupMemberName);
if (!group.getGroupMembers().add(toAdd))
{
throw new GroupAlreadyExistsException(this.groupMemberName);
......
......@@ -99,14 +99,14 @@ public class AddUserMemberAction extends GroupsAction
throws Exception
{
GroupPersistence groupPersistence = getGroupPersistence();
UserPersistence userPersistence = getUserPersistence();
Group group = groupPersistence.getGroup(this.groupName);
Principal userPrincipal = AuthenticationUtil.createPrincipal(this.userID, this.userIDType);
User toAdd = userPersistence.getUser(userPrincipal);
User<Principal> toAdd = new User(userPrincipal);
if (!group.getUserMembers().add(toAdd))
{
throw new MemberAlreadyExistsException();
}
groupPersistence.modifyGroup(group);
List<String> addedMembers = new ArrayList<String>();
......
......@@ -92,7 +92,7 @@ public class RemoveGroupMemberAction extends GroupsAction
{
GroupPersistence groupPersistence = getGroupPersistence();
Group group = groupPersistence.getGroup(this.groupName);
Group toRemove = groupPersistence.getGroup(this.groupMemberName);
Group toRemove = new Group(this.groupMemberName);
if (!group.getGroupMembers().remove(toRemove))
{
throw new GroupNotFoundException(this.groupMemberName);
......
......@@ -97,10 +97,9 @@ public class RemoveUserMemberAction extends GroupsAction
throws Exception
{
GroupPersistence groupPersistence = getGroupPersistence();
UserPersistence userPersistence = getUserPersistence();
Group group = groupPersistence.getGroup(this.groupName);
Principal userPrincipal = AuthenticationUtil.createPrincipal(this.userID, this.userIDType);
User toRemove = userPersistence.getUser(userPrincipal);
User<Principal> toRemove = new User(userPrincipal);
if (!group.getUserMembers().remove(toRemove))
{
throw new MemberNotFoundException();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment