From: David ‘Bombe’ Roden Date: Wed, 3 Dec 2014 05:23:44 +0000 (+0100) Subject: Use local Sone for loading the Sone in the database. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3049b7e396ce20b5b6600ae2791334a6babb414e;p=Sone.git Use local Sone for loading the Sone in the database. --- diff --git a/src/main/java/net/pterodactylus/sone/database/LocalSoneDatabase.java b/src/main/java/net/pterodactylus/sone/database/LocalSoneDatabase.java index 036c607..0240080 100644 --- a/src/main/java/net/pterodactylus/sone/database/LocalSoneDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/LocalSoneDatabase.java @@ -14,7 +14,7 @@ import com.google.common.base.Optional; public interface LocalSoneDatabase { Optional getLocalSone(String localSoneId); - Sone registerLocalSone(OwnIdentity ownIdentity); + LocalSone registerLocalSone(OwnIdentity ownIdentity); String getLastInsertFingerprint(Sone sone); void setLastInsertFingerprint(Sone sone, String lastInsertFingerprint); diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 128a4bd..7ad40e0 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -173,14 +173,14 @@ public class MemoryDatabase extends AbstractService implements Database { } @Override - public Sone registerLocalSone(OwnIdentity ownIdentity) { - final Sone localSone = loadLocalSone(ownIdentity); + public LocalSone registerLocalSone(OwnIdentity ownIdentity) { + final LocalSone localSone = loadLocalSone(ownIdentity); localSones.add(ownIdentity.getId()); return localSone; } - private Sone loadLocalSone(OwnIdentity ownIdentity) { - Sone localSone = newSoneBuilder().local().from(ownIdentity).build(); + private LocalSone loadLocalSone(OwnIdentity ownIdentity) { + LocalSone localSone = (LocalSone) newSoneBuilder().local().from(ownIdentity).build(); localSone.setLatestEdition( Optional.fromNullable( Longs.tryParse(ownIdentity.getProperty(LATEST_EDITION_PROPERTY))) @@ -192,7 +192,7 @@ public class MemoryDatabase extends AbstractService implements Database { return localSone; } - public void loadSone(Sone sone) { + public void loadSone(LocalSone sone) { long soneTime = configurationLoader.getLocalSoneTime(sone.getId()); if (soneTime == -1) { return;