Package com.izforge.izpack.util

Examples of com.izforge.izpack.util.VariableSubstitutor


            threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(Util.RESOLVE_THREAD_POOL_SIZE);
            threadPool.setThreadFactory(new TaskThreadFactory());
            observer.setThreadPoolExecutors(threadPool);
        }

        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());

        // In some cases the execd spool dir does not get substituted
        idata.setVariable(VAR_EXECD_SPOOL_DIR, vs.substituteMultiple(idata.getVariable(VAR_EXECD_SPOOL_DIR), null));

        // cfg.db.spooling.dir
        String spoolingDir = "";
        if (idata.getVariable(VAR_SPOOLING_METHOD).equals("berkeleydb")) {
            spoolingDir = idata.getVariable(VAR_DB_SPOOLING_DIR_BDB);
        } else {
            spoolingDir = idata.getVariable(VAR_DB_SPOOLING_DIR_BDBSERVER);
        }
        idata.setVariable(VAR_DB_SPOOLING_DIR, vs.substituteMultiple(spoolingDir, null));

        // Substitute the variables in Host.State tooltips
        String key = "";
        String value = "";
        Host.State.localizedTexts.clear();
       
        if (idata.langpack != null) {
            if (isExpressInst) {
                idata.setVariable("tooltip.hint", idata.langpack.getString("express.mode.tooltip.hint"));
            } else {
                idata.setVariable("tooltip.hint", "");
            }
           
            Set<String> keys = idata.langpack.keySet();
            for (Iterator<String> it = keys.iterator(); it.hasNext();) {
                key = it.next();
                value = vs.substituteMultiple((String) idata.langpack.get(key), null);
                if (key.startsWith(LANGID_PREFIX_STATE)) {
                    Host.State.localizedTexts.put(key, value);
                }
            }

            // override the tooltip for perm_execd_spool_dir state dependig in the mode
            if (isExpressInst) {
                value = vs.substituteMultiple((String) idata.langpack.get("state.perm_execd_spool_dir.tooltip.global"), null);
            } else {
                value = vs.substituteMultiple((String) idata.langpack.get("state.perm_execd_spool_dir.tooltip.local"), null);
            }
            Host.State.localizedTexts.put("state.perm_execd_spool_dir.tooltip", value);
        }

        // Initialize the table(s) with the qmaster and the Berkeley DB host if it's necessary
        if (true) {
            try {
                boolean isQmasterExist = HostSelectionTableModel.getQmasterHost() != null;
                boolean isBdbExist = HostSelectionTableModel.getBdbHost() != null;
                enablePrevButton(false);

                ArrayList<String> host = new ArrayList<String>();
                Properties prop = new Properties();
                String arch = "";
                String message = "";
                if (isQmasterInst && !isQmasterExist) {
                    if (!idata.getVariable(VAR_QMASTER_HOST).equals("")) {
                        host.add(idata.getVariable(VAR_QMASTER_HOST));

                        resolveHosts(Host.Type.HOSTNAME, host, true, false, (isShadowdInst == true) ? true : false, false, true, true, idata.getVariable(VAR_EXECD_SPOOL_DIR));

                        if (HostSelectionTableModel.getQmasterHost() == null) {
                            try {
                                arch = lists.get(0).get(0).getArchitecture();
                            } finally {
                                prop.setProperty(PARAMETER_1, arch);
                            }

                            if (!arch.equals("")) {
                                vs = new VariableSubstitutor(prop);
                                message = vs.substituteMultiple(idata.langpack.getString("warning.qmaster.arch.unsupported.message"), null);
                                emitWarning(idata.langpack.getString("installer.warning"), message);
                            }
                        }
                    }
                }
                host.clear();

                if (isBdbInst && !isBdbExist) {
                    if (idata.getVariable(VAR_DB_SPOOLING_SERVER).equals("")) {
                        host.add(Host.localHostName); // TODO localhost or qmaster host ?
                    } else {
                        host.add(idata.getVariable(VAR_DB_SPOOLING_SERVER));
                    }
                    resolveHosts(Host.Type.HOSTNAME, host, false, true, false, false, false, false, idata.getVariable(VAR_EXECD_SPOOL_DIR));

                    if (HostSelectionTableModel.getBdbHost() == null) {
                        try {
                            arch = lists.get(0).get(0).getArchitecture();
                        } finally {
                            prop.setProperty(PARAMETER_1, arch);
                        }

                        if (!arch.equals("")) {
                            vs = new VariableSubstitutor(prop);
                            message = vs.substituteMultiple(idata.langpack.getString("warning.bdbserver.arch.unsupported.message"), null);
                            emitWarning(idata.langpack.getString("installer.warning"), message);
                        }
                    }
                }
View Full Code Here


            key = key + "." + TOOLTIP;
        }

        String tooltip = getString(key);

        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
        tooltip = vs.substituteMultiple(tooltip, null);

        if (tooltip.equals(key)) {
            tooltip = null;
        }
View Full Code Here

    /**
     * Makes some fixes on the variables. Should be used right before the installation.
     */
    private void fixVariables() {
        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
        String variable = "";

        // cfg.spooling.method.berkeleydbserver
        variable = idata.getVariable(VAR_SPOOLING_METHOD_BERKELEYDBSERVER);
        if (variable.equals("none")) {
View Full Code Here

        }
        if (!forced && numOfQmasterHost == 0 && numOfExecdHost == 0 && numOfShadowHost == 0 && numOfBdbHost == 0) {
            String message;
            int res=JOptionPane.YES_OPTION;
            if (numOthers > 0) {
                message = new VariableSubstitutor(idata.getVariables()).substituteMultiple(idata.langpack.getString("warning.only.admin.submit.to.install.message"), null);
                res=JOptionPane.showOptionDialog(this, message, getLabel("installer.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null,
                                                 new Object[]{getLabel("installer.yes"), getLabel("installer.no")}, getLabel("installer.no"));
            } else {
                message = new VariableSubstitutor(idata.getVariables()).substituteMultiple(idata.langpack.getString("warning.no.components.to.install.message"), null);
                JOptionPane.showOptionDialog(this, message, getLabel("installer.error"),
                    JOptionPane.CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null,
                    new Object[]{getLabel("installer.cancel")}, getLabel("installer.cancel"));
                res = JOptionPane.NO_OPTION;
            }

            //If Cancel or No, we don't proceed with the installation
            if (res == JOptionPane.NO_OPTION) {
                checkMode = false;
                disableControls(false);
                enableBrowseButtons(true);
                setTablesEnabled(true);
                return;
            }
        }

        // Compare host selection with the component selection if does not match warn user
        String componentString = "";
        String hostTypeString = "";

        if (isQmasterInst && numOfQmasterHost == 0) {
            componentString = getLabel("install.qmaster.label");
            hostTypeString = getLabel("column.qmaster.label");
        } else if (isExecdInst && numOfExecdHost == 0) {
            componentString = getLabel("install.execd.label");
            hostTypeString = getLabel("column.execd.label");
        } else if (isShadowdInst && numOfShadowHost == 0) {
            componentString = getLabel("install.shadowd.label");
            hostTypeString = getLabel("column.shadowd.label");
        } else if (isBdbInst && numOfBdbHost == 0) {
            componentString = getLabel("install.bdb.label");
            hostTypeString = getLabel("column.bdb.label");
        }

        if (!forced && !componentString.equals("")) {
            Properties props = new Properties();
            props.put("component", componentString);
            props.put("host.type", hostTypeString);

            VariableSubstitutor vs = new VariableSubstitutor(props);

            if (JOptionPane.NO_OPTION == JOptionPane.showOptionDialog(this, vs.substituteMultiple(getLabel("warning.comp.selected.but.no.host"), null),
                    getLabel("installer.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null,
                    new Object[]{getLabel("installer.yes"), getLabel("installer.no")}, getLabel("installer.no"))) {
               
                checkMode = false;
                disableControls(false);
View Full Code Here

                }
            }
        }

        // Construct the file names
        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());

        String autoConfTempFile = vs.substituteMultiple(idata.getVariable(VAR_AUTO_CONF_TEMP_FILE), null);
        String autoConfFile = vs.substituteMultiple(idata.getVariable(VAR_AUTO_CONF_FILE), null);

        autoConfFile = autoConfFile + "_" + Util.generateTimeStamp();

        //Set global values
        idata.setVariable(VAR_QMASTER_CONNECT_USER, qmasterConnectUser);
View Full Code Here

        initializeVariables();
    }

    protected void initializeVariables() {
        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());

        /**
         * Read arguments
         */
        // set thread spool sizes
        int size = 0;
        if (idata.getVariable(ARG_RESOLVE_THREAD_POOL_SIZE) != null) {
            try {
                size = Integer.valueOf(idata.getVariable(ARG_RESOLVE_THREAD_POOL_SIZE));
                if (size < 1) {
                    throw new NumberFormatException();
                }
                Util.RESOLVE_THREAD_POOL_SIZE = size;
            } catch (NumberFormatException e) {
                Debug.error("Invalid '" + ARG_RESOLVE_THREAD_POOL_SIZE + "' value: " + idata.getVariable(ARG_RESOLVE_THREAD_POOL_SIZE));
            } finally {
                Debug.trace(ARG_RESOLVE_THREAD_POOL_SIZE + " is now set to " + Util.RESOLVE_THREAD_POOL_SIZE);
            }
        }
        if (idata.getVariable(ARG_INSTALL_THREAD_POOL_SIZE) != null) {
            try {
                size = Integer.valueOf(idata.getVariable(ARG_INSTALL_THREAD_POOL_SIZE));
                if (size < 1) {
                    throw new NumberFormatException();
                }
                Util.INSTALL_THREAD_POOL_SIZE = size;
            } catch (NumberFormatException e) {
                Debug.error("Invalid '" + ARG_INSTALL_THREAD_POOL_SIZE + "' value: " + idata.getVariable(ARG_INSTALL_THREAD_POOL_SIZE));
            } finally {
                Debug.trace(ARG_INSTALL_THREAD_POOL_SIZE + " is now set to " + Util.INSTALL_THREAD_POOL_SIZE);
            }
        }
        //Set the timeout values
        if (idata.getVariable(ARG_RESOLVE_TIMEOUT) != null) {
            try {
                size = Integer.valueOf(idata.getVariable(ARG_RESOLVE_TIMEOUT));
                if (size < 1) {
                    throw new NumberFormatException();
                }
                Util.DEF_RESOLVE_TIMEOUT = size * 1000; //we need ms not seconds
            } catch (NumberFormatException e) {
                Debug.error("Invalid '" + ARG_RESOLVE_TIMEOUT + "' value: " + idata.getVariable(ARG_RESOLVE_THREAD_POOL_SIZE));
            } finally {
                Debug.trace(ARG_RESOLVE_TIMEOUT + " is now set to " + Util.DEF_RESOLVE_TIMEOUT);
            }
        }
        if (idata.getVariable(ARG_INSTALL_TIMEOUT) != null) {
            try {
                size = Integer.valueOf(idata.getVariable(ARG_INSTALL_TIMEOUT));
                if (size < 1) {
                    throw new NumberFormatException();
                }
                Util.DEF_INSTALL_TIMEOUT = size * 1000; //we need ms not seconds
            } catch (NumberFormatException e) {
                Debug.error("Invalid '" + ARG_INSTALL_TIMEOUT + "' value: " + idata.getVariable(ARG_INSTALL_THREAD_POOL_SIZE));
            } finally {
                Debug.trace(ARG_INSTALL_TIMEOUT + " is now set to " + Util.DEF_INSTALL_TIMEOUT);
            }
        }
        // Set connect_mode
        String mode = idata.getVariable(ARG_CONNECT_MODE);
        Util.IS_MODE_WINDOWS = (mode != null && mode.equalsIgnoreCase(CONST_MODE_WINDOWS));
        if (Util.IS_MODE_WINDOWS) {
           Debug.trace("Using mode '" + CONST_MODE_WINDOWS + "'.");
        }
        // Set connect_user
        Util.DEF_CONNECT_USER = vs.substituteMultiple(idata.getVariable(ARG_CONNECT_USER), null);
        Debug.trace("Using connect user '" + Util.DEF_CONNECT_USER + "'.");

        /**
         * Other initializations
         */
        String sgeRootPath = vs.substituteMultiple(idata.getVariable(VAR_SGE_ROOT), null);
        String userName = vs.substituteMultiple(idata.getVariable(VAR_USER_NAME), null);

        ExtendedFile sgeRootDir = new ExtendedFile(sgeRootPath);

        Debug.trace(sgeRootDir.getPermissions() + " " + sgeRootDir.getOwner() + " " + sgeRootDir.getGroup() + " " + sgeRootPath);

        // cfg.admin.user
        idata.setVariable(VAR_ADMIN_USER, sgeRootDir.getOwner());
        Debug.trace("cfg.admin.user='" + idata.getVariable(VAR_ADMIN_USER) + "'");

        // set cfg.add.to.rc
        if (vs.substituteMultiple(idata.getVariable(VAR_USER_NAME),null).equals(idata.getVariable(VAR_ROOT_USER)) ||
                !vs.substituteMultiple(idata.getVariable(VAR_CONNECT_USER), null).equals(vs.substituteMultiple(idata.getVariable(VAR_USER_NAME), null))) {
            idata.setVariable(VAR_ADD_TO_RC, "true");
        } else {
            idata.setVariable(VAR_ADD_TO_RC, "false");
        }

View Full Code Here

        File f = new File(file);
       
        if (client.hasParams()) {
          Map<String, String> params = client.getValidatorParams();
            VariableSubstitutor vs = new VariableSubstitutor(GUIInstaller.getInstallData().getVariables());
            String dirPrefix = "";
            String fileSuffix = "";

            if (params.containsKey(PARAM_DIR)) {
                dirPrefix = params.get(PARAM_DIR);
                dirPrefix = vs.substituteMultiple(dirPrefix, null);

                if (!dirPrefix.endsWith(FileHandler.SEPARATOR)) {
                    dirPrefix = dirPrefix + FileHandler.SEPARATOR;
                }
            }

          if (params.containsKey(PARAM_FILE)) {
                fileSuffix = params.get(PARAM_FILE);
                fileSuffix = vs.substituteMultiple(fileSuffix, null);

               if (!fileSuffix.startsWith(FileHandler.SEPARATOR)) {
                    fileSuffix = FileHandler.SEPARATOR + fileSuffix;
               }
            }
View Full Code Here

    /**
     * Loads the info text.
     */
    private void loadResult() {
        try {
            VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
            readmeTemplatePath = vs.substituteMultiple(idata.getVariable(VAR_README_TEMP_FILE), null);

            readmePath = vs.substituteMultiple(idata.getVariable(VAR_README_FILE_NAME_1), null);
            readmePath += "_" + Util.generateTimeStamp() + ".html";
            //TODO: Detect whole cluster settings
            // Features - bootstrap (CSP, AFS, JMX)
            // spooling - bootstrap (BDB server, bdb, classic)
            // qmaster - act_qmaster
            // shadowds - shadow_masters
            // execd - qconf -sel
            // submit hosts - qconf -ss
            // admin hosts - qconf -sh
            Util.fillUpTemplate(readmeTemplatePath, readmePath, idata.getVariables(), new String[]{"<!--", "/*", "*", "-->"}, true);
            Debug.trace("Generating readme.html file: '" + readmePath + "'.");

            editorPane.setPage("file://" + readmePath);

            String  readmePath2 = vs.substituteMultiple(idata.getVariable(VAR_README_FILE_NAME_2), null);
            readmePath2 += "_" + Util.generateTimeStamp() + ".html";

            Util.fillUpTemplate(readmeTemplatePath, readmePath2, idata.getVariables(), new String[]{"<!--", "/*", "*"}, true);
        } catch (Exception e) {
            Debug.error("Can not generate readme file! " + e);
View Full Code Here

                    return true;
                }

                // Get fs type
                Properties variables = GUIInstaller.getInstallData().getVariables();
                VariableSubstitutor vs = new VariableSubstitutor(variables);
                String sge_root = vs.substituteMultiple(variables.getProperty(Config.VAR_SGE_ROOT, ""), null);
                dir = vs.substituteMultiple(dir, null);
               
                String fsType = Util.getDirFSType(variables.getProperty(Config.VAR_SHELL_NAME, ""), sge_root, dir);

                /**
                 * Validate
 
View Full Code Here

            }
        }

        // if we have a message set, show it and return false
        if (!message.equals("")) {
            message = new VariableSubstitutor(idata.getVariables()).substituteMultiple(message, null);

            JOptionPane.showOptionDialog(this, message, getLabel("installer.error"),
                    JOptionPane.CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null,
                    new Object[]{getLabel("installer.cancel")}, getLabel("installer.cancel"));
View Full Code Here

TOP

Related Classes of com.izforge.izpack.util.VariableSubstitutor

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.