Package com.izforge.izpack.util

Examples of com.izforge.izpack.util.VariableSubstitutor


                        // ('parsexml' was not enabled)
                        if (null == is)
                        {
                            is = new BufferedInputStream(originalUrl.openStream());
                        }
                        VariableSubstitutor vs = new VariableSubstitutor(compiler.getVariables());
                        vs.substitute(is, os, type, encoding);
                    }
                }

            }
            catch (Exception e)
View Full Code Here


                return false;
            }
            else
            {
                if (value != null) {
                    VariableSubstitutor vs = new VariableSubstitutor(installdata.getVariables());
                    value = vs.substituteMultiple(value, null);
                    val = vs.substituteMultiple(val, null);
                } else {
                    value = "";
                }
                return val.equals(value);
            }
View Full Code Here

                if (host.isBdbHost()) {
                }
            }

            VariableSubstitutor vs = new VariableSubstitutor(variables);

            // Fill up cfg.exec.spool.dir.local
            if (host.isExecutionHost() && !host.getSpoolDir().equals(variables.getProperty(VAR_EXECD_SPOOL_DIR))) {
                   variables.setProperty(VAR_EXECD_SPOOL_DIR_LOCAL, host.getSpoolDir());
            } else {
                variables.setProperty(VAR_EXECD_SPOOL_DIR_LOCAL, "");
            }

            // Fill up template file
            String checkHostTempFile = vs.substituteMultiple(variables.getProperty(VAR_CHECK_HOST_TEMP_FILE), null);
            String checkHostFile = vs.substituteMultiple(variables.getProperty(VAR_CHECK_HOST_FILE), null);
            String remoteFile = "";

            checkHostFile = "/tmp/" + checkHostFile + "." + host.getHostname() + ".tmp";
            Debug.trace("Generating check_host file: '" + checkHostFile + "'.");
View Full Code Here

        RemoteComponentScriptCommand installCmd = null;
        CopyExecutableCommand copyCmd = null;
       
        boolean isSpecialTask = Boolean.valueOf(variables.getProperty(VAR_FIRST_TASK, "false")) || Boolean.valueOf(variables.getProperty(VAR_LAST_TASK, "false"));
        VariableSubstitutor vs  = new VariableSubstitutor(variables);
        String log = "";

        try {
            String autoConfFile = null;
            String remoteFile = "";
            int exitValue;

            if (host.isBdbHost() || host.isQmasterHost() || host.isShadowHost() || host.isExecutionHost() || isSpecialTask) {
                if (!isSpecialTask) {
                    if (host.isQmasterHost()) {
                        // shadow host installation  is done in separate task
                        variables.put(VAR_SHADOW_HOST_LIST, "");
                    }

                    // Fill up cfg.exec.spool.dir.local
                    if (host.isExecutionHost() && !host.getSpoolDir().equals(variables.getProperty(VAR_EXECD_SPOOL_DIR))) {
                        variables.setProperty(VAR_EXECD_SPOOL_DIR_LOCAL, host.getSpoolDir());
                    } else {
                        variables.setProperty(VAR_EXECD_SPOOL_DIR_LOCAL, "");
                    }
                }

                String autoConfTempFile = vs.substituteMultiple(variables.getProperty(VAR_AUTO_INSTALL_COMPONENT_TEMP_FILE), null);
                autoConfFile = vs.substituteMultiple(variables.getProperty(VAR_AUTO_INSTALL_COMPONENT_FILE), null);

                //Appended CELL_NAME prevents a race in case of parallel multiple cell installations
                String taskName = isSpecialTask == true ? (Boolean.valueOf(variables.getProperty(VAR_FIRST_TASK, "false")).booleanValue() == true ? "first_task" : "last_task") : host.getComponentString();
                autoConfFile = "/tmp/" + autoConfFile + "." + host.getHostname() + "." + taskName + "." + variables.getProperty(VAR_SGE_CELL_NAME) + ".tmp";               
                Debug.trace("Generating auto_conf file: '" + autoConfFile + "'.");
View Full Code Here

    /**
     * Builds the panel
     */
    private void buildPanel() {
        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());

        // Draw the "Please wait..." text
        JLabel textLabel = new JLabel(vs.substituteMultiple(parent.langpack.getString("title.please.wait"), null));
        textLabel.setHorizontalAlignment(JLabel.CENTER);

        // Center the text
        IzPanelConstraints ipc = new IzPanelConstraints();
        ipc.setXStretch(1.0);
View Full Code Here

        isShadowdInst = isValueEqualsTrue(idata, VAR_INSTALL_SHADOW);
        isExecdInst = isValueEqualsTrue(idata, VAR_INSTALL_EXECD);
        isJmxEnabled = isValueEqualsTrue(idata, VAR_SGE_JMX);
        isBdbInst = isValueEqualsTrue(idata, VAR_INSTALL_BDB);

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

        // Only once...
        if (getNumOfExecution() == 0) {
            // Localhost arch
            Properties variables = idata.getVariables();
            GetArchCommand archCmd = new GetArchCommand(Host.localHostName, Util.DEF_CONNECT_USER,
                    variables.getProperty(VAR_SHELL_NAME, ""), (Util.IS_MODE_WINDOWS && Host.localHostArch.startsWith("win")), variables.getProperty(VAR_SGE_ROOT, ""));
            archCmd.execute();
            if (archCmd.getExitValue() == 0 && archCmd.getOutput().size() > 0) {
                Host.localHostArch = archCmd.getOutput().get(0).trim();
                idata.setVariable(VAR_LOCALHOST_ARCH, Host.localHostArch);
                Debug.trace("localhost.arch='" + idata.getVariable(VAR_LOCALHOST_ARCH) + "'");
            }

            // Check user
            if (vs.substituteMultiple(idata.getVariable(VAR_CONNECT_USER), null).equals(vs.substituteMultiple(idata.getVariable(VAR_USER_NAME), null))) {
                String sgeRoot = vs.substitute(idata.getVariable(VAR_SGE_ROOT), null);
                String userName = vs.substitute(idata.getVariable(VAR_USER_NAME), null);

                ExtendedFile sgeRootDir = new ExtendedFile(sgeRoot);

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

                if (!userName.equals("root")) {
                    if (userName.equals(sgeRootDir.getOwner())) {
                        Debug.trace("You are not installing as user 'root'! This will allow you to run Grid Engine only under your user id for testing a limited functionality of Grid Engine!");
                        if (!silentMode && JOptionPane.NO_OPTION == JOptionPane.showOptionDialog(parent, vs.substituteMultiple(idata.langpack.getString(WARNING_USER_NOT_ROOT), null),
                                idata.langpack.getString("installer.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null,
                                new Object[]{idata.langpack.getString("installer.yes"), idata.langpack.getString("installer.no")}, idata.langpack.getString("installer.yes"))) {
                            parent.exit(true);
                        }
                    } else {
                        Debug.error("You are not installing as user 'root' or as the owner of the Grid Engine root directory. You don't have enough permission to perform installation. The installation terminates!");
                        if (silentMode) {
                            return false;
                        } else {
                            JOptionPane.showOptionDialog(parent, vs.substituteMultiple(idata.langpack.getString(ERROR_USER_INVALID), null),
                                    idata.langpack.getString("installer.error"), JOptionPane.CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null,
                                    new Object[]{idata.langpack.getString("button.exit.label")}, idata.langpack.getString("button.exit.label"));

                            parent.exit(true);
                        }
                    }
                }
            }

            // Set SGE_JMX_PORT to SGE_QMASTER_PORT + 2
            idata.setVariable(VAR_SGE_JMX_PORT, Integer.toString(Integer.valueOf(idata.getVariable(VAR_SGE_QMASTER_PORT)) + 2));
        }

        // Set value for 'cond.qmaster.on.localhost' condition
        Host.IS_QMASTER_ON_LOCALHOST = Host.localHostName.equalsIgnoreCase(idata.getVariable(VAR_QMASTER_HOST)) ||
                Host.localHostIP.equalsIgnoreCase(idata.getVariable(VAR_QMASTER_HOST));

        // cfg.spooling.method
        if (isBdbInst) {
            idata.setVariable(VAR_SPOOLING_METHOD, vs.substituteMultiple(idata.getVariable(VAR_SPOOLING_METHOD_BERKELEYDBSERVER), null));
        } else if (getNumOfExecution() == 0) {
            idata.setVariable(VAR_SPOOLING_METHOD, vs.substituteMultiple(idata.getVariable(VAR_SPOOLING_METHOD_BERKELEYDB), null));
        }

        // Detect Jvm Library if on qmaster host
        if (isJmxEnabled && (isQmasterInst || isShadowdInst)) {
            String sgeRoot = idata.getVariable(VAR_SGE_ROOT);
View Full Code Here

     * Returns with the UrlItem belonging to the given izPanel.
     * @param izPanel The IzPanel
     * @return The UrlItem of IzPanel if there any otherwise null.
     */
    private UrlItem getHelpUrl(IzPanel izPanel) {
        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());

        String name = izPanel.getI18nStringForClass("headline");
        String url = vs.substituteMultiple(izPanel.getI18nStringForClass("helppage"), null);

        if (name != null && !name.equals("") && url != null && !url.equals("")) {
            Debug.log("Found help page: " + name + " " + url);
            return new UrlItem(name, url);
        } else {
View Full Code Here

            // build a Properties instance for substitution
            Properties prop = new Properties();
            prop.put("search.result", sr.toString());

            // substitute the '${search.result}' value with the HTML links
            VariableSubstitutor vs = new VariableSubstitutor(prop);
            srp = vs.substitute(SEARCH_RESULT_PAGE, null);

        } else {
            srp = SEARCH_NO_RESULT_PAGE;
        }
View Full Code Here

     * @see VariableSubstitutor
     */
    public static String fillUpTemplate(String templateFilePath, String resultFilePath, Properties variables, String[] commentChars, boolean removeComments) throws Exception {
      BufferedReader bufferedReader = null;
      BufferedWriter bufferedWriter     = null;
        VariableSubstitutor vs = new VariableSubstitutor(variables);

        Debug.trace("Fill up template from '" + templateFilePath + "' to '" + resultFilePath + "'.");
        File f = new File(resultFilePath);

        try {
          bufferedReader = new BufferedReader(new FileReader(templateFilePath));
            bufferedWriter = new BufferedWriter(new FileWriter(f, false));

            String line = "";
            String formattedLine = "";

            boolean commentedLine = false;
            boolean skipLine = false;
            while ((line = bufferedReader.readLine()) != null) {
                line = vs.substituteMultiple(line, null);
                formattedLine = line.trim().toLowerCase();

                // if comment characters are specified....
                if (commentChars != null) {
                    commentedLine = false;
View Full Code Here

    }
   
    JPanel textPanel = new JPanel(new IzPanelLayout());
        textPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
    JLabel textLabel = new JLabel(vs.substituteMultiple(parent.langpack.getString(WELCOME_TEXT_RESOURCE), null));
    textPanel.add(textLabel);
   
    if (imagePanel != null) {
      add(imagePanel, LayoutConstants.NEXT_COLUMN);
    }
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.