Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.CommandException


            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


        initDomain();

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

        if (!isWritableDirectory(domainFile)) {
            throw new CommandException(
                strings.get("InvalidDirectory", domainFile.getPath()));
        }

        if (force == null ) {
            if (isRunning()) {
                boolean suspendAvailable = canSuspend();

                if (suspendAvailable && !isSuspended()) {
                    throw new CommandException(
                        strings.get("DomainIsNotSuspended", domainName));
                } else if (!suspendAvailable) {
                    throw new CommandException(strings.get("DomainIsNotStopped",
                        domainName));
                }
            }
        }

        int limit = 0;
        if (recycleLimit != null ) {
            try {
                limit = Integer.parseInt(recycleLimit.trim());
            } catch (NumberFormatException ex) {
                limit = -1;
            }
            if (limit < 0) {
                throw new CommandException(
                        strings.get("InvalidBackupRecycleLimit", recycleLimit));
            }
        }

        setDescription(description);
View Full Code Here

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

        // Get the cluster specified by clusterName
        Cluster cluster = domain.getClusterNamed(clusterName);
        if (cluster == null) {
            String msg = Strings.get("cluster.command.unknownCluster",
                    clusterName);
            throw new CommandException(msg);
        }

        // Get the list of servers in the cluster.
        List<Server> targetServers = domain.getServersInTarget(clusterName);
View Full Code Here

            manager.validateDomain(config, false);
            verifyPortBase();
        }
        catch (DomainException e) {
            logger.fine(e.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), e);
        }

        /*
         * The admin user is specified with the --user program option. If not
         * specified (because the user hit Enter at the prompt), we use the
         * default, which allows unauthenticated login.
         */
        adminUser = programOpts.getUser();
        if (!ok(adminUser)) {
            adminUser = SystemPropertyConstants.DEFAULT_ADMIN_USER;
            adminPassword = SystemPropertyConstants.DEFAULT_ADMIN_PASSWORD;
        }
        else if (noPassword) {
            adminPassword = SystemPropertyConstants.DEFAULT_ADMIN_PASSWORD;
        }
        else {
            adminPassword = getAdminPassword();
            boolean haveAdminPwd = true;
        }

        if (saveMasterPassword)
            useMasterPassword = true;

        if (masterPassword == null)
            masterPassword = DEFAULT_MASTER_PASSWORD;

        try {
            // verify admin port is valid if specified on command line
            if (adminPort != null) {
                verifyPortIsValid(adminPort);
            }
            // instance option is entered then verify instance port is valid
            if (instancePort != null) {
                verifyPortIsValid(instancePort);
            }

            // saving the login information happens inside this method
            createTheDomain(domainDir, domainProperties);
        }
        catch (CommandException ce) {
            logger.info(ce.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), ce);
        }
        catch (Exception e) {
            logger.fine(e.getLocalizedMessage());
            throw new CommandException(
                    strings.get("CouldNotCreateDomain", domainName), e);
        }
        return 0;
    }
View Full Code Here

            throws CommandException, CommandValidationException {

        final int portToVerify = convertPortStr(portNum);

        if (!NetUtils.isPortValid(portToVerify))
            throw new CommandException(strings.get("InvalidPortRange", portNum));

        if (checkPorts == false) {
            // do NOT make any network calls!
            logger.log(Level.FINER, "Port ={0}", portToVerify);
            return;
        }

        NetUtils.PortAvailability avail = NetUtils.checkPort(portToVerify);

        switch (avail) {
            case illegalNumber:
                throw new CommandException(
                        strings.get("InvalidPortRange", portNum));

            case inUse:
                throw new CommandException(
                        strings.get("PortInUseError", domainName, portNum));

            case noPermission:
                throw new CommandException(
                        strings.get("NoPermissionForPortError",
                        portNum, domainName));

            case unknown:
                throw new CommandException(strings.get("UnknownPortMsg", portNum));

            case OK:
                logger.log(Level.FINER, "Port ={0}", portToVerify);
                break;
            default:
View Full Code Here

        // Get the cluster specified by clusterName
        Cluster cluster = domain.getClusterNamed(clusterName);
        if (cluster == null) {
            String msg = Strings.get("cluster.command.unknownCluster",
                    clusterName);
            throw new CommandException(msg);
        }

        // Get the list of servers in the cluster.
        List<Server> targetServers = domain.getServersInTarget(clusterName);
View Full Code Here

                    sname = "instance " + info.getInstanceName();

                ProcessStreamDrainer psd = launcher.getProcessStreamDrainer();
                String output = psd.getOutErrString();
                if (ok(output))
                    throw new CommandException(strings.get("serverDiedOutput",
                            sname, exitCode, output));
                else
                    throw new CommandException(strings.get("serverDied",
                            sname, exitCode));
            }
            catch (GFLauncherException ex) {
                // should never happen
            }
            catch (IllegalThreadStateException ex) {
                // process is still alive
            }

            // wait before checking again
            try {
                Thread.sleep(100);
                if (!terse && count++ % 10 == 0)
                    System.out.print(".");
            }
            catch (InterruptedException ex) {
                // don't care
            }
        }

        if (!terse)
            System.out.println();

        if (!alive) {
            String msg;
            String time = "" + (WAIT_FOR_DAS_TIME_MS / 1000);
            if (info.isDomain())
                msg = strings.get("serverNoStart", strings.get("DAS"),
                        info.getDomainName(), time);
            else
                msg = strings.get("serverNoStart", strings.get("INSTANCE"),
                        info.getInstanceName(), time);

            throw new CommandException(msg);
        }
    }
View Full Code Here

        catch (Exception e) {
            // fall through.  Normal returns are in the block above
        }

        // abnormal return path
        throw new CommandException(
                strings.get("deathwait_timeout", CLIConstants.DEATH_TIMEOUT_MS));
    }
View Full Code Here

            catch (Exception e) {
                // ignore!
            }

            if (!success)
                throw new CommandException(
                        strings.get("deathwait_timeout", CLIConstants.DEATH_TIMEOUT_MS));
        }
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.