Merge branch 'release-0.9.7'
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / FcpInterface.java
index a331cfb..6f28518 100644 (file)
@@ -144,26 +144,26 @@ public class FcpInterface {
         *            {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
         */
        public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
+               String identifier = parameters.get("Identifier");
+               if ((identifier == null) || (identifier.length() == 0)) {
+                       sendErrorReply(pluginReplySender, null, 400, "Missing Identifier.");
+                       return;
+               }
                if (!active.get()) {
-                       sendErrorReply(pluginReplySender, null, 503, "FCP Interface deactivated");
+                       sendErrorReply(pluginReplySender, identifier, 503, "FCP Interface deactivated");
                        return;
                }
                AbstractSoneCommand command = commands.get(parameters.get("Message"));
                if (command == null) {
-                       sendErrorReply(pluginReplySender, null, 404, "Unrecognized Message: " + parameters.get("Message"));
+                       sendErrorReply(pluginReplySender, identifier, 404, "Unrecognized Message: " + parameters.get("Message"));
                        return;
                }
                if (!accessAuthorizer.authorized(AccessType.values()[accessType], fullAccessRequired.get(), command.requiresWriteAccess())) {
-                       sendErrorReply(pluginReplySender, null, 401, "Not authorized");
-                       return;
-               }
-               String identifier = parameters.get("Identifier");
-               if ((identifier == null) || (identifier.length() == 0)) {
-                       sendErrorReply(pluginReplySender, null, 400, "Missing Identifier.");
+                       sendErrorReply(pluginReplySender, identifier, 401, "Not authorized");
                        return;
                }
                try {
-                       Response response = command.execute(parameters, data, AccessType.values()[accessType]);
+                       Response response = command.execute(parameters);
                        sendReply(pluginReplySender, identifier, response);
                } catch (Exception e1) {
                        logger.log(Level.WARNING, "Could not process FCP command ā€œ%sā€.", command);
@@ -200,13 +200,7 @@ public class FcpInterface {
                if (identifier != null) {
                        replyParameters.putOverwrite("Identifier", identifier);
                }
-               if (response.hasData()) {
-                       pluginReplySender.send(replyParameters, response.getData());
-               } else if (response.hasBucket()) {
-                       pluginReplySender.send(replyParameters, response.getBucket());
-               } else {
-                       pluginReplySender.send(replyParameters);
-               }
+               pluginReplySender.send(replyParameters);
        }
 
        @Subscribe