Package org.glassfish.api.admin

Examples of org.glassfish.api.admin.ParameterMap


    public ActionReportResult get() {
        return options();
    }

    private static ParameterMap createDataBasedOnForm(FormDataMultiPart formData) {
        ParameterMap data = new ParameterMap();
        try {
            Map<String, List<FormDataBodyPart>> m1 = formData.getFields();

            Set<String> ss = m1.keySet();
            for (String fieldName : ss) {
                for (FormDataBodyPart bodyPart : formData.getFields(fieldName)) {

                    if (bodyPart.getContentDisposition().getFileName() != null) {//we have a file
                        //save it and mark it as delete on exit.
                        InputStream fileStream = bodyPart.getValueAs(InputStream.class);
                        String mimeType = bodyPart.getMediaType().toString();

                        //Use just the filename without complete path. File creation
                        //in case of remote deployment failing because fo this.
                        String fileName = bodyPart.getContentDisposition().getFileName();
                        if (fileName.contains("/")) {
                            fileName = Util.getName(fileName, '/');
                        } else {
                            if (fileName.contains("\\")) {
                                fileName = Util.getName(fileName, '\\');
                            }
                        }

                        File f = Util.saveFile(fileName, mimeType, fileStream);
                        f.deleteOnExit();
                        //put only the local path of the file in the same field.
                        data.add(fieldName, f.getAbsolutePath());
                    } else {
                        data.add(fieldName, bodyPart.getValue());
                    }
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(TemplateCommandPostResource.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here


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

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

        for(PathSegment pathSegment :  candidatePathSegment) {
            sb.append(pathSegment.getPath());
            sb.append('.');
        }
        String setBasePath = sb.toString();
        ParameterMap parameters = new ParameterMap();
        Map<String, String> currentValues = getCurrentValues(setBasePath, habitat);

        for (Map.Entry<String, String> entry : data.entrySet()) {
            String currentValue = currentValues.get(setBasePath + entry.getKey());
            if ((currentValue == null) || entry.getValue().equals("") || (!currentValue.equals(entry.getValue()))) {
                parameters.add("DEFAULT", setBasePath + entry.getKey() + "=" + entry.getValue());
            }
        }
        if (!parameters.entrySet().isEmpty()) {
           return ResourceUtil.runCommand("set", parameters, habitat, ""); //TODO The last parameter is resultType and is not used. Refactor the called method to remove it
        } else {
            return new RestActionReporter(); // noop
        }
    }
View Full Code Here

    }

    private static Map<String, String> getCurrentValues(String basePath, Habitat habitat) {
        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);
        }}, habitat, "");

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

     * @return true/false depending on the outcome of the operation
     * @throws org.glassfish.deployment.autodeploy.AutoDeploymentException
     */
    final AutodeploymentStatus run() throws AutoDeploymentException {
        try {
            ParameterMap p = new ParameterMap();
            for (Map.Entry<Object,Object> entry : props.entrySet())
                p.set((String)entry.getKey(), (String)entry.getValue());
            ActionReport report = commandRunner.getActionReport("hk2-agent");
            CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation(commandName, report);
            inv.parameters(p).execute(command);
            AutodeploymentStatus ds = AutodeploymentStatus.forExitCode(report.getActionExitCode());
            Level messageLevel = (ds.status ? Level.INFO : Level.WARNING);
View Full Code Here

                            PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(pool);
                            CommandRunner commandRunner = habitat.getComponent(CommandRunner.class);
                            ActionReport report = habitat.getComponent(ActionReport.class);
                            CommandRunner.CommandInvocation invocation =
                                    commandRunner.getCommandInvocation("ping-connection-pool", report);
                            ParameterMap params = new ParameterMap();
                            params.add("appname",poolInfo.getApplicationName());
                            params.add("modulename",poolInfo.getModuleName());
                            params.add("DEFAULT", poolInfo.getName());
                            invocation.parameters(params).execute();
                            if(report.getActionExitCode() == ActionReport.ExitCode.SUCCESS){
                                _logger.log(Level.INFO, "app-scoped.ping.connection.pool.success", poolInfo);
                            }else{
                                Object args[] = new Object[]{poolInfo, report.getFailureCause()};
View Full Code Here

                 * Parse all the admin options, stopping at the first
                 * non-option, which is the command name.
                 */
                Parser rcp = new Parser(argv, 0,
                        ProgramOptions.getValidOptions(), false);
                ParameterMap params = rcp.getOptions();
                po = new ProgramOptions(params, env);
                readAndMergeOptionsFromAuxInput(po);
                List<String> operands = rcp.getOperands();
                argv = operands.toArray(new String[operands.size()]);
            } else {
View Full Code Here

            throws CommandException {
        final String auxInput = progOpts.getAuxInput();
        if (auxInput == null || auxInput.length() == 0) {
            return;
        }
        final ParameterMap newParamMap = new ParameterMap();
        /*
         * We will place the options passed via the aux. input on the command
         * line and we do not want to repeat the read from stdin again, so
         * remove the aux input setting.
         */
        progOpts.setAuxInput(null);
        try {
            final AsadminInput.InputReader reader = AsadminInput.reader(auxInput);
            final Properties newOptions = reader.settings().get("option");
            for (String propName : newOptions.stringPropertyNames()) {
                newParamMap.add(propName, newOptions.getProperty(propName));
            }
            progOpts.updateOptions(newParamMap);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        ParameterMap info = new ParameterMap();

        if (uninstall) {
            //store needed info for uninstall
            SshConnector sshC = node.getSshConnector();
            SshAuth sshAuth = sshC.getSshAuth();

            if (sshAuth.getPassword() != null)
                info.add(NodeUtils.PARAM_REMOTEPASSWORD, sshAuth.getPassword());

            if (sshAuth.getKeyPassphrase() != null)
                info.add(NodeUtils.PARAM_SSHKEYPASSPHRASE, sshAuth.getKeyPassphrase());

            if (sshAuth.getKeyfile() != null)
                info.add(NodeUtils.PARAM_SSHKEYFILE, sshAuth.getKeyfile());

            info.add(NodeUtils.PARAM_INSTALLDIR, node.getInstallDir());
            info.add(NodeUtils.PARAM_REMOTEPORT, sshC.getSshPort());
            info.add(NodeUtils.PARAM_REMOTEUSER, sshAuth.getUserName());
            info.add(NodeUtils.PARAM_NODEHOST, node.getNodeHost());
            info.add(NodeUtils.PARAM_WINDOWS_DOMAIN, node.getWindowsDomain());
        }

        CommandInvocation ci = cr.getCommandInvocation("_delete-node", report);
        ParameterMap map = new ParameterMap();
        map.add("DEFAULT", name);
        ci.parameters(map);
        ci.execute();

        //uninstall GlassFish after deleting the node
        if (uninstall) {
View Full Code Here

            logger.info(Strings.get("stop.instance.init", instanceName));
            RemoteAdminCommand rac = new ServerRemoteAdminCommand(habitat, "_stop-instance",
                    host, port, false, "admin", null, logger);

            // notice how we do NOT send in the instance's name as an operand!!
            ParameterMap map = new ParameterMap();
            map.add("force", Boolean.toString(force));
            rac.executeCommand(map);
        }
        catch (CommandException ex) {
            return Strings.get("stop.instance.racError", instanceName,
                    ex.getLocalizedMessage());
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.