Package org.goobi.production.plugin.interfaces

Examples of org.goobi.production.plugin.interfaces.ICommandPlugin


        return;
      }
     
     
      // get correct plugin from list
      ICommandPlugin myCommandPlugin = (ICommandPlugin) PluginLoader.getPluginByTitle(PluginType.Command, this.command);
      if (myCommandPlugin == null) {
        generateAnswer(resp, 400, "invalid command", "command not found in list of command plugins");
        return;
      }

      // hand parameters over to command
      Map<String, String[]> map = req.getParameterMap();
      HashMap<String, String> params = new HashMap<String, String>();
      Iterator<Entry<String, String[]>> i = map.entrySet().iterator();
      while (i.hasNext()) {
        Entry<String, String[]> entry =  i.next();
        if (entry.getValue()[0] != null) {
          params.put(entry.getKey(), entry.getValue()[0]);
        }
      }
      myCommandPlugin.setParameterMap(params);

      // let command validate if all parameters are correct: null means valid
      CommandResponse cr = myCommandPlugin.validate();
      if (cr != null) {
        generateAnswer(resp, cr);
        return;
      }

      // no validation errors, so call the command
      if (myCommandPlugin.usesHttpSession()) {
        myCommandPlugin.setHttpResponse(resp);
      }
      cr = myCommandPlugin.execute();
      generateAnswer(resp, cr.getStatus(), cr.getTitle(), cr.getMessage());
      return;

    } else {
      generateAnswer(resp, 404, "web api deactivated", "web api not configured");
View Full Code Here


  private void generateHelp(HttpServletResponse resp) throws IOException {
    String allHelp = "";
    List<IPlugin> mycommands = PluginLoader.getPluginList(PluginType.Command);
    for (IPlugin iPlugin : mycommands) {
      ICommandPlugin icp = (ICommandPlugin) iPlugin;
      allHelp += "<h4>" + icp.help().getTitle() + "</h4>" + icp.help().getMessage() + "<br/><br/>";
    }
    generateAnswer(resp, 200, "Goobi Web API Help", allHelp);
  }
View Full Code Here

TOP

Related Classes of org.goobi.production.plugin.interfaces.ICommandPlugin

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.