Search in sources :

Example 1 with CLICommand

use of com.sun.enterprise.admin.cli.CLICommand in project Payara by payara.

the class ChangeMasterPasswordCommand method executeCommand.

@Override
protected int executeCommand() throws CommandException {
    CLICommand command = null;
    if (domainDirParam != null && nodeDir != null) {
        throw new CommandException(strings.get("both.domaindir.nodedir.not.allowed"));
    }
    try {
        if (isDomain()) {
            // is it domain
            command = CLICommand.getCommand(habitat, CHANGE_MASTER_PASSWORD_DAS);
            return command.execute(argv);
        }
        if (nodeDir != null) {
            command = CLICommand.getCommand(habitat, CHANGE_MASTER_PASSWORD_NODE);
            return command.execute(argv);
        } else {
            // nodeDir is not specified and domainNameOrNodeName is not a domain.
            // It could be a node
            // We add defaultNodeDir parameter to args
            ArrayList arguments = new ArrayList<String>(Arrays.asList(argv));
            arguments.remove(argv.length - 1);
            arguments.add("--nodedir");
            arguments.add(getDefaultNodesDirs().getAbsolutePath());
            arguments.add(domainNameOrNodeName);
            String[] newargs = (String[]) arguments.toArray(new String[arguments.size()]);
            command = CLICommand.getCommand(habitat, CHANGE_MASTER_PASSWORD_NODE);
            return command.execute(newargs);
        }
    } catch (IOException e) {
        throw new CommandException(e.getMessage(), e);
    }
}
Also used : CLICommand(com.sun.enterprise.admin.cli.CLICommand) ArrayList(java.util.ArrayList) CommandException(org.glassfish.api.admin.CommandException) IOException(java.io.IOException)

Example 2 with CLICommand

use of com.sun.enterprise.admin.cli.CLICommand in project Payara by payara.

the class RestartDomainCommand method dasNotRunning.

/**
 * If the server isn't running, try to start it.
 */
@Override
protected int dasNotRunning() throws CommandException {
    if (!isLocal())
        throw new CommandException(Strings.get("restart.dasNotRunningNoRestart"));
    logger.warning(strings.get("restart.dasNotRunning"));
    CLICommand cmd = habitat.getService(CLICommand.class, "start-domain");
    /*
         * Collect the arguments that also apply to start-domain.
         * The start-domain CLICommand object will already have the
         * ProgramOptions injected into it so we don't need to worry
         * about them here.
         *
         * Usage: asadmin [asadmin-utility-options] start-domain
         *      [-v|--verbose[=<verbose(default:false)>]]
         *      [--upgrade[=<upgrade(default:false)>]]
         *      [--debug[=<debug(default:false)>]] [--domaindir <domaindir>]
         *      [-?|--help[=<help(default:false)>]] [domain_name]
         *
         * Only --debug, --domaindir, and the operand apply here.
         */
    List<String> opts = new ArrayList<String>();
    opts.add("start-domain");
    if (debug != null) {
        opts.add("--debug");
        opts.add(debug.toString());
    }
    if (domainDirParam != null) {
        opts.add("--domaindir");
        opts.add(domainDirParam);
    // XXX - would this be better?
    // opts.add(getDomainRootDir().toString());
    }
    if (getDomainName() != null)
        opts.add(getDomainName());
    return cmd.execute(opts.toArray(new String[opts.size()]));
}
Also used : CLICommand(com.sun.enterprise.admin.cli.CLICommand)

Aggregations

CLICommand (com.sun.enterprise.admin.cli.CLICommand)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CommandException (org.glassfish.api.admin.CommandException)1