FileDocCategorySizeDatePackage
UpgradeToolMain.javaAPI DocGlassfish v2 API8864Wed Aug 01 12:19:46 BST 2007com.sun.enterprise.tools.upgrade

UpgradeToolMain

public class UpgradeToolMain extends Object

Fields Summary
static Logger
_logger
private CommonInfoModel
commonInfo
private UpgradeHarness
harness
private String
certDbPassword
private String
aliasname
private String
keyStorePassword
private com.sun.enterprise.util.i18n.StringManager
sm
Constructors Summary
public UpgradeToolMain()

    
      
        final ASenvPropertyReader reader = new ASenvPropertyReader(
           System.getProperty(SystemPropertyConstants.CONFIG_ROOT_PROPERTY));
        reader.setSystemProperties();

        sm = StringManager.getManager(LogService.UPGRADE_LOGGER);
        _logger.log(Level.INFO, 
                sm.getString("enterprise.tools.upgrade.start_upgrade_tool"));
        
        commonInfo = new CommonInfoModel();
        
        String targetDomainRoot = System.getProperty(UpgradeConstants.AS_DOMAIN_ROOT);
        if(targetDomainRoot == null) {
           targetDomainRoot = new File("").getAbsolutePath();
        }
        commonInfo.setTargetDomainRoot(targetDomainRoot);
        
        harness = new UpgradeHarness();
        String targetInstallPath = System.getProperty(UpgradeConstants.AS_INSTALL_ROOT);
        String asadmin = null;
        String osName = System.getProperty(UpgradeConstants.OS_NAME_IDENTIFIER);
        
        commonInfo.setOSName(osName);
        
        //Test for valid configuration by checking installRoot
        if(osName.indexOf(UpgradeConstants.OS_NAME_WINDOWS) != -1) {
            asadmin = targetInstallPath + File.separator + 
                    UpgradeConstants.AS_BIN_DIRECTORY + 
                    File.separator + UpgradeConstants.ASUPGRADE_BAT;
        } else {
            asadmin = targetInstallPath + File.separator + 
                    UpgradeConstants.AS_BIN_DIRECTORY + 
                    File.separator + UpgradeConstants.ASUPGRADE;
        }
        try {
            if(! new File(asadmin).exists()) {
                _logger.log(Level.WARNING,
                        sm.getString("enterprise.tools.upgrade.configError"));
                System.exit(1);
            }
        }catch (Exception e) {
            _logger.log(Level.WARNING,
                    sm.getString("enterprise.tools.upgrade.unknownError"),e);
        }
        commonInfo.setTargetInstallDir(targetInstallPath);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        UpgradeToolMain main = new UpgradeToolMain();
        StringBuffer argsStringBuff = new StringBuffer();
        for(int i=0;i<args.length;i++){
            argsStringBuff.append(args[i]);
            argsStringBuff.append(" ");
        }
        _logger.info(UpgradeConstants.ASUPGRADE + argsStringBuff.toString());
        // CR 6568819 - added support for -v option (CLI_OPTION_VERSION_UC/LC_SHORT)
        if(args.length==0){
            main.startGUI(args);
        } else if (args[0].equals(UpgradeConstants.CLI_OPTION_CONSOLE_SHORT) || 
                args[0].equals(UpgradeConstants.CLI_OPTION_CONSOLE_LONG) || 
                args[0].equals(UpgradeConstants.CLI_OPTION_VERSION_UC_SHORT) || 
                args[0].equals(UpgradeConstants.CLI_OPTION_VERSION_LC_SHORT) || 
                args[0].equals(UpgradeConstants.CLI_OPTION_VERSION_LONG)){
            main.startCLI(args);
        } else {
            main.startGUI(args);
        }
    
private voidprocessUIEvent(DialogEvent evt)

        if(evt.getAction() == DialogEvent.FINISH_ACTION ||
        evt.getAction() == DialogEvent.CANCEL_ACTION){
            System.exit(0);
        }else if(evt.getAction() == DialogEvent.UPGRADE_ACTION){
            this.upgrade();
        }
    
public voidstartCLI(java.lang.String[] args)

        _logger.log(Level.INFO,
                sm.getString("enterprise.tools.upgrade.start_upgrade_tool_cli"));
        LogService.addLogMessageListener(new CliLogMessageListener()); 
        commonInfo.setCliMode(true);
        try{
            new CLIParser(commonInfo, args);
        }catch(Exception e){
            _logger.log(Level.INFO,sm.getString(
                    "enterprise.tools.upgrade.unexpected_parsing"),e);
            System.exit(1);
        }
        this.upgrade();
    
public voidstartGUI(java.lang.String[] args)

        _logger.log(Level.INFO,sm.getString(
                "enterprise.tools.upgrade.start_upgrade_tool_gui"));
        if(args.length > 0){
            CliLogMessageListener l = new CliLogMessageListener();
            LogService.addLogMessageListener(l);  //to log and output command line parsing
            new ArgsParser(args, commonInfo).parse();
            LogService.removeLogMessageListener(l);
        }
        MainFrame gui = new MainFrame(commonInfo);
        LogService.addLogMessageListener(gui);
        gui.addDialogListener(new DialogListener(){
            public void dialogProcessed(DialogEvent evt){
                processUIEvent(evt);
            }
        });
        UpdateProgressManager.getProgressManager().addUpgradeUpdateListener(gui);
        gui.setVisible(true);
    
private voidupgrade()

        harness.setCommonInfoModel(commonInfo);
        
        //Start Upgrade
        _logger.log(Level.INFO, sm.getString(
                "enterprise.tools.upgrade.start_upgrade_harness"));
        harness.startUpgrade();
        
        //Delete temporary files (if any) created during the process
        _logger.log(Level.INFO, sm.getString(
                "enterprise.tools.upgrade.deletingTempPasswordFiles"));
        commonInfo.deletePasswordFile();
        if(commonInfo.getCliMode())
            System.exit(0);