Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.CommandException


            throws CommandException, CommandValidationException {
        int exitCode = -1;

        if (node == null) {
            if(nodeDirChild == null)
                throw new CommandException(Strings.get("internal.error",
                        "nodeDirChild was null.  The Base Class is supposed to "
                        + "guarantee that this won't happen"));
            _node = nodeDirChild.getName();
            String nodeHost = getInstanceHostName(true);
            createNodeImplicit(_node, getProductRootPath(), nodeHost);
        } else {
            _node = node;
        }

        if (isRegisteredToDAS()) {
            if (!_rendezvousOccurred) {
                setRendezvousOccurred("true");
                _rendezvousOccurred = true;
            }

        } else {
            try {
                registerToDAS();
                _rendezvousOccurred = true;
            } catch (CommandException ce) {
                FileUtils.deleteFileNowOrLater(instanceDir);
                throw ce;
            }
        }
        bootstrapSecureAdminFiles();
        try {
            exitCode = super.executeCommand();
            if (exitCode == SUCCESS) {
                saveMasterPassword();
            }
        } catch (CommandException ce) {
            String msg = "Something went wrong in creating the local filesystem for instance " + instanceName;
            if (ce.getLocalizedMessage() != null) {
                msg = msg + ": " + ce.getLocalizedMessage();
            }
            logger.severe(msg);
            setRendezvousOccurred("false");
            _rendezvousOccurred = false;

            throw new CommandException(msg, ce);
        }
        return exitCode;
    }
View Full Code Here


            PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(),
                MASTER_PASSWORD_ALIAS.toCharArray());
            p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
            chmod("600", pwdFile);
        } catch (Exception ex) {
            throw new CommandException(Strings.get("masterPasswordFileNotCreated", pwdFile),
                ex);
        }
    }
View Full Code Here

        String instanceHostName = null;
        InetAddress localHost = null;
        try {
            localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException ex) {
            throw new CommandException(Strings.get("cantGetHostName", ex));
        }
        if (localHost != null) {
            if (isCanonical) {
                instanceHostName = localHost.getCanonicalHostName();
            } else {
View Full Code Here

        } catch (CommandException cex) {
            logger.finer("RemoteCommand.prepare throws " + cex);
            throw cex;
        } catch (Exception e) {
            logger.finer("RemoteCommand.prepare throws " + e);
            throw new CommandException(e.getMessage());
        }
    }
View Full Code Here

        checkOptions();

        File domainFile = new File(new File(domainDirParam), domainName);

        if (!isWritableDirectory(domainFile)) {
            throw new CommandException(
                strings.get("InvalidDirectory", domainFile.getPath()));
        }
        setBackupDir(backupdir);
        prepareRequest();
        initializeLogger();     // in case program options changed
View Full Code Here

            ListManager mgr = new ListManager(request);
            logger.info(mgr.list());           
        } catch (BackupWarningException bwe) {
            logger.info(bwe.getMessage());
        } catch (BackupException be) {
            throw new CommandException(be);
        }
        return 0;
    }
View Full Code Here

        boolean domainExists = true;
       
        if (backupFilename == null && domainName == null) {
            if (!force) {
                throw new CommandException(strings.get("UseForceOption"));
            }
            // this will properly initialize the domain dir
            // see LocalDomainCommand.initDomain())
            super.validate();
        }

        checkOptions();

        try {
            setDomainName(domainName);
            initDomain();
        } catch (CommandException e) {
            if (e.getCause() != null &&
                (e.getCause() instanceof java.io.IOException)) {
                // The domain does not exist which is allowed if the
                // force option is used (checked later).
                domainExists = false;
            } else {
                throw e;
            }
        }

        if (domainExists && isRunning()) {
            throw new CommandException(strings.get("DomainIsNotStopped",
                                       domainName));
        }

        if (backupFilename != null) {
            File f = new File(backupFilename);
View Full Code Here

            RestoreManager mgr = new RestoreManager(request);
            logger.info(mgr.restore());
        } catch (BackupWarningException bwe) {
            logger.info(bwe.getMessage());
        } catch (BackupException be) {
            throw new CommandException(be);
        }
        return 0;
    }
View Full Code Here

            prepareProcessExecutor();
            CLIProcessExecutor cpe = new CLIProcessExecutor();
            cpe.execute("pingDatabaseCmd", pingDatabaseCmd(false), true);
            if (cpe.exitValue() > 0) {
                // if ping is unsuccesfull then database is not up and running
                throw new CommandException(
                    strings.get("StopDatabaseStatus", dbHost, dbPort));
            } else if (cpe.exitValue() < 0) {
                // Something terribly wrong!
                throw new CommandException(
                    strings.get("UnableToStopDatabase", "derby.log"));
            } else {
                // database is running so go ahead and stop the database
                cpe.execute("stopDatabaseCmd", stopDatabaseCmd(), true);
                if (cpe.exitValue() > 0) {
                    throw new CommandException(
                        strings.get("UnableToStopDatabase", "derby.log"));
                }
            }
        } catch (Exception e) {
            throw new CommandException(
                strings.get("UnableToStopDatabase", "derby.log"), e);
        }
        return 0;
    }
View Full Code Here

            // if ping is unsuccesfull then database is not up and running
            if (cpe.exitValue() > 0) {
                logger.finer("Start Database");
                cpe.execute("startDatabaseCmd", startDatabaseCmd(), false);
                if (cpe.exitValue() != 0) {
                    throw new CommandException(strings.get("UnableToStartDatabase", dbLog));
                }
            } else if (cpe.exitValue() < 0) {
                // Something terribly wrong!
                throw new CommandException(strings.get("CommandUnSuccessful", name));
            } else {
                // database already started
                logger.info(strings.get("StartDatabaseStatus", dbHost, dbPort));
            }
        } 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.
            CLIProcessExecutor cpePing = new CLIProcessExecutor();
            CLIProcessExecutor cpeSysInfo = new CLIProcessExecutor();
            try {
                if (!programOpts.isTerse()) {
                    // try getting sysinfo
                    logger.fine(strings.get("database.info.msg", dbHost, dbPort));
                }
                cpePing.execute("pingDatabaseCmd", pingDatabaseCmd(true), true);
                int counter = 0;
                //give time for the database to be started
                while (cpePing.exitValue() != 0 && counter < 10) {
                    cpePing.execute("pingDatabaseCmd", pingDatabaseCmd(true), true);
                    Thread.sleep(500);
                    counter++;
                    //break out if start-database failed
                    try {
                        cpe.exitValue();
                        break;
                    } catch (IllegalThreadStateException itse) {
                        continue;
                    }
                }
                if (!programOpts.isTerse()) {
                    logger.finer("Database SysInfo");
                    if (cpePing.exitValue() == 0) {
                        cpeSysInfo.execute("sysinfoCmd", sysinfoCmd(), true);
                        if (cpeSysInfo.exitValue() != 0) {
                            logger.info(strings.get("CouldNotGetSysInfo"));
                        }
                    }
                }
            } catch (Exception e) {
                throw new CommandException(strings.get("CommandUnSuccessful", name), e);
            }
            if (cpePing.exitValue() == 0) {
                logger.info(strings.get("DatabaseStartMsg"));
                if ((new File(dbLog)).canWrite()) {
                    logger.info(strings.get("LogRedirectedTo", dbLog));
                }
            } else {
                throw new CommandException(strings.get("UnableToStartDatabase", dbLog));
            }
        } catch (Exception e) {
            throw new CommandException(strings.get("CommandUnSuccessful", name), e);
        }
        return exitCode;
    }
View Full Code Here

TOP

Related Classes of org.glassfish.api.admin.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.