Package org.elfinder.servlets.commands

Examples of org.elfinder.servlets.commands.AbstractCommand


      if (config == null) {
        throw new Exception("Configuration problem");
      }

      // prepare command and run
      AbstractCommand command = prepareCommand((String) requestParams.get("cmd"), request, response, config);
      try {
        command.execute();
      } catch (ConnectorException e) {
        logger.warn("command returned an error", e);
        putResponse("error", e.getMessage());
      }

      // append init info if needed
      if (command.mustRunInit()) {
        try {
          command.initCommand();
        } catch (ConnectorException e) {
          logger.warn("command returned an error", e);
          putResponse("error", e.getMessage());
        }
      }

      // output if command didn't do it
      if (!command.isResponseOutputDone()) {
        output(response, command.isResponseTextHtml(), json, command.getResponseWriter());
        command.setResponseOutputDone(true);
      }
    } catch (Exception e) {
      logger.error("Unknown error", e);
      putResponse("error", "Unknown error");
View Full Code Here


    if (!config.isCommandAllowed(commandStr)) {
      putResponse("error", "Permission denied");
    }

    AbstractCommand command = null;
    if (commandStr != null) {
      command = instanciateCommand(commandStr);
      if (command == null) {
        putResponse("error", "Unknown command");
      }
    } else {
      String current = (String) request.getParameterMap().get("current");
      if (current != null) {
        command = new OpenCommand();
      } else {
        command = new ContentCommand();
      }
    }

    command.setRequest(request);
    command.setResponse(response);
    command.setJson(json);
    command.setRequestParameters(requestParams);
    command.setListFiles(listFiles);
    command.setListFileStreams(listFileStreams);
    command.setConfig(config);

    command.init();

    return command;
  }
View Full Code Here

   * Instanciate a command from its name.
   * @param commandName
   * @return
   */
  protected AbstractCommand instanciateCommand(String commandName) {
    AbstractCommand instance = null;
    try {
      Class<AbstractCommand> clazz = getCommandClass(commandName);
      if (clazz != null) {
        instance = clazz.newInstance();
        if (instance == null) {
View Full Code Here

TOP

Related Classes of org.elfinder.servlets.commands.AbstractCommand

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.