Esempio n. 1
0
 public static Node allocateNewNode(Storage storage) {
   Node node = new Node(storage);
   node.clear();
   node.setStoragePointer(storage.length());
   storage.seek(storage.length());
   storage.write(node.toBytes());
   return node;
 }
Esempio n. 2
0
  /** Serializes the specified model -- useful for testing. */
  @Override
  public synchronized void write(final Model toWrite) {
    final Settings set = toWrite.getSettings();
    final String refresh = set.getRefreshToken();
    final String access = set.getAccessToken();
    final boolean useOauth = set.isUseGoogleOAuth2();
    final boolean gtalk = toWrite.getConnectivity().isGtalkAuthorized();
    if (!LanternUtils.persistCredentials()) {

      set.setRefreshToken("");
      set.setAccessToken("");
      set.setUseGoogleOAuth2(false);
      toWrite.getConnectivity().setGtalkAuthorized(false);
    }
    super.write(toWrite);
    if (!LanternUtils.persistCredentials()) {
      set.setRefreshToken(refresh);
      set.setAccessToken(access);
      set.setUseGoogleOAuth2(useOauth);
      toWrite.getConnectivity().setGtalkAuthorized(gtalk);
    }
  }
Esempio n. 3
0
  public static void flushToStorage(Node item, Storage storage) {
    if (item == null) return;
    storage.seek(item.getStoragePointer());

    storage.write(item.toBytes());
  }