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; }
/** 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); } }
public static void flushToStorage(Node item, Storage storage) { if (item == null) return; storage.seek(item.getStoragePointer()); storage.write(item.toBytes()); }