Package com.sun.enterprise.tools.upgrade.common.arguments

Examples of com.sun.enterprise.tools.upgrade.common.arguments.ArgumentHandler


            throw new RuntimeException("CLI cannot be used with null console");
        }
        int cnt = aList.size();
        this.inputMap = new HashMap<String, ArgumentHandler>();
        for (int i = 0; i < cnt; i++) {
            ArgumentHandler tmpAh = aList.get(i);
            inputMap.put(tmpAh.getCmd(), tmpAh);
        }

        // in command line case, we want info to go to console as well
        ConsoleHandler handler = new ConsoleHandler();
        handler.setFormatter(LogService.createFormatter());
View Full Code Here


        }
        masterPasswordPrompt();
    }

    private void sourcePrompt() {
        ArgumentHandler tmpA = inputMap.get(CLIConstants.SOURCE_SHORT);
        if (tmpA == null) {
            tmpA = inputMap.get(CLIConstants.SOURCE);
        }
        if (tmpA == null) {
            String source = console.readLine(
                sm.getString("enterprise.tools.upgrade.cli.Source_input"));
            tmpA = new ARG_source();
            tmpA.setRawParameters(source);
            inputMap.put(CLIConstants.SOURCE, tmpA);
        }
        //Check if input is a valid source directory input
        if (tmpA.isValidParameter()) {
            tmpA.exec();
        } else {
            System.err.println(sm.getString(
                "enterprise.tools.upgrade.cli.not_valid_source_install"));
            inputMap.remove(CLIConstants.SOURCE_SHORT);
            inputMap.remove(CLIConstants.SOURCE);
View Full Code Here

            sourcePrompt();
        }
    }
 
    private void targetPrompt() {
        ArgumentHandler tmpA = inputMap.get(CLIConstants.TARGET_SHORT);
        if (tmpA == null) {
            tmpA = inputMap.get(CLIConstants.TARGET);
        }
        if (tmpA == null) {
            String target = console.readLine(
                sm.getString("enterprise.tools.upgrade.cli.Target_input"));
            tmpA = new ARG_target();
            tmpA.setRawParameters(target);
            inputMap.put(CLIConstants.TARGET, tmpA);
        }

        // in the interactive CLI case, we'll allow users to fix name clashes
        tmpA.getCommonInfo().getTarget().setDirectoryMover(this);
        if (tmpA.isValidParameter()) {
            tmpA.exec();
        } else {
            System.err.println(sm.getString(
                "enterprise.tools.upgrade.cli.not_valid_target_install"));
            inputMap.remove(CLIConstants.TARGET_SHORT);
            inputMap.remove(CLIConstants.TARGET);
View Full Code Here

      //- System.out.println("lenght: " + args.length + "\ti: " + i);
      tmpArg = args[i];
      if (tmpArg.startsWith("-")){
        //- strip option designator '-' or '--'
        tmpArg = tmpArg.substring(tmpArg.lastIndexOf("-") + 1);
        ArgumentHandler aHandler = getArgHandler(tmpArg);
        if(aHandler.isRequiresParameter() && i+1 < args.length){
          aHandler.setRawParameters(args[++i]);
        }
        aList.add(aHandler);
        // --passwordfile/-f creates credential ArgumentHandlers
        aList.addAll(aHandler.getChildren());
                if (aHandler instanceof ARG_target){
                    trgIndx = aList.indexOf(aHandler);
                }
                if (aHandler instanceof ARG_source){
                    srcIndx = aList.indexOf(aHandler);
                }
      }
      //-System.out.println("   tmpArg: " + tmpArg);
    }

        //- force the src location to preceed target location
        //- so future processing will proceed properly.
        if (srcIndx > trgIndx){
            ArgumentHandler tmpA = aList.remove(srcIndx);
            aList.add(trgIndx, tmpA);
        }
    return aList;
  }
View Full Code Here

    return aList;
  }

   
  private ArgumentHandler getArgHandler(String cmd) {
    ArgumentHandler aHandler = null;
    Class clazz = null;
    try {
      clazz = Class.forName("com.sun.enterprise.tools.upgrade.common.arguments.ARG_" + cmd);
    } catch (ClassNotFoundException cnf) {
      try {
        clazz = Class.forName("com.sun.enterprise.tools.upgrade.common.arguments.ARG_UnknownCmd");
      } catch (ClassNotFoundException cnf1) {
        _logger.log(Level.INFO, sm.getString(
          "enterprise.tools.upgrade.cli.arg_unknow_class_not_found"));
      }
    } catch (Exception e1) {
      _logger.log(Level.INFO, sm.getString("enterprise.tools.upgrade.cli.invalid_option",e1), e1);
    }
   
    try {
      aHandler = (ArgumentHandler)clazz.getConstructor().newInstance();
      aHandler.setCmd(cmd);
    } catch (Exception ex) {
      _logger.log(Level.INFO,
        sm.getString("enterprise.tools.upgrade.cli.invalid_option",cmd), ex);
      System.exit(1);
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.tools.upgrade.common.arguments.ArgumentHandler

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.