示例#1
0
 private static Set<String> getRemoteIds(List<SyncResponseEvent> events) {
   Set<String> ids = new HashSet<String>(events.size());
   for (SyncResponseEvent event : events) {
     if (event.isAddContact() || event.isUpdateContact()) {
       ids.add(RemoteId.contactId(event.getContactId()).toString());
     }
   }
   return ids;
 }
示例#2
0
 private void processEvent(SyncResponseEvent event, Stats stats) throws ServiceException {
   Contact contact = event.getContact();
   RemoteId rid = RemoteId.contactId(contact.getId());
   DataSourceItem dsi = localData.getReverseMapping(rid.toString());
   if (event.isAddContact() || event.isUpdateContact()) {
     if (dsi.itemId > 0) {
       // Don't update contact if it has been modified locally since
       // sync request was sent. Wait until we send the new changes
       // before updating the local contact.
       if (!contactChanges.containsKey(dsi.itemId)) {
         updateContact(contact, dsi, stats);
       }
     } else {
       addContact(contact, stats);
     }
   } else if (event.isRemoveContact()) {
     if (dsi.itemId > 0) {
       deleteContact(dsi.itemId, stats);
     }
   }
 }
示例#3
0
 private void updateContactMapping(int itemId, Contact contact) throws ServiceException {
   RemoteId rid = RemoteId.contactId(contact.getId());
   localData.updateMapping(itemId, rid.toString(), toXml(contact));
 }