Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #145 GHTeam.getMembers() does not page properly #146

Merged
merged 1 commit into from
Feb 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/main/java/org/kohsuke/github/GHTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

/**
* A team in GitHub organization.
Expand Down Expand Up @@ -48,12 +52,27 @@ public int getId() {
return id;
}

/**
* Retrieves the current members.
*/
public Set<GHUser> getMembers() throws IOException {
return new HashSet<GHUser>(Arrays.asList(GHUser.wrap(org.root.retrieve().to(api("/members"), GHUser[].class), org.root)));
}
/**
* Retrieves the current members.
*/
public Set<GHUser> getMembers() throws IOException {

Set<GHUser> members = new LinkedHashSet<GHUser>();

Iterator<GHUser[]> pageIterator = org.root.retrieve().asIterator(api("/members"),
GHUser[].class);
while (pageIterator != null && pageIterator.hasNext()) {
GHUser[] users = pageIterator.next();
if (users != null) {
GHUser.wrap(users, org.root);
for (GHUser user : users) {
members.add(user);
}
}
}

return Collections.unmodifiableSet(members);
}

/**
* Checks if this team has the specified user as a member.
Expand Down