Example #1
0
 private void updateGroup(String remoteId, ContactGroup group, Stats stats)
     throws ServiceException {
   DataSourceItem dsi = localData.getReverseMapping(remoteId);
   if (dsi.itemId > 0) {
     if (group.isEmpty()) {
       localData.deleteContactGroup(dsi.itemId);
       stats.deleted++;
     } else {
       ContactGroup oldGroup = localData.getContactGroup(dsi.itemId);
       if (!group.equals(oldGroup)) {
         localData.modifyContactGroup(dsi.itemId, group);
         stats.updated++;
       }
     }
   } else if (!group.isEmpty()) {
     localData.createContactGroup(remoteId, group);
     stats.added++;
   }
 }
Example #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);
     }
   }
 }