If no current Sone exists, return an error.
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / CreatePostCommand.java
index 81dff2c..8ffba74 100644 (file)
@@ -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;
@@ -47,21 +46,18 @@ public class CreatePostCommand extends AbstractSoneCommand {
                super(core, true);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
-               Sone sone = getSone(parameters, "Sone", true);
+               Sone sone = getMandatoryLocalSone(parameters, "Sone");
                String text = getString(parameters, "Text");
                Sone recipient = null;
                if (parameters.get("Recipient") != null) {
-                       recipient = getSone(parameters, "Recipient", false);
+                       recipient = getMandatorySone(parameters, "Recipient");
                }
                if (sone.equals(recipient)) {
                        return new ErrorResponse("Sone and Recipient must not be the same.");
                }
-               Post post = sone.newPostBuilder().randomId().currentTime().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());
        }