use of cz.metacentrum.perun.core.api.exceptions.PerunException in project perun by CESNET.
the class ExtSourcePerun method findRichUsers.
private List<RichUser> findRichUsers(String substring) {
String query;
// encode query params
query = "searchString=" + URLEncoder.encode(substring, StandardCharsets.UTF_8);
List<RichUser> richUsers;
try {
richUsers = this.call("usersManager", "findRichUsers", query).readList(RichUser.class);
} catch (PerunException ex) {
throw new InternalErrorException(ex);
}
Iterator<RichUser> iterator = richUsers.iterator();
while (iterator.hasNext()) {
RichUser richUser = iterator.next();
boolean hasLogin = false;
for (UserExtSource ues : richUser.getUserExtSources()) {
if (ues.getExtSource() != null && ues.getExtSource().getName().equals(extSourceNameForLogin)) {
hasLogin = true;
continue;
}
}
if (!hasLogin)
iterator.remove();
}
return richUsers;
}
use of cz.metacentrum.perun.core.api.exceptions.PerunException in project perun by CESNET.
the class ExtSourcePerun method findRichUsers.
private List<RichUser> findRichUsers(Integer groupId) {
// we don't need to encode query params here, no unsafe char in fixed string
String query = "group=" + groupId + "&" + "allowedStatuses[]=" + "VALID";
List<RichMember> richMembers;
try {
richMembers = this.call("membersManager", "getRichMembersWithAttributes", query).readList(RichMember.class);
} catch (PerunException ex) {
throw new InternalErrorException(ex);
}
return convertListOfRichMembersToListOfRichUsers(richMembers);
}
Aggregations