Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.CommandValidationException


    void validateHostName(String hostName)
            throws CommandValidationException {

        if (!StringUtils.ok(hostName)) {
            throw new CommandValidationException(
                    Strings.get("nodehost.required"));
        }
        try {
            // Check if hostName is valid by looking up it's address
            InetAddress.getByName(hostName);
        }
        catch (UnknownHostException e) {
            throw new CommandValidationException(
                    Strings.get("unknown.host", hostName),
                    e);
        }
    }
View Full Code Here


        if (StringUtils.ok(p)) {
            try {
                expandedPassword = RelativePathResolver.getRealPasswordFromAlias(p);
            }
            catch (IllegalArgumentException e) {
                throw new CommandValidationException(
                        Strings.get("no.such.password.alias", p));
            }
            catch (Exception e) {
                throw new CommandValidationException(
                        Strings.get("no.such.password.alias", p),
                        e);
            }

            if (expandedPassword == null) {
                throw new CommandValidationException(
                        Strings.get("no.such.password.alias", p));
            }
        }
    }
View Full Code Here

                break;
            case DCOM:
                pingDcomConnection(node);
                break;
            default:
                throw new CommandValidationException("Internal Error: unknown type");
        }
    }
View Full Code Here

                m2 = e2.getMessage();
            }
            String msg = Strings.get("ssh.bad.connect", node.getNodeHost(), "SSH");
            logger.warning(StringUtils.cat(": ", msg, m1, m2,
                    sshL.toString()));
            throw new CommandValidationException(StringUtils.cat(NL,
                    msg, m1, m2));
        }
    }
View Full Code Here

            if(!StringUtils.ok(domain))
                domain = host;

            if (!StringUtils.ok(installdir))
                throw new CommandValidationException(Strings.get("dcom.no.installdir"));

            pingDcomConnection(host, domain, username, password, getInstallRoot(installdir));
        }
        // very complicated catch copied from pingssh above...
        catch (CommandValidationException cve) {
            throw cve;
        }
        catch (Exception e) {
            String m1 = e.getMessage();
            String m2 = "";
            Throwable e2 = e.getCause();
            if (e2 != null) {
                m2 = e2.getMessage();
            }
            String msg = Strings.get("ssh.bad.connect", node.getNodeHost(), "DCOM");
            logger.warning(StringUtils.cat(": ", msg, m1, m2));
            throw new CommandValidationException(StringUtils.cat(NL, msg, m1, m2));
        }
    }
View Full Code Here

     */
    void pingDcomConnection(String host, String domain, String username,
            String password, String installRoot) throws CommandValidationException {
        // don't bother trying to connect if we have no password!
        if (!StringUtils.ok(password))
            throw new CommandValidationException(Strings.get("dcom.nopassword"));

        if (NetUtils.isThisHostLocal(host))
            throw new CommandValidationException(Strings.get("dcom.yes.local", host));

        try {
            installRoot = installRoot.replace('/', '\\');
            WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, username, password);
            WindowsRemoteFile wrf = new WindowsRemoteFile(wrfs, installRoot);
            WindowsCredentials creds = new WindowsCredentials(host, domain, username, password);

            // also looking for side-effect of Exception getting thrown...
            if (!wrf.exists()) {
                throw new CommandValidationException(Strings.get("dcom.no.remote.install",
                        host, installRoot));
            }

            if (!WindowsRemotePinger.ping(installRoot, creds))
                throw new CommandValidationException(Strings.get("dcom.no.connection", host));
        }
        catch (CommandValidationException cve) {
            throw cve;
        }
        catch (Exception ex) {
            throw new CommandValidationException(ex);
        }
    }
View Full Code Here

        String sshkeypassphrase = map.getOne(PARAM_SSHKEYPASSPHRASE);
        boolean installFlag = Boolean.parseBoolean(map.getOne(PARAM_INSTALL));

        // We use the resolver to expand any system properties
        if (!NetUtils.isPortStringValid(resolver.resolve(sshport))) {
            throw new CommandValidationException(Strings.get(
                    "ssh.invalid.port", sshport));
        }

        int port = Integer.parseInt(resolver.resolve(sshport));

        try {
            // sshpassword and sshkeypassphrase may be password alias.
            // Those aliases are handled by sshLauncher
            String resolvedInstallDir = resolver.resolve(installdir);

            sshL.validate(resolver.resolve(nodehost),
                    port,
                    resolver.resolve(sshuser),
                    sshpassword,
                    resolver.resolve(sshkeyfile),
                    sshkeypassphrase,
                    resolvedInstallDir,
                    // Landmark file to ensure valid GF install
                    LANDMARK_FILE,
                    logger);
        }
        catch (IOException e) {
            String m1 = e.getMessage();
            String m2 = "";
            Throwable e2 = e.getCause();
            if (e2 != null) {
                m2 = e2.getMessage();
            }
            if (e instanceof FileNotFoundException) {
                logger.warning(StringUtils.cat(": ", m1, m2, sshL.toString()));
                if (!installFlag)
                    throw new CommandValidationException(StringUtils.cat(NL,
                            m1, m2));
            }
            else {
                String msg = Strings.get("ssh.bad.connect", nodehost, "SSH");
                logger.warning(StringUtils.cat(": ", msg, m1, m2,
                        sshL.toString()));
                throw new CommandValidationException(StringUtils.cat(NL,
                        msg, m1, m2));
            }
        }
    }
View Full Code Here

        try {
            return RemoteType.valueOf(map.getOne(PARAM_TYPE));
        }
        catch (Exception e) {
            throw new CommandValidationException(e);
        }
    }
View Full Code Here

        if (node == null)
            return "";

        // dcomfix
        if (RemoteType.valueOf(node.getType()) == RemoteType.DCOM) {
            throw new CommandValidationException("NOT YET IMPLEMENTED FOR DCOM");
        }

        List<String> command = new ArrayList<String>();
        command.add("version");
        command.add("--local");
        command.add("--terse");
        NodeRunner nr = new NodeRunner(habitat, logger);

        StringBuilder output = new StringBuilder();
        try {
            int commandStatus = nr.runAdminCommandOnNode(node, output, command);
            if (commandStatus != 0) {
                return "unknown version: " + output.toString();
            }
        }
        catch (Exception e) {
            throw new CommandValidationException(
                    Strings.get("failed.to.run", command.toString(),
                    node.getNodeHost()), e);
        }
        return output.toString().trim();
    }
View Full Code Here

        String sshkeyfile = map.getOne(PARAM_SSHKEYFILE);
        if (StringUtils.ok(sshkeyfile)) {
            // User specified a key file. Make sure we get use it
            File kfile = new File(resolver.resolve(sshkeyfile));
            if (!kfile.isAbsolute()) {
                throw new CommandValidationException(
                        Strings.get("key.path.not.absolute",
                        kfile.getPath()));
            }
            if (!kfile.exists()) {
                throw new CommandValidationException(
                        Strings.get("key.path.not.found",
                        kfile.getPath()));
            }
            if (!kfile.canRead()) {
                throw new CommandValidationException(
                        Strings.get("key.path.not.readable",
                        kfile.getPath(), System.getProperty("user.name")));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.api.admin.CommandValidationException

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.