Remove more convenience methods.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 14 Oct 2011 13:19:13 +0000 (15:19 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 May 2012 07:51:31 +0000 (09:51 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/SoneDownloader.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/ViewPostPage.java
src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java

index cdc3d01..922f0d1 100644 (file)
@@ -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. */
index d9b318c..59eaa78 100644 (file)
@@ -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));
index 82e4c51..be83549 100644 (file)
@@ -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);
index 314689e..002cfbd 100644 (file)
@@ -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");
                        }
index 98b2603..336157e 100644 (file)
@@ -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);
        }
index 20857f3..8626d38 100644 (file)
@@ -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");
                }
index 83fa15b..7c4bda4 100644 (file)
@@ -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<Sone> sones = webInterface.getCore().getLikes(post);
                        return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones));
                } else if ("reply".equals(type)) {