Package net.pterodactylus.sone.freenet.fcp.Command

Examples of net.pterodactylus.sone.freenet.fcp.Command.ErrorResponse


   *            {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
   */
  public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
    if (!active) {
      try {
        sendReply(pluginReplySender, null, new ErrorResponse(400, "FCP Interface deactivated"));
      } catch (PluginNotFoundException pnfe1) {
        logger.log(Level.FINE, "Could not set error to plugin.", pnfe1);
      }
      return;
    }
    AbstractSoneCommand command = commands.get(parameters.get("Message"));
    if ((accessType == FredPluginFCP.ACCESS_FCP_RESTRICTED) && (((fullAccessRequired == FullAccessRequired.WRITING) && command.requiresWriteAccess()) || (fullAccessRequired == FullAccessRequired.ALWAYS))) {
      try {
        sendReply(pluginReplySender, null, new ErrorResponse(401, "Not authorized"));
      } catch (PluginNotFoundException pnfe1) {
        logger.log(Level.FINE, "Could not set error to plugin.", pnfe1);
      }
      return;
    }
    try {
      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()));
      }
    } catch (PluginNotFoundException pnfe1) {
      logger.log(Level.WARNING, "Could not find destination plugin: " + pluginReplySender);
    }
  }
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.freenet.fcp.Command.ErrorResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.