protected int addItem(SyncItem item) throws SyncException {
    if (Log.isLoggable(Log.DEBUG)) {
      Log.debug(TAG_LOG, "addItem");
    }
    JSONSyncItem jsonSyncItem = (JSONSyncItem) item;
    try {
      String fullName = getFileFullName(jsonSyncItem.getContentName());

      FileAdapter tgtFile = new FileAdapter(fullName);
      if (tgtFile.exists()) {
        // This is the case where the client and the server have a file
        // with the very same name but different content. In this case
        // we rename the destination file
        fullName = createUniqueFileName(fullName);
        if (Log.isLoggable(Log.INFO)) {
          Log.info(TAG_LOG, "Changing target file name to avoid clashing " + fullName);
        }
      }
      tgtFile.close();

      item.setKey(fullName);
      if (Log.isLoggable(Log.DEBUG)) {
        Log.debug(TAG_LOG, "key set to:" + fullName);
      }
      // This is a new file, rename the temp file
      String sourceFileName = createTempFileName(jsonSyncItem.getContentName());
      renameTempFile(sourceFileName, fullName);

      super.addItem(item);
      return SyncSource.SUCCESS_STATUS;
    } catch (IOException ioe) {
      Log.error(TAG_LOG, "Cannot rename temporary file", ioe);
      throw new SyncException(SyncException.CLIENT_ERROR, "Cannot rename temporary file");
    }
  }