コード例 #1
0
ファイル: TagSync.java プロジェクト: TaNhoSy/zimbra-mirror
 /**
  * Remove mapping for a given localId
  *
  * @throws ServiceException
  */
 public void removeTagMapping(int tagId) throws ServiceException {
   // delete the mapping if it was needed and exists
   if (mappingRequired) {
     try {
       DataSourceMapping mapping = new DataSourceMapping(tagDs, tagId);
       mapping.delete();
       localIdFromRemote.remove(Integer.valueOf(mapping.getRemoteId()));
       remoteIdFromLocal.remove(tagId);
       if (localIdsByName.containsValue(tagId)) {
         Set<String> keysToRemove =
             new HashSet<
                 String>(); // should only be one, but naming conflicts might end up with more..
         for (Entry<String, Integer> entry : localIdsByName.entrySet()) {
           if (entry.getValue().equals(tagId)) {
             keysToRemove.add(entry.getKey());
           }
         }
         for (String key : keysToRemove) {
           localIdsByName.remove(key);
         }
       }
       OfflineLog.offline.debug("removed tag mapping for localId %d", tagId);
       // TODO: consider the case where we have > 63 tags.
       // we can move one of the overflow tags into a free slot, but we also have to apply the tag
       // to existing messages
     } catch (ServiceException se) {
       if (!MailServiceException.NO_SUCH_ITEM.equals(se.getCode())) {
         throw se;
       }
     }
   }
 }
コード例 #2
0
ファイル: TagSync.java プロジェクト: TaNhoSy/zimbra-mirror
 /**
  * Get the local ID corresponding to remote tagId
  *
  * @throws ServiceException
  */
 public int localTagId(int id) throws ServiceException {
   if (!isMappingRequired(id)) {
     return id;
   }
   try {
     if (localIdFromRemote.containsKey(id)) {
       return localIdFromRemote.get(id);
     }
     DataSourceMapping mapping = new DataSourceMapping(tagDs, id + "");
     OfflineLog.offline.debug("got localId %d from remote %d", mapping.getItemId(), id);
     localIdFromRemote.put(id, mapping.getItemId());
     return mapping.getItemId();
   } catch (ServiceException se) {
     if (MailServiceException.NO_SUCH_ITEM.equals(se.getCode())) {
       return -1;
     }
     throw se;
   }
 }
コード例 #3
0
ファイル: TagSync.java プロジェクト: TaNhoSy/zimbra-mirror
 /**
  * Get the remoteId corresponding to local tagId
  *
  * @throws ServiceException
  */
 public int remoteTagId(int id) throws ServiceException {
   if (mappingRequired) {
     if (remoteIdFromLocal.containsKey(id)) {
       return remoteIdFromLocal.get(id);
     }
     try {
       DataSourceMapping mapping = new DataSourceMapping(tagDs, id);
       int remoteId = Integer.valueOf(mapping.getRemoteId());
       OfflineLog.offline.debug("got remoteId %d from localId %d", remoteId, id);
       remoteIdFromLocal.put(id, remoteId);
       return remoteId;
     } catch (ServiceException se) {
       if (MailServiceException.NO_SUCH_ITEM.equals(se.getCode())) {
         return -1;
       }
       throw se;
     }
   } else {
     return id;
   }
 }