* @throws ServiceException if the insert request failed due to system error.
*/
protected UserFeed getUsers(String domain, String username, String password)
throws MalformedURLException, IOException, ServiceException {
String domainUrlBase = null;
UserFeed allUsers = null;
UserService userService = new UserService(GmailSettingsClient.APP_TITLE);
userService.setUserCredentials(username + "@" + domain, password);
domainUrlBase = "https://www.google.com/a/feeds/" + domain + "/";
URL retrieveUrl = new URL(domainUrlBase + "user/2.0/");
AppsForYourDomainQuery query = new AppsForYourDomainQuery(retrieveUrl);
query.setStartUsername(null);
allUsers = new UserFeed();
UserFeed currentPage;
Link nextLink;
do {
currentPage = userService.query(query, UserFeed.class);
allUsers.getEntries().addAll(currentPage.getEntries());
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} while (nextLink != null);