Package com.sun.enterprise.cli.framework

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


                                                       new Object[] {name}));
        } catch (Exception e) {           
            if (e.getLocalizedMessage() != null)
                CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());

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


            File f = (new File(path)).getParentFile();
            if (f != null) {
                try {
                    path = (new File(f, NODE_AGENT_DIRECTORY_NAME)).getCanonicalPath();
                } catch (Exception ex) {
                    throw new CommandException(_strMgr.getString("InvalidNodeAgentPath"), ex);
                }
            }
        }
        if (path == null) {
            throw new CommandException(_strMgr.getString("InvalidNodeAgentPath"));
        }
        return path;
    }     
View Full Code Here

       try {                           
            AgentConfig agentConfig = new AgentConfig(null, getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);
            return manager.listNodeAgents();
       } catch (Exception ex) {
           throw new CommandException(ex);
       }
    }
View Full Code Here

    {
      String agentName = null;
        if (operands.isEmpty()) {
        final String[] agents = getAgents();
        if (agents.length == 0) {
            throw new CommandException(_strMgr.getString("NoAgents",
            new Object[] {getAgentPath()}));
            } else if (agents.length > 1) {
            throw new CommandException(_strMgr.getString("NoDefaultAgent",
          new Object[] {getAgentPath()}));
            } else {
            agentName = agents[0]//assign the only domain
          }
        } else {
View Full Code Here

        validateOptions();

        //verify for no-spaces in agentdir option on non-windows platform
        String agentDirValue = getOption(AGENTDIR);
        if ((agentDirValue != null) && !isWindows() && isSpaceInPath(agentDirValue))
            throw new CommandException(getLocalizedString("SpaceNotAllowedInPath",
                                                                        new Object[]{AGENTDIR}));
        //domain validation upfront (i.e. before we prompt)
        String agentName=null;
        try {                                    
            // check to see in the nodeagent name was supplied
            if (operands.isEmpty()) {
                // no name, default to hostname
                agentName=NetUtils.getHostName();
            } else {
                // name supplied, use it
                agentName=(String)operands.firstElement();
            }

            // log agentname for debug
            CLILogger.getInstance().printDebugMessage("agentName = " + agentName);
           
            AgentConfig agentConfig = new AgentConfig(agentName,
                getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);             
            manager.validateNodeAgent(agentConfig, false);
        } catch (Exception e) {
            if (e.getLocalizedMessage() != null)
                CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());

            throw new CommandException(getLocalizedString(
                "CommandUnSuccessful", new Object[] {name} ), e);
        }
       
        try {                      
            Properties agentProperties = getAgentProperties(getOption(AGENT_PROPERTIES));
            final String adminUser = getUser();
            final String adminPassword = getPassword();
           
                //need to call setOption before calling getMasterPassword() since
                //getMasterPassword() needs to get ADMIN_PASSWORD first.
            setOption(ADMIN_PASSWORD, adminPassword);
           
            boolean saveMasterPasswordSpecified = getBooleanOption(SAVE_MASTER_PASSWORD);
            String masterPassword = null;
            if (saveMasterPasswordSpecified)
            {
               masterPassword = getMasterPasswordWithDefaultPrompt(null, null);
            }
           
            final String adminPort = String.valueOf(getPort());
            final String adminHost = getHost();
           
            Boolean saveMasterPassword = getSaveMasterPassword(masterPassword)
           
            //The --secure option is a synonymn for --agentproperties agent.das.isSecure=false           
            if (!getBooleanOption(SECURE)) {               
                agentProperties.setProperty(AgentConfig.AGENT_DAS_IS_SECURE, "false");
            }                      

            //System.out.println("adminPassword=" + adminPassword + " masterPassword=" + masterPassword +
            //    " saveMasterPassword=" + saveMasterPassword);           
           
            if (adminHost == null || adminPort == null || adminUser == null || adminPassword == null) {
                throw new CommandValidationException(_strMgr.getString("InvalidDASConfiguration"));
            }
       
            // defaulted protocol and clientHostName until moved to cli if deemed appropriate ???
            // temporary fix to remove agent user & password, for now map them to das user & password???
            AgentConfig agentConfig = new AgentConfig(agentName, getAgentPath(), adminUser,
                adminPassword, new Integer(getAdminPort()),
                adminHost, adminPort, adminUser, adminPassword,
                masterPassword,
                saveMasterPassword, agentProperties);                                               
           
            AgentManager manager = getAgentManager(agentConfig);                       
           
            //Create the node agent
            manager.createNodeAgent();                                              
           
            try {
                //If the DAS and Node Agent were created together on the same machine (i.e. by the
                //installer), the we attempt to pre-register the new node agent's config directly
                //in the domain.xml of the domain.
                rendezvousWithDAS(agentConfig, agentProperties);
            } catch (Exception ex) {
                try {
                    //if we could not register, then  cleanup
                    manager.deleteNodeAgent();
                } catch (Exception ex2) {
                    //eat any exceptions occuring during cleanup time.                   
                }
                throw ex;
            }
           
            CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        } catch (Exception e) {                       
            if (e.getLocalizedMessage() != null)
                CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());

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

        } catch (Exception e) {                       
            e.printStackTrace();

            CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());           
            throw new CommandException(
                _strMgr.getString("ApplyRepositoryZipCommandFailed",
                new Object[] {name}), e);
        }

    }
View Full Code Here

                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        } catch (Exception e) {           
                if (e.getLocalizedMessage() != null)
                    CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
                throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                              new Object[] {name} ), e);
      }
    }
View Full Code Here

                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        } catch (Exception e) {           
                if (e.getLocalizedMessage() != null)
                    CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
                throw new CommandException(getLocalizedString("CommandUnSuccessful",
                                                              new Object[] {name} ), e);
      }
    }
View Full Code Here

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

            createTheDomain(getDomainsRoot(), domainProperties);
        }
        catch (Exception e)
        {
            CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());
            throw new CommandException(getLocalizedString("CouldNotCreateDomain",
                new Object[] {domainName}), e);
        }
    }
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.