@Override public PatchInfo getPatchInfo(Id id) { String p = headerPath(id); JsonObject obj = Zk.zkFetchJson(client, p); Id patchId = getIdOrNull(obj, fId); if ( ! Objects.equals(id, patchId) ) { /*msg*/ } Id prevId = getIdOrNull(obj, fPrevious); long ver = JSONX.getLong(obj, fVersion, -99); Version version = ver < 0 ? Version.UNSET : Version.create(ver); return new PatchInfo(patchId, Version.UNSET, prevId); }
private void save(long version, Id patch, Id prev) { newState(version, patch, prev); JsonObject x = stateToJson(version, patch, prev); byte[] bytes = JSONX.asBytes(x); if ( patch != null ) { // [META] // Record the basic header - (version, id, prev) - for validation. if ( keepHeaderInfo ) Zk.zkCreateSet(client, headerPath(patch), bytes); // Write version->id mapping. Zk.zkCreateSet(client, versionPath(version), patch.asBytes()); } Zk.zkSet(client, statePath, bytes); }