// This should get partly shuffled back into SyncConfiguration, I think.
 public void load(ConfigurationBranch config)
     throws NonObjectJSONException, IOException, ParseException {
   if (config == null) {
     throw new IllegalArgumentException("config cannot be null.");
   }
   String remoteJSON = config.getString("remote", null);
   String localJSON = config.getString("local", null);
   RepositorySessionBundle rB = new RepositorySessionBundle(remoteJSON);
   RepositorySessionBundle lB = new RepositorySessionBundle(localJSON);
   if (remoteJSON == null) {
     rB.setTimestamp(0);
   }
   if (localJSON == null) {
     lB.setTimestamp(0);
   }
   syncID = config.getString("syncID", null);
   remoteBundle = rB;
   localBundle = lB;
   Logger.debug(
       LOG_TAG,
       "Loaded SynchronizerConfiguration. syncID: "
           + syncID
           + ", remoteBundle: "
           + remoteBundle
           + ", localBundle: "
           + localBundle);
 }
  public void persist(ConfigurationBranch config) {
    if (config == null) {
      throw new IllegalArgumentException("config cannot be null.");
    }
    String jsonRemote = remoteBundle.toJSONString();
    String jsonLocal = localBundle.toJSONString();
    Editor editor = config.edit();
    editor.putString("remote", jsonRemote);
    editor.putString("local", jsonLocal);
    editor.putString("syncID", syncID);

    // Synchronous.
    editor.commit();
    Logger.debug(
        LOG_TAG,
        "Persisted SynchronizerConfiguration. syncID: "
            + syncID
            + ", remoteBundle: "
            + remoteBundle
            + ", localBundle: "
            + localBundle);
  }
  @Override
  public void onFinishSucceeded(RepositorySession session, RepositorySessionBundle bundle) {
    info("onFinishSucceeded. Flows? " + flowAToBCompleted + ", " + flowBToACompleted);

    if (session == sessionA) {
      if (flowAToBCompleted) {
        info(
            "onFinishSucceeded: bumping session A's timestamp to "
                + pendingATimestamp
                + " or "
                + storeEndATimestamp);
        bundle.bumpTimestamp(Math.max(pendingATimestamp, storeEndATimestamp));
        this.synchronizer.bundleA = bundle;
      }
      if (this.sessionB != null) {
        info("Finishing session B.");
        // On to the next.
        this.sessionB.finish(this);
      }
    } else if (session == sessionB) {
      if (flowBToACompleted) {
        info(
            "onFinishSucceeded: bumping session B's timestamp to "
                + pendingBTimestamp
                + " or "
                + storeEndBTimestamp);
        bundle.bumpTimestamp(Math.max(pendingBTimestamp, storeEndBTimestamp));
        this.synchronizer.bundleB = bundle;
        info("Notifying delegate.onSynchronized.");
        this.delegate.onSynchronized(this);
      }
    } else {
      // TODO: hurrrrrr...
    }

    if (this.sessionB == null) {
      this.sessionA = null; // We're done.
    }
  }