Move post-related database functionality into its own class.
[Sone.git] / src / main / java / net / pterodactylus / sone / database / memory / ConfigurationLoader.java
index 1691ddb..e65cf48 100644 (file)
@@ -10,6 +10,8 @@ import java.util.logging.Logger;
 import net.pterodactylus.util.config.Configuration;
 import net.pterodactylus.util.config.ConfigurationException;
 
+import com.google.common.base.Optional;
+
 /**
  * Helper class for interacting with a {@link Configuration}.
  *
@@ -37,6 +39,10 @@ public class ConfigurationLoader {
                return loadIds("KnownPosts");
        }
 
+       public synchronized void saveKnownPosts(Set<String> knownPosts) {
+               saveIds("KnownPosts", knownPosts);
+       }
+
        public synchronized Set<String> loadKnownPostReplies() {
                return loadIds("KnownReplies");
        }
@@ -81,4 +87,13 @@ public class ConfigurationLoader {
                }
        }
 
+       public long getLocalSoneTime(String localSoneId) {
+               Long time = configuration.getLongValue("Sone/" + localSoneId + "/Time").getValue(null);
+               return Optional.fromNullable(time).or(-1L);
+       }
+
+       public String getLastInsertFingerprint(String localSoneId) {
+               return configuration.getStringValue("Sone/" + localSoneId + "/LastInsertFingerprint").getValue("");
+       }
+
 }