Remove PostProvider methods from Core.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 16 Oct 2013 18:27:08 +0000 (20:27 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:28 +0000 (22:25 +0100)
15 files changed:
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java
src/main/java/net/pterodactylus/sone/web/DeletePostPage.java
src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java
src/main/java/net/pterodactylus/sone/web/SearchPage.java
src/main/java/net/pterodactylus/sone/web/ViewPostPage.java
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java

index 21448b6..3e4bf1d 100644 (file)
@@ -436,19 +436,6 @@ public class Core extends AbstractService implements SoneProvider, PostReplyProv
                return trustedIdentities.containsEntry(origin.getIdentity(), target.getIdentity());
        }
 
-       public Optional<Post> getPost(String postId) {
-               return database.getPost(postId);
-       }
-
-       public Collection<Post> getPosts(String soneId) {
-               return database.getPosts(soneId);
-       }
-
-       public Collection<Post> getDirectedPosts(final String recipientId) {
-               checkNotNull(recipientId, "recipient must not be null");
-               return database.getDirectedPosts(recipientId);
-       }
-
        @Override
        public Optional<PostReply> getPostReply(String replyId) {
                return database.getPostReply(replyId);
@@ -528,7 +515,7 @@ public class Core extends AbstractService implements SoneProvider, PostReplyProv
                Set<Post> posts = new HashSet<Post>();
                synchronized (bookmarkedPosts) {
                        for (String bookmarkedPostId : bookmarkedPosts) {
-                               Optional<Post> post = getPost(bookmarkedPostId);
+                               Optional<Post> post = database.getPost(bookmarkedPostId);
                                if (post.isPresent()) {
                                        posts.add(post.get());
                                }
index 9be30fc..19c1979 100644 (file)
@@ -186,7 +186,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
        protected Post getPost(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
                try {
                        String postId = simpleFieldSet.getString(parameterName);
-                       Optional<Post> post = core.getPost(postId);
+                       Optional<Post> post = core.getDatabase().getPost(postId);
                        if (!post.isPresent()) {
                                throw new FcpException("Could not load post from “" + postId + "”.");
                        }
index a99c031..fb44e3a 100644 (file)
@@ -67,7 +67,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand {
                        }
                        allPosts.addAll(friendSone.get().getPosts());
                }
-               allPosts.addAll(getCore().getDirectedPosts(sone.getId()));
+               allPosts.addAll(getCore().getDatabase().getDirectedPosts(sone.getId()));
                allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
 
                List<Post> sortedPosts = new ArrayList<Post>(allPosts);
index 1303508..4811997 100644 (file)
@@ -59,7 +59,7 @@ public class CreateReplyPage extends SoneTemplatePage {
                String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
-                       Optional<Post> post = webInterface.getCore().getPost(postId);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                        if (!post.isPresent()) {
                                throw new RedirectException("noPermission.html");
                        }
index 23c2cc1..5cb4b44 100644 (file)
@@ -54,7 +54,7 @@ public class DeletePostPage extends SoneTemplatePage {
                if (request.getMethod() == Method.GET) {
                        String postId = request.getHttpRequest().getParam("post");
                        String returnPage = request.getHttpRequest().getParam("returnPage");
-                       Optional<Post> post = webInterface.getCore().getPost(postId);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                        if (!post.isPresent()) {
                                throw new RedirectException("noPermission.html");
                        }
@@ -64,7 +64,7 @@ public class DeletePostPage extends SoneTemplatePage {
                } else if (request.getMethod() == Method.POST) {
                        String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
-                       Optional<Post> post = webInterface.getCore().getPost(postId);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                        if (!post.isPresent() || !post.get().getSone().isLocal()) {
                                throw new RedirectException("noPermission.html");
                        }
index 0b3d4b3..e89b6dc 100644 (file)
@@ -64,7 +64,7 @@ public class MarkAsKnownPage extends SoneTemplatePage {
                for (StringTokenizer idTokenizer = new StringTokenizer(ids); idTokenizer.hasMoreTokens();) {
                        String id = idTokenizer.nextToken();
                        if (type.equals("post")) {
-                               Optional<Post> post = webInterface.getCore().getPost(id);
+                               Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
                                if (!post.isPresent()) {
                                        continue;
                                }
index d83b822..f809579 100644 (file)
@@ -320,7 +320,7 @@ public class SearchPage extends SoneTemplatePage {
         */
        private String getPostId(String phrase) {
                String postId = phrase.startsWith("post://") ? phrase.substring(7) : phrase;
-               return (webInterface.getCore().getPost(postId).isPresent()) ? postId : null;
+               return (webInterface.getCore().getDatabase().getPost(postId).isPresent()) ? postId : null;
        }
 
        /**
index 3f44419..409c63a 100644 (file)
@@ -53,7 +53,7 @@ public class ViewPostPage extends SoneTemplatePage {
        @Override
        protected String getPageTitle(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
-               Optional<Post> post = webInterface.getCore().getPost(postId);
+               Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                String title = "";
                if (post.isPresent()) {
                        title = post.get().getText().substring(0, Math.min(20, post.get().getText().length())) + "…";
@@ -68,7 +68,7 @@ public class ViewPostPage extends SoneTemplatePage {
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getParam("post");
                boolean raw = request.getHttpRequest().getParam("raw").equals("true");
-               Optional<Post> post = webInterface.getCore().getPost(postId);
+               Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                templateContext.set("post", post.orNull());
                templateContext.set("raw", raw);
        }
index 3c0ba8f..4874ade 100644 (file)
@@ -83,7 +83,7 @@ public class ViewSonePage extends SoneTemplatePage {
                        return;
                }
                List<Post> sonePosts = sone.get().getPosts();
-               sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
+               sonePosts.addAll(webInterface.getCore().getDatabase().getDirectedPosts(sone.get().getId()));
                Collections.sort(sonePosts, Post.TIME_COMPARATOR);
                Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0));
                templateContext.set("postPagination", postPagination);
index dc95166..313d271 100644 (file)
@@ -58,7 +58,7 @@ public class CreateReplyAjaxPage extends JsonPage {
                if (!sender.isPresent()) {
                        sender = of(getCurrentSone(request.getToadletContext()));
                }
-               Optional<Post> post = webInterface.getCore().getPost(postId);
+               Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                if (!post.isPresent()) {
                        return createErrorJsonObject("invalid-post-id");
                }
index 66a67eb..943d6a8 100644 (file)
@@ -47,7 +47,7 @@ public class DeletePostAjaxPage extends JsonPage {
        @Override
        protected JsonReturnObject createJsonObject(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
-               Optional<Post> post = webInterface.getCore().getPost(postId);
+               Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                if (!post.isPresent()) {
                        return createErrorJsonObject("invalid-post-id");
                }
index dea635c..3bb40c9 100644 (file)
@@ -64,7 +64,7 @@ public class GetLikesAjaxPage extends JsonPage {
                        return createErrorJsonObject("invalid-" + type + "-id");
                }
                if ("post".equals(type)) {
-                       Optional<Post> post = webInterface.getCore().getPost(id);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
                        if (!post.isPresent()) {
                                return createErrorJsonObject("invalid-post-id");
                        }
index 8587d12..1221f1a 100644 (file)
@@ -61,7 +61,7 @@ public class GetPostAjaxPage extends JsonPage {
        @Override
        protected JsonReturnObject createJsonObject(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
-               Optional<Post> post = webInterface.getCore().getPost(postId);
+               Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                if (!post.isPresent()) {
                        return createErrorJsonObject("invalid-post-id");
                }
index c15abcc..b8fc52e 100644 (file)
@@ -59,7 +59,7 @@ public class GetTimesAjaxPage extends JsonPage {
                if (allIds.length() > 0) {
                        String[] ids = allIds.split(",");
                        for (String id : ids) {
-                               Optional<Post> post = webInterface.getCore().getPost(id);
+                               Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
                                if (!post.isPresent()) {
                                        continue;
                                }
index 602f253..cb5940c 100644 (file)
@@ -55,7 +55,7 @@ public class MarkAsKnownAjaxPage extends JsonPage {
                Core core = webInterface.getCore();
                for (String id : ids) {
                        if (type.equals("post")) {
-                               Optional<Post> post = core.getPost(id);
+                               Optional<Post> post = core.getDatabase().getPost(id);
                                if (!post.isPresent()) {
                                        continue;
                                }