Search in sources :

Example 6 with ParamModelData

use of com.sun.enterprise.admin.util.CommandModelData.ParamModelData in project Payara by payara.

the class RemoteCLICommand method prepare.

@Override
protected void prepare() throws CommandException, CommandValidationException {
    try {
        processProgramOptions();
        initializeAuth();
        /*
             * Now we have all the information we need to create
             * the remote admin command object.
             */
        initializeRemoteAdminCommand();
        if (responseFormatType != null) {
            rac.setResponseFormatType(responseFormatType);
        }
        if (userOut != null) {
            rac.setUserOut(userOut);
        }
        /*
             * Initialize a CookieManager so that we can retreive
             * any cookies included in the reply.   These cookies
             * (e.g. JSESSIONID, JROUTE) are used for CLI session
             * based routing.
             */
        initializeCookieManager();
        /*
             * If this is a help request, we don't need the command
             * metadata and we throw away all the other options and
             * fake everything else.
             */
        if (programOpts.isHelp()) {
            CommandModelData cm = new CommandModelData(name);
            cm.add(new ParamModelData("help", boolean.class, true, "false", "?"));
            this.commandModel = cm;
            rac.setCommandModel(cm);
            return;
        }
        /*
             * Find the metadata for the command.
             */
        commandModel = rac.getCommandModel();
    } catch (CommandException cex) {
        if (logger.isLoggable(Level.FINER))
            logger.finer("RemoteCommand.prepare throws " + cex);
        throw cex;
    } catch (Exception e) {
        if (logger.isLoggable(Level.FINER))
            logger.finer("RemoteCommand.prepare throws " + e);
        throw new CommandException(e.getMessage());
    }
}
Also used : CommandModelData(com.sun.enterprise.admin.util.CommandModelData) ParamModelData(com.sun.enterprise.admin.util.CommandModelData.ParamModelData) CommandException(org.glassfish.api.admin.CommandException) StoreException(com.sun.appserv.management.client.prefs.StoreException) CommandException(org.glassfish.api.admin.CommandException) CommandValidationException(org.glassfish.api.admin.CommandValidationException)

Example 7 with ParamModelData

use of com.sun.enterprise.admin.util.CommandModelData.ParamModelData in project Payara by payara.

the class CreateDomainCommand method usageOptions.

/**
 * Add --adminport and --instanceport options with proper default values.
 * (Can't set default values above because it conflicts with --portbase
 * option processing.)
 */
@Override
protected Collection<ParamModel> usageOptions() {
    Collection<ParamModel> opts = commandModel.getParameters();
    Set<ParamModel> uopts = new LinkedHashSet<ParamModel>();
    ParamModel aPort = new ParamModelData(ADMIN_PORT, String.class, true, Integer.toString(CLIConstants.DEFAULT_ADMIN_PORT));
    ParamModel iPort = new ParamModelData(INSTANCE_PORT, String.class, true, Integer.toString(DEFAULT_INSTANCE_PORT));
    for (ParamModel pm : opts) {
        if (pm.getName().equals(ADMIN_PORT)) {
            uopts.add(aPort);
        } else if (pm.getName().equals(INSTANCE_PORT)) {
            uopts.add(iPort);
        } else {
            uopts.add(pm);
        }
    }
    return uopts;
}
Also used : ParamModel(org.glassfish.api.admin.CommandModel.ParamModel) ParamModelData(com.sun.enterprise.admin.util.CommandModelData.ParamModelData)

Example 8 with ParamModelData

use of com.sun.enterprise.admin.util.CommandModelData.ParamModelData in project Payara by payara.

the class ProgramOptions method addMetaOption.

/**
 * Helper method to define a meta-option.
 *
 * @param name  long option name
 * @param sname short option name
 * @param type  option type (String.class, Boolean.class, etc.)
 * @param req   is option required?
 * @param def   default value for option
 */
private static void addMetaOption(Set<ParamModel> opts, String name, char sname, Class type, boolean req, String def) {
    ParamModel opt = new ParamModelData(name, type, !req, def, Character.toString(sname));
    opts.add(opt);
}
Also used : ParamModel(org.glassfish.api.admin.CommandModel.ParamModel) ParamModelData(com.sun.enterprise.admin.util.CommandModelData.ParamModelData)

Example 9 with ParamModelData

use of com.sun.enterprise.admin.util.CommandModelData.ParamModelData in project Payara by payara.

the class RemoteCommand method prepare.

@Override
protected void prepare() throws CommandException, CommandValidationException {
    try {
        processProgramOptions();
        initializeAuth();
        /*
             * Now we have all the information we need to create
             * the remote admin command object.
             */
        initializeRemoteAdminCommand();
        if (responseFormatType != null) {
            rac.setResponseFormatType(responseFormatType);
        }
        if (userOut != null) {
            rac.setUserOut(userOut);
        }
        /*
             * Initialize a CookieManager so that we can retreive
             * any cookies included in the reply.   These cookies
             * (e.g. JSESSIONID, JROUTE) are used for CLI session
             * based routing.
             */
        initializeCookieManager();
        /*
             * If this is a help request, we don't need the command
             * metadata and we throw away all the other options and
             * fake everything else.
             */
        if (programOpts.isHelp()) {
            commandModel = helpModel();
            rac.setCommandModel(commandModel);
            return;
        }
        /*
             * Find the metadata for the command.
             */
        commandModel = rac.getCommandModel();
        if (programOpts.isNotifyCommand()) {
            commandModel.add(new ParamModelData("notify", boolean.class, true, "false"));
        }
    } catch (CommandException cex) {
        if (logger.isLoggable(Level.FINER))
            logger.finer("RemoteCommand.prepare throws " + cex);
        throw cex;
    } catch (Exception e) {
        if (logger.isLoggable(Level.FINER))
            logger.finer("RemoteCommand.prepare throws " + e);
        throw new CommandException(e.getMessage());
    }
}
Also used : ParamModelData(com.sun.enterprise.admin.util.CommandModelData.ParamModelData) StoreException(com.sun.appserv.management.client.prefs.StoreException)

Example 10 with ParamModelData

use of com.sun.enterprise.admin.util.CommandModelData.ParamModelData in project Payara by payara.

the class RemoteCommand method helpModel.

/**
 * Return a CommandModel that only includes the --help option.
 */
private CommandModel helpModel() {
    CommandModelData cm = new CommandModelData(name);
    cm.add(new ParamModelData("help", boolean.class, true, "false", "?"));
    return cm;
}
Also used : ParamModelData(com.sun.enterprise.admin.util.CommandModelData.ParamModelData)

Aggregations

ParamModelData (com.sun.enterprise.admin.util.CommandModelData.ParamModelData)15 CachedCommandModel (com.sun.enterprise.admin.util.CachedCommandModel)3 File (java.io.File)3 ParamModel (org.glassfish.api.admin.CommandModel.ParamModel)3 StoreException (com.sun.appserv.management.client.prefs.StoreException)2 SmartFile (com.sun.enterprise.universal.io.SmartFile)2 CommandException (org.glassfish.api.admin.CommandException)2 CommandModelData (com.sun.enterprise.admin.util.CommandModelData)1 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 JsonArray (javax.json.JsonArray)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObject (javax.json.JsonObject)1 JsonValue (javax.json.JsonValue)1 JsonParser (javax.json.stream.JsonParser)1 SSLException (javax.net.ssl.SSLException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1