Example #1
0
  public void importAllContacts() throws IOException, ServiceException {
    // import contacts
    setService();

    URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/[email protected]/full");
    Query myQuery = new Query(feedUrl);
    myQuery.setMaxResults(10);

    ContactFeed resultFeed = myService.query(myQuery, ContactFeed.class);
    // Print the results
    System.out.println(resultFeed.getTitle().getPlainText());
    for (int i = 0; i < resultFeed.getEntries().size(); i++) {
      ContactEntry entry = resultFeed.getEntries().get(i);
      // Determine if this contact entry already exists in database (check Google ID):
      System.out.println(entry.getEtag());
      System.out.println(entry.getId());
      // if individual exists with Google ID, check to see if that invididual has all the emails
      // listed:
      //   People tryPerosn = peopleRepo.findByPropertyValue("googleId", "googleId", entry.getId());
      if (peopleRepo.findByPropertyValue("googleId", "googleId", entry.getEtag()) != null) {

        System.out.println(
            peopleRepo
                    .findByPropertyValue("googleId", "googleId", entry.getId())
                    .getNodeId()
                    .toString()
                + " He exists!");
      } else {
        importContact(entry);
      }
      entry.getEmailAddresses();
    }

    // If entry exists, check to see if entry
  }