Package com.sun.enterprise.cli.framework

Examples of com.sun.enterprise.cli.framework.CommandException


            }
            unconfigureAddons();
        }
        catch(Exception e) {
            CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());        
            throw new CommandException(getLocalizedString("CannotStopDomain",
                                                           new Object[] {domainName} ), e);
        }
    }
View Full Code Here


        try {
            domainName = getDomainName();
        } catch(Exception e) {
            CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
            domainName = domainName==null?getLocalizedString("Undefined"):domainName;
            throw new CommandException(getLocalizedString("CannotStopDomain",
                                                          new Object[] {domainName} ), e);
        }
        stopDomain(domainName);
    }
View Full Code Here

            prepareProcessExecutor();
            CLIProcessExecutor cpe = new CLIProcessExecutor();
            cpe.execute(pingDatabaseCmd(false), true);
            if (cpe.exitValue() > 0) {
                    //if ping is unsuccesfull then database is not up and running
                throw new CommandException(getLocalizedString("StopDatabaseStatus", new Object[]{dbHost, dbPort}));
            }
            else if (cpe.exitValue() <0) {
                    // Something terribly wrong!
                throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                              new Object[] {name} ));
            }
            else {
                    //database is running so go ahead and stop the database
                cpe.execute(stopDatabaseCmd(), true);
                if (cpe.exitValue() > 0) {
                    throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                              new Object[] {name} ));
                }
                CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                           "CommandSuccessful",
                                                           new Object[] {name}));
View Full Code Here

            //if ping is unsuccesfull then database is not up and running
            if (cpe.exitValue() > 0) {
              CLILogger.getInstance().printDebugMessage("Start Database");
                cpe.execute(startDatabaseCmd(), false);
                if (cpe.exitValue() != 0) {
                    throw new CommandException(getLocalizedString("UnableToStartDatabase",
                                                     new Object[]{dbLog}));
                }
            }
            else if (cpe.exitValue() < 0) {
                    // Something terribly wrong!
                throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                              new Object[] {name} ));
            }
            else {
                    //database already started
                CLILogger.getInstance().printMessage(getLocalizedString(
                                                     "StartDatabaseStatus",
                                                     new Object[]{dbHost, dbPort}));
                CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                           "CommandSuccessful",
                                                           new Object[] {name}));
            }
        }
        catch (IllegalThreadStateException ite) {
            // IllegalThreadStateException is thrown if the
            // process has not yet teminated and is still running.
          // see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Process.html#exitValue()
            // This is good since that means the database is up and running.

            if (!getBooleanOption(TERSE)) {
                try {
                  CLILogger.getInstance().printDetailMessage(
                                            getLocalizedString("database.info.msg",
                                            new Object[]{dbHost, dbPort}));
                    //try getting sysinfo
                  CLILogger.getInstance().printDebugMessage("Database SysInfo");
                new CLIProcessExecutor().execute(sysinfoCmd(), true);
                }
                catch (Exception e) {
                    throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                           new Object[] {name}), e);
                }
            }
            CLILogger.getInstance().printMessage(getLocalizedString("DatabaseStartMsg"));
          if ((new File(dbLog)).canWrite()) {
View Full Code Here

            DomainsManager manager = getFeatureFactory().getDomainsManager();
            domainsList = manager.listDomains(domainConfig);
        }
        catch(Exception e)
        {
            throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                     new Object[] {name} ), e);
        }
        boolean allDomainsStarted = true;

        if (domainsList.length == 0)
            throw new CommandException(getLocalizedString("NoDomainsToStart"));
        else
            CLILogger.getInstance().printDetailMessage(getLocalizedString("StartingAppserv",
                                                             new Object[] {getDomainsRoot()}));
       
        for (int i = 0; i < domainsList.length; i++)
        {
            try
            {
                startDomain(domainsList[i]);
            }
            catch(Exception e)
            {
                allDomainsStarted = false;
                CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
                CLILogger.getInstance().printExceptionStackTrace(e);
                CLILogger.getInstance().printError(getLocalizedString("CannotStartDomainMsg",
                                                       new Object[] {domainsList[i]}));
            }
        }
        if (!allDomainsStarted)
        {
            throw new CommandException(getLocalizedString("CannotStartOneOrMoreDomains"));

        }
    }
View Full Code Here

      {
        if(doBackupMessage)
          checkOnBackup(config);
      }

            throw new CommandException(getLocalizedString("CannotStartDomain",
                       new Object[] {domainName}), e);
        }    
    }
View Full Code Here

            domainName = getDomainName();
        } catch(Exception e)
        {
            CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
            domainName = domainName==null?getLocalizedString("Undefined"):domainName;
            throw new CommandException(getLocalizedString("CannotStartDomain",
                       new Object[] {domainName}), e);
        }
        startDomain(domainName);
        if (t.isAlive()) {
            try {
View Full Code Here

        if (ipuh.needsUpgrade()) {
              String domainDirOption = getOption(DOMAINDIR);
              String domainsDirProperty = System.getProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY);

              if (domainDirOption != null && domainDirOption.indexOf(domainsDirProperty) == -1){
                    throw new CommandException(getLocalizedString("UpgradeUnsupported", new Object[]{domainsDirProperty}));
                }
            if (ipuh.isCommsApplicationServer()) {
                try {
                    String profile = getOption(PROFILE);
                    if (peformUpgradeForCommsAppServer(installDir, domainDir, domainName, profile, ipuh.getFromVersion(), ipuh.getToVersion())) {
                        CLILogger.getInstance().printDetailMessage((getLocalizedString("UpgradeSuccessful")));
                        ipuh.touchUpgradedToFile();
                    } else {
                        throw new CommandException(getLocalizedString("UpgradeFailedForCommsAppServer"));
                    }
                } catch (Exception ex) {
                    throw new CommandException(getLocalizedString("UpgradeFailedForCommsAppServer"), ex);
                }
            } else {
            try {
                final String sPasswordFile = createPasswordFileText();
                final String[] upgradeCmd;
               
                /*Need to prefix the upgrade command with CMD /c in case of Windows*/
                if(OS.isWindows())
                        upgradeCmd = new String[]    {"CMD",
                                                        "/c",
                                                      installDir + File.separator +
                                                      "bin" + File.separator +
                                                      "asupgrade", "-c", "-s",
                                                      domainDir+File.separator+domainName,
                                                      "-t", installDir +File.separator+ "domains",
                                                      "-noprompt" };
                else
                            upgradeCmd = new String[] {installDir + File.separator +
                                                      "bin" + File.separator +
                                                      "asupgrade", "-c", "-s",
                                                      domainDir+File.separator+domainName,
                                                      "-t", installDir +File.separator+ "domains",
                                                      "-noprompt" };
               
                ProcessExecutor pe = new ProcessExecutor(upgradeCmd, UPGRADE_TIMEOUT);
                /*
                 * ProcessExecutor's constructor replaces all the '/'s with '\' in case the OS is Windows.
                 * We don't want that for CMD /c. Hence need to replace it again
                 */
                if(OS.isWindows())
                        upgradeCmd[1] ="/c";

                CLILogger.getInstance().printDetailMessage((getLocalizedString("StartingUpgrade")));
                pe.execute()// timeout in 600sec or 10min
                Process process = pe.getSubProcess();
                int exitValue = process.waitFor();
                if (exitValue != 0) {
                    throw new CommandException(getLocalizedString("UpgradeFailed"));
                }else {
                    CLILogger.getInstance().printDetailMessage((getLocalizedString("UpgradeSuccessful")));
                    ipuh.touchUpgradedToFile();
                }
            }
            catch (Exception e) {
                    //e.printStackTrace();
                throw new CommandException(getLocalizedString("UpgradeFailed"), e);
            }
            }
        } else {
            try {
                ipuh.touchUpgradedToFile();
            } catch(final IOException ioe) {
                throw new CommandException(ioe);
            }
        }
    }
View Full Code Here

    private void checkIfStopping() throws Exception
    {
        if(isStopping(mgr, config))
        {
            throw new CommandException(getLocalizedString("CannotStartStoppingDomain",
                   new Object[] {domainName}));
        }
    }
View Full Code Here

            fTemp.deleteOnExit();
          tempFileName = fTemp.toString();
      }
      catch (IOException ioe) {
            final StringManager lsm = StringManager.getManager(DerbyControl.class);
          throw new CommandException(lsm.getString("UnableToAccessDatabaseLog", tempFileName));
      }
        return tempFileName;
    }   
View Full Code Here

TOP

Related Classes of com.sun.enterprise.cli.framework.CommandException

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.