Java 如何检索我的域中的所有用户

Java 如何检索我的域中的所有用户,java,google-apps,Java,Google Apps,我在该域中创建了一个域,我创建了近500个用户帐户。我想检索域中的所有用户。因此,我使用以下编码检索域中的所有用户。但在该编码中,我只显示了前100个用户。它还显示了用户条目总数100。我不知道该编码有什么问题 import com.google.gdata.client.appsforyourdomain.UserService; import com.google.gdata.data.appsforyourdomain.provisioning.UserEntry; import com.

我在该域中创建了一个域,我创建了近500个用户帐户。我想检索域中的所有用户。因此,我使用以下编码检索域中的所有用户。但在该编码中,我只显示了前100个用户。它还显示了用户条目总数100。我不知道该编码有什么问题

import com.google.gdata.client.appsforyourdomain.UserService;
import com.google.gdata.data.appsforyourdomain.provisioning.UserEntry;
import com.google.gdata.data.appsforyourdomain.provisioning.UserFeed;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

/**
 * This is a test template
 */

  public class AppsProvisioning {

    public static void main(String[] args) {

      try {

        // Create a new Apps Provisioning service
        UserService myService = new UserService("My Application");
        myService.setUserCredentials(admin,password);

        // Get a list of all entries
        URL metafeedUrl = new URL("https://www.google.com/a/feeds/"+domain+"/user/2.0/");
        System.out.println("Getting user entries...\n");
        UserFeed resultFeed = myService.getFeed(metafeedUrl, UserFeed.class);
        List<UserEntry> entries = resultFeed.getEntries();
        for(int i=0; i<entries.size(); i++) {
          UserEntry entry = entries.get(i);
          System.out.println("\t" + entry.getTitle().getPlainText());
        }
        System.out.println("\nTotal Entries: "+entries.size());
      }
      catch(AuthenticationException e) {
        e.printStackTrace();
      }
      catch(MalformedURLException e) {
        e.printStackTrace();
      }
      catch(ServiceException e) {
        e.printStackTrace();
      }
      catch(IOException e) {
        e.printStackTrace();
      }
    }
  }
import com.google.gdata.client.appsforyourdomain.UserService;
导入com.google.gdata.data.appsforyourdomain.provisioning.UserEntry;
导入com.google.gdata.data.appsforyourdomain.provisioning.UserFeed;
导入com.google.gdata.util.AuthenticationException;
导入com.google.gdata.util.ServiceException;
导入java.io.IOException;
导入java.net.MalformedURLException;
导入java.net.URL;
导入java.util.List;
/**
*这是一个测试模板
*/
公共类应用程序提供{
公共静态void main(字符串[]args){
试一试{
//创建新的应用程序设置服务
UserService myService=newuserservice(“我的应用程序”);
setUserCredentials(管理员、密码);
//获取所有条目的列表
URL metafeedUrl=新URL(“https://www.google.com/a/feeds/“+domain+”/user/2.0/”;
System.out.println(“获取用户条目…\n”);
UserFeed resultFeed=myService.getFeed(metafeedUrl,UserFeed.class);
List entries=resultFeed.getEntries();

对于(int i=0;i用户列表在atom提要中返回。这是一个分页提要,每页最多有100个条目。如果提要中有更多条目,则将有一个atom:link元素,该元素具有rel=“next”属性,指向下一页。您需要继续跟踪这些链接,直到没有更多的“next”页面

见:

代码将类似于:

URL metafeedUrl = new URL("https://www.google.com/a/feeds/"+domain+"/user/2.0/");
System.out.println("Getting user entries...\n");
List<UserEntry> entries = new ArrayList<UserEntry>();

while (metafeedUrl != null) {
    // Fetch page
    System.out.println("Fetching page...\n");
    UserFeed resultFeed = myService.getFeed(metafeedUrl, UserFeed.class);
    entries.addAll(resultFeed.getEntries());

    // Check for next page
    Link nextLink = resultFeed.getNextLink();
    if (nextLink == null) {
        metafeedUrl = null;
    } else {
        metafeedUrl = nextLink.getHref();
    }
}

// Handle results
for(int i=0; i<entries.size(); i++) {
    UserEntry entry = entries.get(i);
    System.out.println("\t" + entry.getTitle().getPlainText());
}
System.out.println("\nTotal Entries: "+entries.size());
URL metafeedUrl=新URL(“https://www.google.com/a/feeds/“+domain+”/user/2.0/”;
System.out.println(“获取用户条目…\n”);
列表项=新的ArrayList();
while(metafeedUrl!=null){
//获取页面
System.out.println(“获取页面…\n”);
UserFeed resultFeed=myService.getFeed(metafeedUrl,UserFeed.class);
entries.addAll(resultFeed.getEntries());
//查看下一页
Link nextLink=resultFeed.getNextLink();
if(nextLink==null){
metafeedUrl=null;
}否则{
metafeedUrl=nextLink.getHref();
}
}
//处理结果
对于(int i=0;i