@Override
  protected Integer[] doInBackground(Void... params) {

    try {
      // First getting the server side revision
      // This is pretty simple and fast web call
      // This let's us know fast if remote service is up
      Integer serverSideLatestRevision =
          SyncServices.getServerRevNumberCall(mActivity, mSyncConfig);
      Integer serverSideLatestRevisionDate =
          SyncServices.getServerRevNumberDateCall(mActivity, mSyncConfig);

      if (serverSideLatestRevision == null || serverSideLatestRevisionDate == null) {
        throw new SyncException(
            "Server latest revision or lastest revision date cannot be null", null);
      }

      return new Integer[] {serverSideLatestRevision, serverSideLatestRevisionDate};

    } catch (Exception e) {
      mUpdateFromRevisionException = new SyncException(e.getMessage(), e.getCause());
      e.printStackTrace();
      cancel(true);
    }

    return null;
  }
  private void cleanAndCheckout() throws Exception {

    // Clean configured storage
    FileCommons.eraseFolder(mSyncConfig.getStoragePath(mActivity));

    // Force direct Checkout
    SyncServices.checkout(mActivity, mSyncHandler, mSyncConfig);
  }
  private void updateFromRevision(Integer serverLastRevisionNumber, Integer serverLastRevisionDate)
      throws Exception {

    /** Comparing server revision with client */
    if (mCurrentClientVersion < serverLastRevisionNumber) {

      // Client is not up to date.
      // Update from currentClientVersion
      SyncServices.updateFromRevision(mActivity, mSyncHandler, mCurrentClientVersion, mSyncConfig);

    } else if (mCurrentClientVersion.equals(serverLastRevisionNumber)) {

      // Notify user sync is finished
      mSyncHandler.onSynchronizationFinished(serverLastRevisionNumber, serverLastRevisionDate);

    } else {

      // client > server revision.
      // It's a problem.. make things clean from now...
      cleanAndCheckout();
    }
  }