- Response reply = command.execute(parameters, data, AccessType.values()[accessType]);
- SimpleFieldSet replyParameters = reply.getReplyParameters();
- replyParameters.putOverwrite("Identifier", identifier);
- if (reply.hasData()) {
- pluginReplySender.send(replyParameters, reply.getData());
- } else if (reply.hasBucket()) {
- pluginReplySender.send(replyParameters, reply.getBucket());
- } else {
- pluginReplySender.send(replyParameters);
+ if (!active) {
+ sendReply(pluginReplySender, null, new ErrorResponse(400, "FCP Interface deactivated"));
+ return;
+ }
+ AbstractSoneCommand command = commands.get(parameters.get("Message"));
+ if ((accessType == FredPluginFCP.ACCESS_FCP_RESTRICTED) && (((fullAccessRequired == FullAccessRequired.WRITING) && command.requiresWriteAccess()) || (fullAccessRequired == FullAccessRequired.ALWAYS))) {
+ sendReply(pluginReplySender, null, new ErrorResponse(401, "Not authorized"));
+ return;
+ }
+ if (command == null) {
+ sendReply(pluginReplySender, null, new ErrorResponse("Unrecognized Message: " + parameters.get("Message")));
+ return;
+ }
+ String identifier = parameters.get("Identifier");
+ if ((identifier == null) || (identifier.length() == 0)) {
+ sendReply(pluginReplySender, null, new ErrorResponse("Missing Identifier."));
+ return;
+ }
+ try {
+ Response response = command.execute(parameters, data, AccessType.values()[accessType]);
+ sendReply(pluginReplySender, identifier, response);
+ } catch (Exception e1) {
+ logger.log(Level.WARNING, "Could not process FCP command “%s”.", command);
+ sendReply(pluginReplySender, identifier, new ErrorResponse("Error executing command: " + e1.getMessage()));