From: David ‘Bombe’ Roden Date: Fri, 14 Oct 2011 13:19:13 +0000 (+0200) Subject: Remove more convenience methods. X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=827f78acf643d43be2cafdd05400b21908955e3f Remove more convenience methods. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index cdc3d01..922f0d1 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -457,17 +457,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis } /** - * Returns the post with the given ID. - * - * @param postId - * The ID of the post to get - * @return The post with the given ID, or a new post with the given ID - */ - public Post getPost(String postId) { - return getPost(postId, true); - } - - /** * Returns the post with the given ID, optionally creating a new post. * * @param postId @@ -1315,7 +1304,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis logger.log(Level.WARNING, "Invalid post found, aborting load!"); return; } - Post post = getPost(postId).setSone(sone).setTime(postTime).setText(postText); + Post post = getPost(postId, true).setSone(sone).setTime(postTime).setText(postText); if ((postRecipientId != null) && (postRecipientId.length() == 43)) { post.setRecipient(getSone(postRecipientId)); } @@ -1337,7 +1326,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis logger.log(Level.WARNING, "Invalid reply found, aborting load!"); return; } - replies.add(getReply(replyId).setSone(sone).setPost(getPost(postId)).setTime(replyTime).setText(replyText)); + replies.add(getReply(replyId).setSone(sone).setPost(getPost(postId, true)).setTime(replyTime).setText(replyText)); } /* load post likes. */ diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index d9b318c..59eaa78 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -372,7 +372,7 @@ public class SoneDownloader extends AbstractService { return null; } try { - Post post = core.getPost(postId).setSone(sone).setTime(Long.parseLong(postTime)).setText(postText); + Post post = core.getPost(postId, true).setSone(sone).setTime(Long.parseLong(postTime)).setText(postText); if ((postRecipientId != null) && (postRecipientId.length() == 43)) { post.setRecipient(core.getSone(postRecipientId)); } @@ -403,7 +403,7 @@ public class SoneDownloader extends AbstractService { return null; } try { - replies.add(core.getReply(replyId).setSone(sone).setPost(core.getPost(replyPostId)).setTime(Long.parseLong(replyTime)).setText(replyText)); + replies.add(core.getReply(replyId).setSone(sone).setPost(core.getPost(replyPostId, true)).setTime(Long.parseLong(replyTime)).setText(replyText)); } catch (NumberFormatException nfe1) { /* TODO - mark Sone as bad. */ logger.log(Level.WARNING, String.format("Downloaded reply for Sone %s with invalid time: %s", sone, replyTime)); diff --git a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index 82e4c51..be83549 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java @@ -58,7 +58,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) { - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); if (text.length() > 0) { String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43); Sone sender = webInterface.getCore().getLocalSone(senderId, false); diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 314689e..002cfbd 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -55,14 +55,14 @@ public class DeletePostPage extends SoneTemplatePage { if (request.getMethod() == Method.GET) { String postId = request.getHttpRequest().getParam("post"); String returnPage = request.getHttpRequest().getParam("returnPage"); - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); templateContext.set("post", post); templateContext.set("returnPage", returnPage); return; } else if (request.getMethod() == Method.POST) { String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); if (!post.getSone().isLocal()) { throw new RedirectException("noPermission.html"); } diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 98b2603..336157e 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -72,7 +72,7 @@ public class ViewPostPage extends SoneTemplatePage { super.processTemplate(request, templateContext); String postId = request.getHttpRequest().getParam("post"); boolean raw = request.getHttpRequest().getParam("raw").equals("true"); - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); templateContext.set("post", post); templateContext.set("raw", raw); } 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 20857f3..8626d38 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 == null) { sender = getCurrentSone(request.getToadletContext()); } - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); if ((post == null) || (post.getSone() == null)) { 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 83fa15b..7c4bda4 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -63,7 +63,7 @@ public class GetLikesAjaxPage extends JsonPage { return createErrorJsonObject("invalid-" + type + "-id"); } if ("post".equals(type)) { - Post post = webInterface.getCore().getPost(id); + Post post = webInterface.getCore().getPost(id, false); Set sones = webInterface.getCore().getLikes(post); return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } else if ("reply".equals(type)) {