Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.ParameterMap


     */
    public ActionReport runCommand(String commandName,
            HashMap<String, String> parameters, Habitat habitat) {
        CommandRunner cr = habitat.getComponent(CommandRunner.class);
        ActionReport ar = habitat.getComponent(ActionReport.class);
        ParameterMap p = new ParameterMap();
        for (Map.Entry<String,String> entry : parameters.entrySet())
            p.set(entry.getKey(), entry.getValue());

        cr.getCommandInvocation(commandName, ar).parameters(p).execute();
        return ar;
    }
View Full Code Here


    */
    public ActionReport runCommand(String commandName,
           Properties parameters, Habitat habitat) {
       CommandRunner cr = habitat.getComponent(CommandRunner.class);
       ActionReport ar = habitat.getComponent(ActionReport.class);
        ParameterMap p = new ParameterMap();
        for (String prop : parameters.stringPropertyNames())
            p.set(prop, parameters.getProperty(prop));

       cr.getCommandInvocation(commandName, ar).parameters(p).execute();
       return ar;
    }
View Full Code Here

        // ensure we don't already have one of this name before creating it.
        for (JmsHost jmsHost : jmsservice.getJmsHost()) {
                if (jmsHostName.equals(jmsHost.getName())) {
                    if (force) {
                        ActionReport deleteReport = report.addSubActionsReport();
                        ParameterMap parameters = new ParameterMap();
                         parameters.set("DEFAULT", jmsHostName);
                         parameters.set("target", target);
                        commandRunner.getCommandInvocation("delete-jms-host", deleteReport, context.getSubject()).parameters(parameters).execute();
                        if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
                            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                            return;
                        }
View Full Code Here

        }

        // Filter out the global options.
        // We are interested only in --passwordfile option. No other options are relevant when GlassFish is running in embedded mode.
        Parser parser = new Parser(args, 0, ProgramOptions.getValidOptions(), true);
        ParameterMap globalOptions = parser.getOptions();
        List<String> operands = parser.getOperands();
        String argv[] = operands.toArray(new String[operands.size()]);

        parser = new Parser(argv, 0, commandModel.getParameters(), false);
        ParameterMap options = parser.getOptions();
        operands = parser.getOperands();
        options.set("DEFAULT", operands);
        // if command has a "terse" option, set it in options
        if (commandModel.getModelFor("terse") != null)
            options.set("terse", Boolean.toString(terse));

        // Read the passwords from the password file and set it in command options.
        if (globalOptions.size() > 0) {
            String pwfile = globalOptions.getOne(ProgramOptions.PASSWORDFILE);
            if (pwfile != null && pwfile.length() > 0) {
                Map<String, String> passwords = CLIUtil.readPasswordFileOptions(pwfile, true);
                for (CommandModel.ParamModel opt : commandModel.getParameters()) {
                    if (opt.getParam().password()) {
                        String pwdname = opt.getName();
                        String pwd = passwords.get(pwdname);
                        if (pwd != null) {
                            options.set(pwdname, pwd);
                        }
                    }
                }
            }
        }
View Full Code Here

     * @param args
     * @return
     * @throws CommandException
     */
    /* package */ ActionReport executeCommand(String command, String... args) throws CommandException {
        ParameterMap commandParams = getParameters(command, args);
        final ActionReport actionReport = createActionReport();

        org.glassfish.api.admin.CommandRunner.CommandInvocation inv =
                commandRunner.getCommandInvocation(command, actionReport, embeddedSystemAdministrator.getSubject());

View Full Code Here

                        }
                    }
                }
                if (destExists) {
                    ActionReport deleteReport = report.addSubActionsReport();
                    ParameterMap parameters = new ParameterMap();
                    parameters.set("DEFAULT", destName);
                    parameters.set("destType", destType);
                    parameters.set("target", target);
                    commandRunner.getCommandInvocation("delete-jmsdest", deleteReport, subject).parameters(parameters).execute();
                    if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        return;
                    }
View Full Code Here

        newParams[params.length] = file.getAbsolutePath();
        CommandExecutorImpl executer = habitat.getService(CommandExecutorImpl.class);
        try {
            String command = "deploy";
            ActionReport actionReport = executer.createActionReport();
            ParameterMap commandParams = executer.getParameters(command, newParams);
            org.glassfish.api.admin.CommandRunner.CommandInvocation inv =
                    executer.getCommandRunner().getCommandInvocation(command, actionReport, kernelIdentity.getSubject());
            inv.parameters(commandParams);
            // set outputbound payload if --retrieve option is specified.
            Payload.Outbound outboundPayload = null;
            String retrieveOpt = commandParams.getOne("retrieve");
            File retrieve = retrieveOpt != null ? new File(retrieveOpt) : null;
            if (retrieve != null && retrieve.exists()) {
                outboundPayload = PayloadImpl.Outbound.newInstance();
                inv.outbound(outboundPayload);
            }
View Full Code Here

     * @return ActionReport object with command execute status details.
     */
    public static RestActionReporter runCommand(String commandName,
                                                Map<String, String> parameters,
                                                Subject subject) {
        ParameterMap p = new ParameterMap();
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            p.set(entry.getKey(), entry.getValue());
        }

        return runCommand(commandName, p, subject);
    }
View Full Code Here

    public static RestActionReporter applyChanges(Map<String, String> data, UriInfo uriInfo, Subject subject) {
        return applyChanges(data, getBasePathFromUri(uriInfo), subject);
    }

    public static RestActionReporter applyChanges(Map<String, String> data, String basePath, Subject subject) {
        ParameterMap parameters = new ParameterMap();
        Map<String, String> currentValues = getCurrentValues(basePath, subject);

        for (Map.Entry<String, String> entry : data.entrySet()) {
            String currentValue = currentValues.get(basePath + entry.getKey());
            if ((currentValue == null) || entry.getValue().equals("") || (!currentValue.equals(entry.getValue()))) {
                parameters.add("DEFAULT", basePath + entry.getKey() + "=" + entry.getValue());
            }
        }
        if (!parameters.entrySet().isEmpty()) {
           return ResourceUtil.runCommand("set", parameters, subject);
        } else {
            return new RestActionReporter(); // noop
        }
    }
View Full Code Here

    }

    public static Map<String, String> getCurrentValues(String basePath, ServiceLocator habitat, Subject subject) {
        Map<String, String> values = new HashMap<String, String>();
        final String path = (basePath.endsWith(".")) ? basePath.substring(0, basePath.length()-1) : basePath;
        RestActionReporter gr = ResourceUtil.runCommand("get", new ParameterMap() {{
            add ("DEFAULT", path);
        }}, subject);

        MessagePart top = gr.getTopMessagePart();
        for (MessagePart child : top.getChildren()) {
View Full Code Here

TOP

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

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.