Skip to content

Commit

Permalink
SAK-46408 Roster - Searching string with many matches does not return…
Browse files Browse the repository at this point in the history
… any result (sakaiproject#9924)
  • Loading branch information
Fernando Alvarez-Castellanos Rojo authored Oct 29, 2021
1 parent 0fb7278 commit dc6292d
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import lombok.extern.slf4j.Slf4j;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.entitybroker.EntityReference;
import org.sakaiproject.entitybroker.EntityView;
Expand Down Expand Up @@ -265,33 +266,33 @@ public Object getUsers(EntityReference reference, Map<String, Object> parameters
roleId = parameters.get(KEY_ROLE_ID).toString();
}

List<RosterMember> membership = new ArrayList();
Map<String, Integer> roleCounts = new HashMap(1);
List<RosterMember> membership = new ArrayList<>();
Map<String, Integer> roleCounts = new HashMap<>(1);

for (String userId : userIds) {
RosterMember member = sakaiProxy.getMember(siteId, userId, groupId, enrollmentSetId);

if (null == member) {
throw new EntityException("Unable to retrieve membership", reference.getReference());
}

if(roleId != null) {
if(StringUtils.equals(member.getRole(), roleId)) {
if (member != null) {
if(roleId != null) {
if(StringUtils.equals(member.getRole(), roleId)) {
membership.add(member);
}
} else {
membership.add(member);
}
} else {
membership.add(member);
}


String role = member.getRole();
if (!roleCounts.containsKey(role)) {
roleCounts.put(role, 1);
} else {
roleCounts.put(role, roleCounts.get(role) + 1);
String role = member.getRole();
if (!roleCounts.containsKey(role)) {
roleCounts.put(role, 1);
} else {
roleCounts.put(role, roleCounts.get(role) + 1);
}
}
}

if (CollectionUtils.isEmpty(membership)) {
throw new EntityException("Unable to retrieve membership", reference.getReference());
}

RosterData data = new RosterData();
data.setMembers(membership);
data.setMembersTotal(membership.size());
Expand Down

0 comments on commit dc6292d

Please sign in to comment.