mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
DS-3572: Restored behaviour of GroupService.isMember and moved new behaviour to GroupService.isParentOf
This commit is contained in:

committed by
Pascal-Nicolas Becker

parent
aeb3af9b2f
commit
59087eed9b
@@ -7,9 +7,6 @@
|
||||
*/
|
||||
package org.dspace.eperson;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -36,7 +33,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -157,8 +153,13 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMember(Context context, Group owningGroup, Group childGroup) throws SQLException {
|
||||
return group2GroupCacheDAO.findByParentAndChild(context, owningGroup, childGroup) != null;
|
||||
public boolean isMember(Group owningGroup, Group childGroup) {
|
||||
return owningGroup.contains(childGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParentOf(Context context, Group parentGroup, Group childGroup) throws SQLException {
|
||||
return group2GroupCacheDAO.findByParentAndChild(context, parentGroup, childGroup) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +204,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
||||
while (it.hasNext() && !isMember) {
|
||||
Group specialGroup = it.next();
|
||||
//Check if the special group matches the given group or if it is a subgroup (with 1 query)
|
||||
if (specialGroup.equals(group) || isMember(context, group, specialGroup)) {
|
||||
if (specialGroup.equals(group) || isParentOf(context, group, specialGroup)) {
|
||||
isMember = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user