From: David ‘Bombe’ Roden Date: Wed, 16 Oct 2013 18:27:08 +0000 (+0200) Subject: Remove PostProvider methods from Core. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e14e8aff491d7a04e4e04ed9c38bcae630195655;p=Sone.git Remove PostProvider methods from Core. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 21448b6..3e4bf1d 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -436,19 +436,6 @@ public class Core extends AbstractService implements SoneProvider, PostReplyProv return trustedIdentities.containsEntry(origin.getIdentity(), target.getIdentity()); } - public Optional getPost(String postId) { - return database.getPost(postId); - } - - public Collection getPosts(String soneId) { - return database.getPosts(soneId); - } - - public Collection getDirectedPosts(final String recipientId) { - checkNotNull(recipientId, "recipient must not be null"); - return database.getDirectedPosts(recipientId); - } - @Override public Optional getPostReply(String replyId) { return database.getPostReply(replyId); @@ -528,7 +515,7 @@ public class Core extends AbstractService implements SoneProvider, PostReplyProv Set posts = new HashSet(); synchronized (bookmarkedPosts) { for (String bookmarkedPostId : bookmarkedPosts) { - Optional post = getPost(bookmarkedPostId); + Optional post = database.getPost(bookmarkedPostId); if (post.isPresent()) { posts.add(post.get()); } diff --git a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java index 9be30fc..19c1979 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java @@ -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 = core.getPost(postId); + Optional post = core.getDatabase().getPost(postId); if (!post.isPresent()) { throw new FcpException("Could not load post from “" + postId + "”."); } diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java index a99c031..fb44e3a 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java @@ -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 sortedPosts = new ArrayList(allPosts); diff --git a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index 1303508..4811997 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java @@ -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 = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { throw new RedirectException("noPermission.html"); } diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 23c2cc1..5cb4b44 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -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 = webInterface.getCore().getPost(postId); + Optional 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 = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent() || !post.get().getSone().isLocal()) { throw new RedirectException("noPermission.html"); } diff --git a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java index 0b3d4b3..e89b6dc 100644 --- a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java +++ b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java @@ -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 = webInterface.getCore().getPost(id); + Optional post = webInterface.getCore().getDatabase().getPost(id); if (!post.isPresent()) { continue; } diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index d83b822..f809579 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -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; } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 3f44419..409c63a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -53,7 +53,7 @@ public class ViewPostPage extends SoneTemplatePage { @Override protected String getPageTitle(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Optional post = webInterface.getCore().getPost(postId); + Optional 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 = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); templateContext.set("post", post.orNull()); templateContext.set("raw", raw); } diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 3c0ba8f..4874ade 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -83,7 +83,7 @@ public class ViewSonePage extends SoneTemplatePage { return; } List 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 postPagination = new Pagination(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0)); templateContext.set("postPagination", postPagination); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java index dc95166..313d271 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java @@ -58,7 +58,7 @@ public class CreateReplyAjaxPage extends JsonPage { if (!sender.isPresent()) { sender = of(getCurrentSone(request.getToadletContext())); } - Optional post = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { return createErrorJsonObject("invalid-post-id"); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java index 66a67eb..943d6a8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java @@ -47,7 +47,7 @@ public class DeletePostAjaxPage extends JsonPage { @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Optional post = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { return createErrorJsonObject("invalid-post-id"); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java index dea635c..3bb40c9 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -64,7 +64,7 @@ public class GetLikesAjaxPage extends JsonPage { return createErrorJsonObject("invalid-" + type + "-id"); } if ("post".equals(type)) { - Optional post = webInterface.getCore().getPost(id); + Optional post = webInterface.getCore().getDatabase().getPost(id); if (!post.isPresent()) { return createErrorJsonObject("invalid-post-id"); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java index 8587d12..1221f1a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java @@ -61,7 +61,7 @@ public class GetPostAjaxPage extends JsonPage { @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Optional post = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { return createErrorJsonObject("invalid-post-id"); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java index c15abcc..b8fc52e 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java @@ -59,7 +59,7 @@ public class GetTimesAjaxPage extends JsonPage { if (allIds.length() > 0) { String[] ids = allIds.split(","); for (String id : ids) { - Optional post = webInterface.getCore().getPost(id); + Optional post = webInterface.getCore().getDatabase().getPost(id); if (!post.isPresent()) { continue; } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java index 602f253..cb5940c 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java @@ -55,7 +55,7 @@ public class MarkAsKnownAjaxPage extends JsonPage { Core core = webInterface.getCore(); for (String id : ids) { if (type.equals("post")) { - Optional post = core.getPost(id); + Optional post = core.getDatabase().getPost(id); if (!post.isPresent()) { continue; }