import net.pterodactylus.sone.database.ImageBuilder.ImageCreated;
import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostBuilder.PostCreated;
-import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.PostReplyBuilder;
import net.pterodactylus.sone.database.PostReplyBuilder.PostReplyCreated;
import net.pterodactylus.sone.database.PostReplyProvider;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class Core extends AbstractService implements SoneProvider, PostProvider, PostReplyProvider {
+public class Core extends AbstractService implements SoneProvider, PostReplyProvider {
/** The logger. */
private static final Logger logger = Logging.getLogger(Core.class);
return trustedIdentities.containsEntry(origin.getIdentity(), target.getIdentity());
}
- @Override
public Optional<Post> getPost(String postId) {
return database.getPost(postId);
}
- @Override
public Collection<Post> getPosts(String soneId) {
return database.getPosts(soneId);
}
- @Override
public Collection<Post> getDirectedPosts(final String recipientId) {
checkNotNull(recipientId, "recipient must not be null");
return database.getDirectedPosts(recipientId);
package net.pterodactylus.sone.database;
+import java.util.Collection;
+
+import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.Sone;
+
+import com.google.common.base.Optional;
+
/**
- * Combines a {@link PostProvider}, a {@link PostBuilderFactory}, and a
- * {@link PostStore} into a complete post database.
+ * Database for handling {@link Post}s.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public interface PostDatabase extends PostProvider, PostStore {
+public interface PostDatabase {
+
+ /**
+ * Returns the post with the given ID.
+ *
+ * @param postId
+ * The ID of the post to return
+ * @return The post with the given ID, or {@code null}
+ */
+ Optional<Post> getPost(String postId);
+
+ /**
+ * Returns all posts from the given Sone.
+ *
+ * @param soneId
+ * The ID of the Sone
+ * @return All posts from the given Sone
+ */
+ Collection<Post> getPosts(String soneId);
+
+ /**
+ * Returns all posts that have the given Sone as recipient.
+ *
+ * @see Post#getRecipient()
+ * @param recipientId
+ * The ID of the recipient of the posts
+ * @return All posts that have the given Sone as recipient
+ */
+ Collection<Post> getDirectedPosts(String recipientId);
+
+ /**
+ * Adds the given post to the store.
+ *
+ * @param post
+ * The post to store
+ */
+ void storePost(Post post);
+
+ /**
+ * Removes the given post.
+ *
+ * @param post
+ * The post to remove
+ */
+ void removePost(Post post);
+
+ /**
+ * Stores the given posts as all posts of a single {@link Sone}. This method
+ * will removed all other posts from the Sone!
+ *
+ * @param sone
+ * The Sone to store the posts for
+ * @param posts
+ * The posts to store
+ * @throws IllegalArgumentException
+ * if posts do not all belong to the same Sone
+ */
+ void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException;
- /* nothing here. */
+ /**
+ * Removes all posts of the given {@link Sone}
+ *
+ * @param sone
+ * The Sone to remove all posts for
+ */
+ void removePosts(Sone sone);
}
+++ /dev/null
-/*
- * Sone - PostProvider.java - Copyright © 2011–2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import java.util.Collection;
-
-import net.pterodactylus.sone.data.Post;
-
-import com.google.common.base.Optional;
-
-/**
- * Interface for objects that can provide {@link Post}s by their ID.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface PostProvider {
-
- /**
- * Returns the post with the given ID.
- *
- * @param postId
- * The ID of the post to return
- * @return The post with the given ID, or {@code null}
- */
- public Optional<Post> getPost(String postId);
-
- /**
- * Returns all posts from the given Sone.
- *
- * @param soneId
- * The ID of the Sone
- * @return All posts from the given Sone
- */
- public Collection<Post> getPosts(String soneId);
-
- /**
- * Returns all posts that have the given Sone as recipient.
- *
- * @see Post#getRecipient()
- * @param recipientId
- * The ID of the recipient of the posts
- * @return All posts that have the given Sone as recipient
- */
- public Collection<Post> getDirectedPosts(String recipientId);
-
-}
+++ /dev/null
-/*
- * Sone - PostStore.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import java.util.Collection;
-
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
-
-/**
- * Interface for a store for posts.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface PostStore {
-
- /**
- * Adds the given post to the store.
- *
- * @param post
- * The post to store
- */
- public void storePost(Post post);
-
- /**
- * Removes the given post.
- *
- * @param post
- * The post to remove
- */
- public void removePost(Post post);
-
- /**
- * Stores the given posts as all posts of a single {@link Sone}. This method
- * will removed all other posts from the Sone!
- *
- * @param sone
- * The Sone to store the posts for
- * @param posts
- * The posts to store
- * @throws IllegalArgumentException
- * if posts do not all belong to the same Sone
- */
- public void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException;
-
- /**
- * Removes all posts of the given {@link Sone}
- *
- * @param sone
- * The Sone to remove all posts for
- */
- public void removePosts(Sone sone);
-
-}
import net.pterodactylus.sone.core.FreenetInterface;
import net.pterodactylus.sone.core.WebOfTrustUpdater;
import net.pterodactylus.sone.database.Database;
-import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.SoneProvider;
import net.pterodactylus.sone.database.memory.MemoryDatabase;
import net.pterodactylus.sone.fcp.FcpInterface;
bind(FcpInterface.class).in(Singleton.class);
bind(Database.class).to(MemoryDatabase.class);
bind(SoneProvider.class).to(Core.class).in(Singleton.class);
- bind(PostProvider.class).to(MemoryDatabase.class);
bindListener(Matchers.any(), new TypeListener() {
@Override