From d678616d36fce087fe89cdbc27f0169e7a612790 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 18 Jan 2013 14:36:06 +0100 Subject: [PATCH] Remove possibility to create new replies from core interface. --- src/main/java/net/pterodactylus/sone/core/Core.java | 16 +++------------- .../net/pterodactylus/sone/fcp/AbstractSoneCommand.java | 2 +- .../java/net/pterodactylus/sone/web/DeleteReplyPage.java | 2 +- .../java/net/pterodactylus/sone/web/MarkAsKnownPage.java | 2 +- src/main/java/net/pterodactylus/sone/web/SearchPage.java | 2 +- .../pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java | 2 +- .../pterodactylus/sone/web/ajax/GetLikesAjaxPage.java | 2 +- .../pterodactylus/sone/web/ajax/GetReplyAjaxPage.java | 2 +- .../pterodactylus/sone/web/ajax/GetTimesAjaxPage.java | 2 +- .../pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java | 2 +- 10 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 2a1ef8e..5ce01fe 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -558,25 +558,15 @@ public class Core extends AbstractService implements SoneProvider, PostProvider } /** - * Returns the reply with the given ID. If there is no reply with the given - * ID yet, a new one is created, unless {@code create} is false in which - * case {@code null} is returned. + * Returns the reply with the given ID. * * @param replyId * The ID of the reply to get - * @param create - * {@code true} to always return a {@link Reply}, {@code false} - * to return {@code null} if no reply can be found * @return The reply, or {@code null} if there is no such reply */ - public PostReply getPostReply(String replyId, boolean create) { + public PostReply getPostReply(String replyId) { synchronized (replies) { - PostReply reply = replies.get(replyId); - if (create && (reply == null)) { - reply = new PostReplyImpl(replyId); - replies.put(replyId, reply); - } - return reply; + return replies.get(replyId); } } diff --git a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java index b9ff03c..80802ad 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java @@ -211,7 +211,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand { protected PostReply getReply(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException { try { String replyId = simpleFieldSet.getString(parameterName); - PostReply reply = core.getPostReply(replyId, false); + PostReply reply = core.getPostReply(replyId); if (reply == null) { throw new FcpException("Could not load reply from “" + replyId + "”."); } diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java index 8c07716..25a9e0b 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java @@ -53,7 +53,7 @@ public class DeleteReplyPage extends SoneTemplatePage { protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36); - PostReply reply = webInterface.getCore().getPostReply(replyId, false); + PostReply reply = webInterface.getCore().getPostReply(replyId); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); if (request.getMethod() == Method.POST) { if (!reply.getSone().isLocal()) { diff --git a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java index fe50509..0bf5285 100644 --- a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java +++ b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java @@ -71,7 +71,7 @@ public class MarkAsKnownPage extends SoneTemplatePage { } webInterface.getCore().markPostKnown(post); } else if (type.equals("reply")) { - PostReply reply = webInterface.getCore().getPostReply(id, false); + PostReply reply = webInterface.getCore().getPostReply(id); if (reply == null) { continue; } diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 7352bab..337918d 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -336,7 +336,7 @@ public class SearchPage extends SoneTemplatePage { */ private String getReplyPostId(String phrase) { String replyId = phrase.startsWith("reply://") ? phrase.substring(8) : phrase; - return (webInterface.getCore().getPostReply(replyId, false) != null) ? webInterface.getCore().getPostReply(replyId, false).getPost().getId() : null; + return (webInterface.getCore().getPostReply(replyId) != null) ? webInterface.getCore().getPostReply(replyId).getPost().getId() : null; } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java index 67bf901..b1a3317 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java @@ -49,7 +49,7 @@ public class DeleteReplyAjaxPage extends JsonPage { @Override protected JsonObject createJsonObject(FreenetRequest request) { String replyId = request.getHttpRequest().getParam("reply"); - PostReply reply = webInterface.getCore().getPostReply(replyId, false); + PostReply reply = webInterface.getCore().getPostReply(replyId); if (reply == null) { return createErrorJsonObject("invalid-reply-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 c1c532b..04191fa 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -67,7 +67,7 @@ public class GetLikesAjaxPage extends JsonPage { Set sones = webInterface.getCore().getLikes(post); return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } else if ("reply".equals(type)) { - PostReply reply = webInterface.getCore().getPostReply(id, false); + PostReply reply = webInterface.getCore().getPostReply(id); Set sones = webInterface.getCore().getLikes(reply); return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java index 99a7220..6139776 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java @@ -62,7 +62,7 @@ public class GetReplyAjaxPage extends JsonPage { @Override protected JsonObject createJsonObject(FreenetRequest request) { String replyId = request.getHttpRequest().getParam("reply"); - PostReply reply = webInterface.getCore().getPostReply(replyId, false); + PostReply reply = webInterface.getCore().getPostReply(replyId); if ((reply == null) || (reply.getSone() == null)) { return createErrorJsonObject("invalid-reply-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 03bf8c5..13cf424 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java @@ -77,7 +77,7 @@ public class GetTimesAjaxPage extends JsonPage { if (allIds.length() > 0) { String[] ids = allIds.split(","); for (String id : ids) { - PostReply reply = webInterface.getCore().getPostReply(id, false); + PostReply reply = webInterface.getCore().getPostReply(id); if (reply == null) { 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 18450b1..e9c582a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java @@ -63,7 +63,7 @@ public class MarkAsKnownAjaxPage extends JsonPage { } core.markPostKnown(post); } else if (type.equals("reply")) { - PostReply reply = core.getPostReply(id, false); + PostReply reply = core.getPostReply(id); if (reply == null) { continue; } -- 2.7.4