mirror of
https://github.com/etesync/android
synced 2025-05-14 12:58:49 +00:00
Journalmanager: Change getUuid to getUid (the rest says uid too).
This commit is contained in:
parent
7cefb64db2
commit
14e6f757c5
@ -69,7 +69,7 @@ abstract class BaseManager {
|
|||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private String uid;
|
private String uid;
|
||||||
|
|
||||||
public String getUuid() {
|
public String getUid() {
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ public class JournalEntryManager extends BaseManager {
|
|||||||
|
|
||||||
void verify(Crypto.CryptoManager crypto, Entry previous) throws Exceptions.IntegrityException {
|
void verify(Crypto.CryptoManager crypto, Entry previous) throws Exceptions.IntegrityException {
|
||||||
String correctHash = calculateHmac(crypto, previous);
|
String correctHash = calculateHmac(crypto, previous);
|
||||||
if (!getUuid().equals(correctHash)) {
|
if (!getUid().equals(correctHash)) {
|
||||||
throw new Exceptions.IntegrityException("Bad HMAC. " + getUuid() + " != " + correctHash);
|
throw new Exceptions.IntegrityException("Bad HMAC. " + getUid() + " != " + correctHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class JournalEntryManager extends BaseManager {
|
|||||||
private String calculateHmac(Crypto.CryptoManager crypto, Entry previous) {
|
private String calculateHmac(Crypto.CryptoManager crypto, Entry previous) {
|
||||||
String uuid = null;
|
String uuid = null;
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
uuid = previous.getUuid();
|
uuid = previous.getUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Crypto.toHex(calculateHmac(crypto, uuid));
|
return Crypto.toHex(calculateHmac(crypto, uuid));
|
||||||
|
@ -12,7 +12,6 @@ import com.etesync.syncadapter.App;
|
|||||||
import com.etesync.syncadapter.GsonHelper;
|
import com.etesync.syncadapter.GsonHelper;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
@ -49,7 +48,7 @@ public class JournalManager extends BaseManager {
|
|||||||
List<Journal> ret = GsonHelper.gson.fromJson(body.charStream(), journalType);
|
List<Journal> ret = GsonHelper.gson.fromJson(body.charStream(), journalType);
|
||||||
|
|
||||||
for (Journal journal : ret) {
|
for (Journal journal : ret) {
|
||||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), keyBase64, journal.getUuid());
|
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), keyBase64, journal.getUid());
|
||||||
journal.processFromJson();
|
journal.processFromJson();
|
||||||
journal.verify(crypto);
|
journal.verify(crypto);
|
||||||
}
|
}
|
||||||
@ -58,7 +57,7 @@ public class JournalManager extends BaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteJournal(Journal journal) throws Exceptions.HttpException {
|
public void deleteJournal(Journal journal) throws Exceptions.HttpException {
|
||||||
HttpUrl remote = this.remote.resolve(journal.getUuid() + "/");
|
HttpUrl remote = this.remote.resolve(journal.getUid() + "/");
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.delete()
|
.delete()
|
||||||
.url(remote)
|
.url(remote)
|
||||||
@ -79,7 +78,7 @@ public class JournalManager extends BaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateJournal(Journal journal) throws Exceptions.HttpException {
|
public void updateJournal(Journal journal) throws Exceptions.HttpException {
|
||||||
HttpUrl remote = this.remote.resolve(journal.getUuid() + "/");
|
HttpUrl remote = this.remote.resolve(journal.getUid() + "/");
|
||||||
RequestBody body = RequestBody.create(JSON, journal.toJson());
|
RequestBody body = RequestBody.create(JSON, journal.toJson());
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
@ -125,7 +124,7 @@ public class JournalManager extends BaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] calculateHmac(Crypto.CryptoManager crypto) {
|
byte[] calculateHmac(Crypto.CryptoManager crypto) {
|
||||||
return super.calculateHmac(crypto, getUuid());
|
return super.calculateHmac(crypto, getUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String genUid() {
|
public static String genUid() {
|
||||||
|
@ -69,7 +69,7 @@ public class CollectionInfo implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateFromJournal(JournalManager.Journal journal) {
|
public void updateFromJournal(JournalManager.Journal journal) {
|
||||||
uid = journal.getUuid();
|
uid = journal.getUid();
|
||||||
version = journal.getVersion();
|
version = journal.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public abstract class SyncAdapterService extends Service {
|
|||||||
List<CollectionInfo> collections = new LinkedList<>();
|
List<CollectionInfo> collections = new LinkedList<>();
|
||||||
|
|
||||||
for (JournalManager.Journal journal : journalsManager.getJournals(settings.password())) {
|
for (JournalManager.Journal journal : journalsManager.getJournals(settings.password())) {
|
||||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), settings.password(), journal.getUuid());
|
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), settings.password(), journal.getUid());
|
||||||
CollectionInfo info = CollectionInfo.fromJson(journal.getContent(crypto));
|
CollectionInfo info = CollectionInfo.fromJson(journal.getContent(crypto));
|
||||||
info.updateFromJournal(journal);
|
info.updateFromJournal(journal);
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ abstract public class SyncManager {
|
|||||||
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
||||||
|
|
||||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
||||||
persistSyncEntry(entry.getUuid(), cEntry);
|
persistSyncEntry(entry.getUid(), cEntry);
|
||||||
if (cEntry.isAction(SyncEntry.Actions.DELETE)) {
|
if (cEntry.isAction(SyncEntry.Actions.DELETE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -276,9 +276,9 @@ abstract public class SyncManager {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (JournalEntryManager.Entry entry : remoteEntries) {
|
for (JournalEntryManager.Entry entry : remoteEntries) {
|
||||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
||||||
persistSyncEntry(entry.getUuid(), cEntry);
|
persistSyncEntry(entry.getUid(), cEntry);
|
||||||
i++;
|
i++;
|
||||||
if (remoteCTag.equals(entry.getUuid())) {
|
if (remoteCTag.equals(entry.getUid())) {
|
||||||
remoteEntries.subList(0, i).clear();
|
remoteEntries.subList(0, i).clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -307,9 +307,9 @@ abstract public class SyncManager {
|
|||||||
App.log.info("Processing resource for journal entry");
|
App.log.info("Processing resource for journal entry");
|
||||||
processSyncEntry(cEntry);
|
processSyncEntry(cEntry);
|
||||||
|
|
||||||
persistSyncEntry(entry.getUuid(), cEntry);
|
persistSyncEntry(entry.getUid(), cEntry);
|
||||||
|
|
||||||
remoteCTag = entry.getUuid();
|
remoteCTag = entry.getUid();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
saveSyncTag();
|
saveSyncTag();
|
||||||
@ -325,7 +325,7 @@ abstract public class SyncManager {
|
|||||||
if (!localEntries.isEmpty()) {
|
if (!localEntries.isEmpty()) {
|
||||||
for (List<JournalEntryManager.Entry> entries : ListUtils.partition(localEntries, MAX_PUSH)) {
|
for (List<JournalEntryManager.Entry> entries : ListUtils.partition(localEntries, MAX_PUSH)) {
|
||||||
journal.putEntries(entries, remoteCTag);
|
journal.putEntries(entries, remoteCTag);
|
||||||
remoteCTag = entries.get(entries.size() - 1).getUuid();
|
remoteCTag = entries.get(entries.size() - 1).getUid();
|
||||||
pushed += entries.size();
|
pushed += entries.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user