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
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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>();
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −2
Original line number Diff line number Diff line
@@ -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();