- lock.readLock().lock();
- try {
- return sonePosts.get(soneId);
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /** Loads the known posts. */
- private void loadKnownPosts() {
- Set<String> knownPosts = configurationLoader.loadKnownPosts();
- lock.writeLock().lock();
- try {
- this.knownPosts.clear();
- this.knownPosts.addAll(knownPosts);
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- /**
- * Saves the known posts to the configuration.
- *
- * @throws DatabaseException
- * if a configuration error occurs
- */
- private void saveKnownPosts() throws DatabaseException {
- lock.readLock().lock();
- try {
- int postCounter = 0;
- for (String knownPostId : knownPosts) {
- configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").setValue(
- knownPostId);
- }
- configuration.getStringValue("KnownPosts/" + postCounter + "/ID").setValue(null);
- } catch (ConfigurationException ce1) {
- throw new DatabaseException("Could not save database.", ce1);
- } finally {
- lock.readLock().unlock();
- }