예제 #1
0
 @Override
 public void addListMembers(String tweep, String listName) throws TwitterException {
   final List<TwitterUser> users = new ArrayList<TwitterUser>();
   long cursor = -1;
   while (cursor != 0) {
     PagableResponseList<User> members = twitter.getUserListMembers(tweep, listName, cursor);
     for (User member : members) {
       TwitterUser user = TwitterUser.fromUser(member);
       TwitterUser existingUser = twitterUserRepository.findOne(user.getId());
       if (existingUser == null) {
         user.setListMember(true);
         user.setType(TweepTypes.IMPORTED);
         users.add(user);
       }
     }
     cursor = members.getNextCursor();
   }
   twitterUserRepository.save(users).iterator();
 }
예제 #2
0
 private void readListMembers(PagableResponseList<User> members, List<TwitterUser> existingUsers) {
   final List<TwitterUser> users = new ArrayList<TwitterUser>();
   for (User member : members) {
     TwitterUser user = TwitterUser.fromUser(member);
     if (!existingUsers.contains(user)) {
       TwitterUser existingUser = twitterUserRepository.findOne(user.getId());
       if (existingUser != null) {
         existingUser.setListMember(true);
         existingUser.setType(TweepTypes.MEMBER);
         users.add(existingUser);
       } else {
         user.setListMember(true);
         user.setType(TweepTypes.MEMBER);
         users.add(user);
       }
     }
   }
   CollectionUtils.addAll(existingUsers, twitterUserRepository.save(users).iterator());
   // log.info(users.size() + " new members added.");
 }