From: David ‘Bombe’ Roden Date: Tue, 15 Oct 2013 20:34:36 +0000 (+0200) Subject: Return an optional from the Core already. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=041f2bcb967b6ae170053d2a0a7055f869b894dd;p=Sone.git Return an optional from the Core already. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e550652..48afb36 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1950,8 +1950,8 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, touchConfiguration(); } - public PostCreated postCreated() { - return new PostCreated() { + public Optional postCreated() { + return Optional.of(new PostCreated() { @Override public void postCreated(final Post post) { if (post.isKnown()) { @@ -1967,7 +1967,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, }, 10, TimeUnit.SECONDS); } } - }; + }); } } diff --git a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java index 01b52aa..fcad23c 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java @@ -18,7 +18,6 @@ package net.pterodactylus.sone.fcp; import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Optional.of; import static net.pterodactylus.sone.data.Identified.GET_ID; import net.pterodactylus.sone.core.Core; @@ -61,7 +60,7 @@ public class CreatePostCommand extends AbstractSoneCommand { if (sone.equals(recipient)) { return new ErrorResponse("Sone and Recipient must not be the same."); } - Post post = sone.newPostBuilder().to(fromNullable(recipient).transform(GET_ID)).withText(text).build(of(getCore().postCreated())); + Post post = sone.newPostBuilder().to(fromNullable(recipient).transform(GET_ID)).withText(text).build(getCore().postCreated()); return new Response("PostCreated", new SimpleFieldSetBuilder().put("Post", post.getId()).get()); } diff --git a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java index 73cd097..9348652 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java @@ -72,7 +72,7 @@ public class CreatePostPage extends SoneTemplatePage { } Optional recipient = webInterface.getCore().getSone(recipientId); text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); - sender.get().newPostBuilder().to(recipient.transform(Identified.GET_ID)).withText(text).build(of(webInterface.getCore().postCreated())); + sender.get().newPostBuilder().to(recipient.transform(Identified.GET_ID)).withText(text).build(webInterface.getCore().postCreated()); throw new RedirectException(returnPage); } templateContext.set("errorTextEmpty", true); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java index 536d4fb..afccd40 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java @@ -66,7 +66,7 @@ public class CreatePostAjaxPage extends JsonPage { return createErrorJsonObject("text-required"); } text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); - Post newPost = sender.get().newPostBuilder().to(recipient.transform(GET_ID)).withText(text).build(of(webInterface.getCore().postCreated())); + Post newPost = sender.get().newPostBuilder().to(recipient.transform(GET_ID)).withText(text).build(webInterface.getCore().postCreated()); return createSuccessJsonObject().put("postId", newPost.getId()).put("sone", sender.get().getId()).put("recipient", newPost.getRecipientId().orNull()); }