package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+import com.google.common.base.Optional;
+
/**
* Database functions for local Sones.
*
*/
public interface LocalSoneDatabase {
+ Optional<LocalSone> getLocalSone(String localSoneId);
Sone registerLocalSone(OwnIdentity ownIdentity);
String getLastInsertFingerprint(Sone sone);
void setLastInsertFingerprint(Sone sone, String lastInsertFingerprint);
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
import net.pterodactylus.sone.data.Image;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Profile;
// DATABASE METHODS
//
+ @Override
+ public Optional<LocalSone> getLocalSone(String localSoneId) {
+ lock.readLock().lock();
+ try {
+ if (!localSones.contains(localSoneId)) {
+ return Optional.absent();
+ }
+ return Optional.of((LocalSone) allSones.get(localSoneId));
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
@Override
public Sone registerLocalSone(OwnIdentity ownIdentity) {