X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FFcpInterface.java;h=6f28518a3a20032cebb5c4d38b8eb9c07a032a8f;hp=a331cfb533ac95d960f3f3e0d9c58dd7fe37b55a;hb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae;hpb=906cc9fc1cde118f7c08a1f7a611abfb2285df9c diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index a331cfb..6f28518 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -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