Details
Description
I used izPack for a quite complex installer. As I think the console mode is a great feature I tried it out with the latest trunk version and encountered diffrent problems listed below. In "worst case" none of the panels/input fields can be displayed and something unwanted (e.g. without parsing files according to user input) will be installed.
Those are the points i found in my installation scenario:
1) Using title field in UserInPutPanel causes Exception and following input fields are skipped
title field collection not implemented
java.lang.NullPointerException
at com.izforge.izpack.panels.UserInputPanelConsoleHelper.runConsole(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.iterateAndPerformAction(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.doInstall(Unknown Source)
at com.izforge.izpack.installer.Installer.main(Unknown Source)
2) Using check field in UserInPutPanel causes Exception and following input fields are skipped
java.lang.NullPointerException
at com.izforge.izpack.panels.UserInputPanelConsoleHelper.runConsole(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.iterateAndPerformAction(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.doInstall(Unknown Source)
at com.izforge.izpack.installer.Installer.main(Unknown Source)
3) Rule field in UserInputPanel is not implemented, those fields are simply skipped
4) Panel validators are not called
e.g. I implemented a simple jdbc connection validator based on user input:
<panel classname="UserInputPanel" id="jdbc">
<validator classname="install.jdbcconval"/>
</panel>
In GUI mode the validator class is called, in console mode it is skipped
5) JDKPathPanel is not implemented
Attachments
-
- patch_20090528.txt
- 28/May/09 9:28 AM
- 39 kB
- Peter Heiles
-
- patch.txt
- 20/Apr/09 2:31 AM
- 14 kB
- Mounir el hajj
-
- patch-24-8-2009.txt
- 24/Aug/09 8:57 AM
- 1 kB
- Mounir el hajj
-
- src_lib_com_izforge_izpack_panels_InstallationGroup_20090601_build_patch.txt
- 01/Jun/09 9:55 AM
- 0.7 kB
- Van Halbert
-
- src_lib_com_izforge_izpack_panels_InstallationGroup_20090601_patches.txt
- 01/Jun/09 9:51 AM
- 39 kB
- Van Halbert
-
- src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_052609_patch.txt
- 26/May/09 10:55 AM
- 21 kB
- Van Halbert
-
- src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090529_patch.txt
- 29/May/09 1:42 PM
- 5 kB
- Van Halbert
-
- src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090601_patch.txt
- 01/Jun/09 9:45 AM
- 9 kB
- Van Halbert
-
- src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090608_patch.txt
- 08/Jun/09 12:28 PM
- 9 kB
- Van Halbert
Activity
thank you.
Is just saw that the DefaultTargetPanel is also not called in console mode - I guess that should be quite easy to implement. It would be also nice to have some kind of list which features are not implemented yet
Peter can you please test the patch?
it should fix all the errors in the user input panel. note that the Rule field will be handled like a normal text field, which is logic, since no gui is involved.
Validation should be also performed.
As for JDKPathPanel, and DefaultTargetPanel i haven't had time to do these. all you have to do is create a console helper class for these panels, the same way an automation helper is implemented
one final note. can you set <property name="debug" value="on"/> in the build.xml before compiling your compiler? this will give more meaningful stack traces
Thank you,
M
I just did a quick test and came to the following result - setting debug=on before compilation did not increase the debug output
@1) Title field is displayed
@2) Check field
Still causes Exception
java.lang.NullPointerException
at com.izforge.izpack.panels.UserInputPanelConsoleHelper.processCheckField(Unknown Source)
at com.izforge.izpack.panels.UserInputPanelConsoleHelper.runConsole(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.iterateAndPerformAction(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.doInstall(Unknown Source)
at com.izforge.izpack.installer.Installer.main(Unknown Source)
Also causes the validator in the panel not being called (as it's the last option in this user panel i guess that all following input fields are also skipped)
@3) Ruled Input fields
It shows the suggestion, e.g. for an IP Address: " Server IP: [0:127 1:0 2:0 3:1]"
Result: If the user just hits "Enter" variable is filled with "0:127 1:0 2:0 3:1"
So the default value is filled with the field number (0:, 1:, ...), which should not be included in the default value and additional chars in the rule (e.g. "." between the fields) is not considered
Suggestion: Fill the default value according to the rule, e.g. "127.0.0.1"
@4) Validators are called, but failed validation does not force the user to validate the entered Parameters. Causes the installation to start without having valid user input (with validation I would expect that user input has to be valid before installation process is executed):
com.izforge.izpack.installer.InstallerException: Validating data for panel jdbc was not successfull
at com.izforge.izpack.installer.ConsoleInstaller.validatePanel(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.iterateAndPerformAction(Unknown Source)
at com.izforge.izpack.installer.ConsoleInstaller.doInstall(Unknown Source)
at com.izforge.izpack.installer.Installer.main(Unknown Source)
Configure [NEXTPANEL]
@5) JDKPathPanel, DefaultTargetPane not Implemented, therefore no change expected
Additional finding:
When choosing "redisplay" after a UserInputPanel is finished I would expect that the values entered before are shown, but default values are displayed
please try this new patch
@2) check that debug is not set to false in a previous place. in all cases attach the user input spec that is causing the exception for this panel, it is difficult to debug this exception without an accurate trace or scenario
@3) test
@4) test
M
I will try out the newer patch, for now my Test Case for 2:
<field type="check" variable="BINDIP">
<spec txt="Bind Application to specified IP" true="true" false="false"/>
<validator class="com.izforge.izpack.util.NotEmptyValidator" />
</field>
Just tested the changes:
@3: seems like there is no change in my installation after recompiling with new patch
Test Case:
<field type="rule" variable="SERVERIP">
<spec txt="Server IP:" layout="N:3:3 . N:3:3 . N:3:3 . N:3:3" set="0:127 1:0 2:0 3:1"/>
<validator class="com.izforge.izpack.util.NotEmptyValidator" />
</field>
display: " Server IP: [0:127 1:0 2:0 3:1]"
variable contains: 0:127 1:0 2:0 3:1
@4 Works as expected, if no exception occurs before validator should be called (e.g. in case 2).
Improvement suggestion : Output Text like "Validation failed, please verify your input" before redisplaying the input fields for the panel
thanks! almost working good for me:
@2) Check box works fine, but now I figured out that dynamic variables are not updated on panel switch
Test Case:
Condition ipBindingWanted depends on user input in check field BINDAPPAPPTOIP and causes variable to change its value
— UserInput---
<field type="check" variable="BINDIP">
<spec txt="Bind Application to specified IP" true="true" false="false"/>
<validator class="com.izforge.izpack.util.NotEmptyValidator" />
</field>
--install.xml---
<conditions>
<condition type="variable" id="ipBindingWanted">
<name>BINDIP</name>
<value>true</value>
</condition>
<conditions>
<dynamicvariables>
<variable name="APPBINDHOST" value="$SERVERIP" condition="ipBindingWanted" />
<variable name="APPBINDHOST" value="0.0.0.0" condition="!ipBindingWanted" />
</dynamicvariables>
@3) works fine. In contrast to the check box the entered value is not redisplayed for ruled input fields (did not check for "simple fields)(if selected by user or validation fails)
Patch for dynamic variable refreshs:
Index: ConsoleInstaller.java
===================================================================
— ConsoleInstaller.java (revision 2736)
+++ ConsoleInstaller.java (working copy)
@@ -1,263 +1,300 @@
-/*
- * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
- *
- * http://izpack.org/
- * http://izpack.codehaus.org/
- *
- * Copyright 2007 Dennis Reil
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.izforge.izpack.installer;
-
-import java.io.FileReader;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.FileInputStream;
-import java.util.Iterator;
-import java.util.Properties;
-
-import com.izforge.izpack.LocaleDatabase;
-import com.izforge.izpack.Panel;
-import com.izforge.izpack.util.Debug;
-import com.izforge.izpack.util.Housekeeper;
-import com.izforge.izpack.util.OsConstraint;
-import com.izforge.izpack.util.VariableSubstitutor;
-
-/** - * Runs the console installer
- *
- * @author Mounir el hajj
- */
-public class ConsoleInstaller extends InstallerBase
-{
- - private AutomatedInstallData installdata = new AutomatedInstallData();
- - private boolean result = false;
- - private Properties properties;
- - private PrintWriter printWriter;
- - public ConsoleInstaller() throws Exception
- {
- super();
- loadInstallData(this.installdata);
- this.installdata.localeISO3 = "eng";
- InputStream in = getClass().getResourceAsStream(
- "/langpacks/" + this.installdata.localeISO3 + ".xml");
- this.installdata.langpack = new LocaleDatabase(in);
- this.installdata.setVariable(ScriptParser.ISO3_LANG, this.installdata.localeISO3);
- ResourceManager.create(this.installdata);
- loadConditions(installdata);
- loadInstallerRequirements();
- loadDynamicVariables();
- if (!checkInstallerRequirements(installdata))
- {
- Debug.log("not all installerconditions are fulfilled.");
- return;
- }
- addCustomLangpack(installdata);
- }
-
- protected void iterateAndPerformAction(String strAction) throws Exception
- {
- if (!checkInstallerRequirements(this.installdata))
- {- Debug.log("not all installerconditions are fulfilled.");- return;- } } - Debug.log("[ Starting console installation ] " + strAction);
- - try
- {
- this.result = true;
- Iterator<Panel> panelsIterator = this.installdata.panelsOrder.iterator();
- this.installdata.curPanelNumber = -1;
- while (panelsIterator.hasNext())
- {
- Panel p = (Panel) panelsIterator.next();
- this.installdata.curPanelNumber++;
- String praefix = "com.izforge.izpack.panels.";
- if (p.className.compareTo(".") > -1)
- { - praefix = ""; - }
- if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints))
- { - continue; - }
- String panelClassName = p.className;
- String consoleHelperClassName = praefix + panelClassName + "ConsoleHelper";
- Class<PanelConsole> consoleHelperClass = null;
- - Debug.log("ConsoleHelper:" + consoleHelperClassName);
- try
- { - - consoleHelperClass = (Class<PanelConsole>) Class - .forName(consoleHelperClassName); - - }
- catch (ClassNotFoundException e)
- { - Debug.log("ClassNotFoundException-skip :" + consoleHelperClassName); - continue; - }
- PanelConsole consoleHelperInstance = null;
- if (consoleHelperClass != null)
- {
- try
- { - Debug.log("Instantiate :" + consoleHelperClassName); - refreshDynamicVariables( - new VariableSubstitutor(installdata.getVariables()), installdata); - consoleHelperInstance = consoleHelperClass.newInstance(); - }
- catch (Exception e)
- { - Debug.log("ERROR: no default constructor for " + consoleHelperClassName - + ", skipping..."); - continue; - }
- }
- - if (consoleHelperInstance != null)
- {
- try
- {
- Debug.log("consoleHelperInstance." + strAction + ":"
- + consoleHelperClassName + " entered.");
- boolean bActionResult = true;
- boolean bIsConditionFulfilled = true;
- String strCondition = p.getCondition();
- if (strCondition != null)
- {
- bIsConditionFulfilled = installdata.getRules().isConditionTrue(
- strCondition);
- }
-
- if (strAction.equals("doInstall") &&bIsConditionFulfilled)
- { - bActionResult = consoleHelperInstance.runConsole(this.installdata); - }
- else if (strAction.equals("doGeneratePropertiesFile"))
- { - bActionResult = consoleHelperInstance.runGeneratePropertiesFile( - this.installdata, this.printWriter); - }
- else if (strAction.equals("doInstallFromPropertiesFile") &&bIsConditionFulfilled)
- { - bActionResult = consoleHelperInstance.runConsoleFromPropertiesFile( - this.installdata, this.properties); - }
- if (!bActionResult)
- { - this.result = false; - return; - }
- else
- { - Debug.log("consoleHelperInstance." + strAction + ":" - + consoleHelperClassName + " successfully done."); - }
- }
- catch (Exception e)
- {
- Debug.log("ERROR: console installation failed for panel " + panelClassName);
- e.printStackTrace();
- this.result = false;
- }
-
- }
- - }
- - if (this.result)
- { - System.out.println("[ Console installation done ]"); - }
- else
- { - System.out.println("[ Console installation FAILED! ]"); - }
- }
- catch (Exception e)
- {
- this.result = false;
- System.err.println(e.toString());
- e.printStackTrace();
- System.out.println("[ Console installation FAILED! ]");
- }
-
- }
- - protected void doInstall() throws Exception
- {
- try
- { - iterateAndPerformAction("doInstall"); - }
- catch (Exception e)
- {
- throw e;
- }
-
- finally
- { - Housekeeper.getInstance().shutDown(this.result ? 0 : 1); - }
- }
-
- protected void doGeneratePropertiesFile(String strFile) throws Exception
- {
- try
- { - this.printWriter = new PrintWriter(strFile); - iterateAndPerformAction("doGeneratePropertiesFile"); - this.printWriter.flush(); - }
- catch (Exception e)
- {- throw e;- } }
- - finally
- {
- this.printWriter.close();
- Housekeeper.getInstance().shutDown(this.result ? 0 : 1);
- }
-
- }
- - protected void doInstallFromPropertiesFile(String strFile) throws Exception
- {
- FileInputStream in = new FileInputStream(strFile);
- try
- { - properties = new Properties(); - properties.load(in); - iterateAndPerformAction("doInstallFromPropertiesFile"); - }
- catch (Exception e)
- { - throw e; - }
- finally
- { - in.close(); - Housekeeper.getInstance().shutDown(this.result ? 0 : 1); - }
- }
-}
+/*
+ * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
+ *
+ * http://izpack.org/
+ * http://izpack.codehaus.org/
+ *
+ * Copyright 2007 Dennis Reil
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.izforge.izpack.installer;
+
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.FileInputStream;
+import java.util.Iterator;
+import java.util.Properties;
+
+import com.izforge.izpack.LocaleDatabase;
+import com.izforge.izpack.Panel;
+import com.izforge.izpack.installer.DataValidator.Status;
+import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.Housekeeper;
+import com.izforge.izpack.util.OsConstraint;
+import com.izforge.izpack.util.VariableSubstitutor;
+
+/**
+ * Runs the console installer
+ *
+ * @author Mounir el hajj
+ */
+public class ConsoleInstaller extends InstallerBase
+{
+
+ private AutomatedInstallData installdata = new AutomatedInstallData();
+
+ private boolean result = false;
+
+ private Properties properties;
+
+ private PrintWriter printWriter;
+
+ public ConsoleInstaller() throws Exception
+Unknown macro: {+ super();+ loadInstallData(this.installdata);+ this.installdata.localeISO3 = "eng";+ InputStream in = getClass().getResourceAsStream(+ "/langpacks/" + this.installdata.localeISO3 + ".xml");+ this.installdata.langpack = new LocaleDatabase(in);+ this.installdata.setVariable(ScriptParser.ISO3_LANG, this.installdata.localeISO3);+ ResourceManager.create(this.installdata);+ loadConditions(installdata);+ loadInstallerRequirements();+ loadDynamicVariables();+ if (!checkInstallerRequirements(installdata))+ { + Debug.log("not all installerconditions are fulfilled."); + return; + }
+ addCustomLangpack(installdata);
+ }
+
+ protected void iterateAndPerformAction(String strAction) throws Exception
+ {
+ if (!checkInstallerRequirements(this.installdata))
+ {+ Debug.log("not all installerconditions are fulfilled.");+ return;+ } }
+ Debug.log("[ Starting console installation ] " + strAction);
+
+ try
+ {
+ this.result = true;
+ Iterator<Panel> panelsIterator = this.installdata.panelsOrder.iterator();
+ this.installdata.curPanelNumber = -1;
+ VariableSubstitutor substitutor = new VariableSubstitutor(this.installdata.getVariables());
+ while (panelsIterator.hasNext())
+ {
+ Panel p = (Panel) panelsIterator.next();
+ this.installdata.curPanelNumber++;
+ String praefix = "com.izforge.izpack.panels.";
+ if (p.className.compareTo(".") > -1)
+ { + praefix = ""; + }
+ if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints))
+ { + continue; + }
+ String panelClassName = p.className;
+ String consoleHelperClassName = praefix + panelClassName + "ConsoleHelper";
+ Class<PanelConsole> consoleHelperClass = null;
+
+ Debug.log("ConsoleHelper:" + consoleHelperClassName);
+ try
+ { + + consoleHelperClass = (Class<PanelConsole>) Class + .forName(consoleHelperClassName); + + }
+ catch (ClassNotFoundException e)
+ { + Debug.log("ClassNotFoundException-skip :" + consoleHelperClassName); + continue; + }
+ PanelConsole consoleHelperInstance = null;
+ if (consoleHelperClass != null)
+Unknown macro: {+ try+ { + Debug.log("Instantiate :" + consoleHelperClassName); + refreshDynamicVariables(substitutor, installdata); + consoleHelperInstance = consoleHelperClass.newInstance(); + }+ catch (Exception e)+ { + Debug.log("ERROR: no default constructor for " + consoleHelperClassName + + ", skipping..."); + continue; + }+ }
+
+ if (consoleHelperInstance != null)
+ {
+ try
+ {
+ Debug.log("consoleHelperInstance." + strAction + ":"
+ + consoleHelperClassName + " entered.");
+ boolean bActionResult = true;
+ boolean bIsConditionFulfilled = true;
+ String strCondition = p.getCondition();
+ if (strCondition != null)
+ { + bIsConditionFulfilled = installdata.getRules().isConditionTrue( + strCondition); + }
+
+ if (strAction.equals("doInstall") && bIsConditionFulfilled)
+Unknown macro: {+ do+ { + bActionResult = consoleHelperInstance.runConsole(this.installdata); + }+ while (!validatePanel(p));+ }
+ else if (strAction.equals("doGeneratePropertiesFile"))
+ { + bActionResult = consoleHelperInstance.runGeneratePropertiesFile( + this.installdata, this.printWriter); + }
+ else if (strAction.equals("doInstallFromPropertiesFile")
+ && bIsConditionFulfilled)
+ { + bActionResult = consoleHelperInstance.runConsoleFromPropertiesFile( + this.installdata, this.properties); + }
+ if (!bActionResult)
+ { + this.result = false; + return; + }
+ else
+ { + Debug.log("consoleHelperInstance." + strAction + ":" + + consoleHelperClassName + " successfully done."); + }
+ }
+ catch (Exception e)
+ { + Debug.log("ERROR: console installation failed for panel " + panelClassName); + e.printStackTrace(); + this.result = false; + }
+
+ }
+
+ }
+
+ if (this.result)
+ { + System.out.println("[ Console installation done ]"); + }
+ else
+ { + System.out.println("[ Console installation FAILED! ]"); + }
+ }
+ catch (Exception e)
+ { + this.result = false; + System.err.println(e.toString()); + e.printStackTrace(); + System.out.println("[ Console installation FAILED! ]"); + }
+
+ }
+
+ protected void doInstall() throws Exception
+Unknown macro: {+ try+ { + iterateAndPerformAction("doInstall"); + }+ catch (Exception e)+ { + throw e; + }
+
+ finally
+ { + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + }
+ }
+
+ protected void doGeneratePropertiesFile(String strFile) throws Exception
+ {
+ try
+ { + this.printWriter = new PrintWriter(strFile); + iterateAndPerformAction("doGeneratePropertiesFile"); + this.printWriter.flush(); + }
+ catch (Exception e)
+ {+ throw e;+ } }
+
+ finally
+ { + this.printWriter.close(); + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + }
+
+ }
+
+ protected void doInstallFromPropertiesFile(String strFile) throws Exception
+Unknown macro: {+ FileInputStream in = new FileInputStream(strFile);+ try+ { + properties = new Properties(); + properties.load(in); + iterateAndPerformAction("doInstallFromPropertiesFile"); + }+ catch (Exception e)+ { + throw e; + }+ finally+ { + in.close(); + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + }+ }
+
+ /**
+ * Validate a panel.
+ *
+ * @param p The panel to validate
+ * @throws InstallerException thrown if the validation fails.
+ */
+ private boolean validatePanel(final Panel p) throws InstallerException
+ {
+ boolean bValidity = true;
+ String dataValidator = p.getValidator();
+ if (dataValidator != null)
+ {
+ DataValidator validator = DataValidatorFactory.createDataValidator(dataValidator);
+ Status validationResult = validator.validateData(installdata);
+ if (validationResult != DataValidator.Status.OK)
+Unknown macro: {+ // if defaultAnswer is true, result is ok+ if (validationResult == Status.WARNING && validator.getDefaultAnswer())+ { + System.out + .println("Configuration said, it's ok to go on, if validation is not successfull"); + + }+ // make installation fail instantly+ bValidity = false;+ System.out.println("Validation failed, please verify your input");+ }
+ }
+ return bValidity;
+ }
+}
- * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
- *
- * http://izpack.org/
- * http://izpack.codehaus.org/
- *
- * Copyright 2007 Dennis Reil
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ -package com.izforge.izpack.installer; - -import java.io.FileReader; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.FileInputStream; -import java.util.Iterator; -import java.util.Properties; - -import com.izforge.izpack.LocaleDatabase; -import com.izforge.izpack.Panel; -import com.izforge.izpack.util.Debug; -import com.izforge.izpack.util.Housekeeper; -import com.izforge.izpack.util.OsConstraint; -import com.izforge.izpack.util.VariableSubstitutor; - -/**
- * Runs the console installer
- *
- * @author Mounir el hajj
- */ -public class ConsoleInstaller extends InstallerBase -{ -
- private AutomatedInstallData installdata = new AutomatedInstallData(); -
- private boolean result = false; -
- private Properties properties; -
- private PrintWriter printWriter; -
- public ConsoleInstaller() throws Exception
- {
- super();
- loadInstallData(this.installdata);
- this.installdata.localeISO3 = "eng";
- InputStream in = getClass().getResourceAsStream(
- "/langpacks/" + this.installdata.localeISO3 + ".xml");
- this.installdata.langpack = new LocaleDatabase(in);
- this.installdata.setVariable(ScriptParser.ISO3_LANG, this.installdata.localeISO3);
- ResourceManager.create(this.installdata);
- loadConditions(installdata);
- loadInstallerRequirements();
- loadDynamicVariables();
- if (!checkInstallerRequirements(installdata))
- { - Debug.log("not all installerconditions are fulfilled."); - return; - } - addCustomLangpack(installdata); - } - - protected void iterateAndPerformAction(String strAction) throws Exception - { - if (!checkInstallerRequirements(this.installdata)) - {- Debug.log("not all installerconditions are fulfilled.");- return;- } }
- Debug.log("[ Starting console installation ] " + strAction); -
- try
- {
- this.result = true;
- Iterator<Panel> panelsIterator = this.installdata.panelsOrder.iterator();
- this.installdata.curPanelNumber = -1;
- while (panelsIterator.hasNext())
- {
- Panel p = (Panel) panelsIterator.next();
- this.installdata.curPanelNumber++;
- String praefix = "com.izforge.izpack.panels.";
- if (p.className.compareTo(".") > -1)
- { - praefix = ""; - }
- if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints))
- { - continue; - }
- String panelClassName = p.className;
- String consoleHelperClassName = praefix + panelClassName + "ConsoleHelper";
- Class<PanelConsole> consoleHelperClass = null; -
- Debug.log("ConsoleHelper:" + consoleHelperClassName);
- try
- { - - consoleHelperClass = (Class<PanelConsole>) Class - .forName(consoleHelperClassName); - - }
- catch (ClassNotFoundException e)
- { - Debug.log("ClassNotFoundException-skip :" + consoleHelperClassName); - continue; - }
- PanelConsole consoleHelperInstance = null;
- if (consoleHelperClass != null)
- {
- try
- { - Debug.log("Instantiate :" + consoleHelperClassName); - refreshDynamicVariables( - new VariableSubstitutor(installdata.getVariables()), installdata); - consoleHelperInstance = consoleHelperClass.newInstance(); - }
- catch (Exception e)
- { - Debug.log("ERROR: no default constructor for " + consoleHelperClassName - + ", skipping..."); - continue; - }
- } -
- if (consoleHelperInstance != null)
- {
- try
- {
- Debug.log("consoleHelperInstance." + strAction + ":"
- + consoleHelperClassName + " entered.");
- boolean bActionResult = true;
- boolean bIsConditionFulfilled = true;
- String strCondition = p.getCondition();
- if (strCondition != null)
- { - bIsConditionFulfilled = installdata.getRules().isConditionTrue( - strCondition); - } -
- if (strAction.equals("doInstall") &&bIsConditionFulfilled)
- { - bActionResult = consoleHelperInstance.runConsole(this.installdata); - }
- else if (strAction.equals("doGeneratePropertiesFile"))
- { - bActionResult = consoleHelperInstance.runGeneratePropertiesFile( - this.installdata, this.printWriter); - }
- else if (strAction.equals("doInstallFromPropertiesFile") &&bIsConditionFulfilled)
- { - bActionResult = consoleHelperInstance.runConsoleFromPropertiesFile( - this.installdata, this.properties); - }
- if (!bActionResult)
- { - this.result = false; - return; - }
- else
- { - Debug.log("consoleHelperInstance." + strAction + ":" - + consoleHelperClassName + " successfully done."); - }
- }
- catch (Exception e)
- { - Debug.log("ERROR: console installation failed for panel " + panelClassName); - e.printStackTrace(); - this.result = false; - } -
- } -
- } -
- if (this.result)
- { - System.out.println("[ Console installation done ]"); - }
- else
- { - System.out.println("[ Console installation FAILED! ]"); - }
- }
- catch (Exception e)
- { - this.result = false; - System.err.println(e.toString()); - e.printStackTrace(); - System.out.println("[ Console installation FAILED! ]"); - } -
- } -
- protected void doInstall() throws Exception
- {
- try
- { - iterateAndPerformAction("doInstall"); - }
- catch (Exception e)
- { - throw e; - } - - finally - { - Housekeeper.getInstance().shutDown(this.result ? 0 : 1); - } - } - - protected void doGeneratePropertiesFile(String strFile) throws Exception - { - try - { - this.printWriter = new PrintWriter(strFile); - iterateAndPerformAction("doGeneratePropertiesFile"); - this.printWriter.flush(); - } - catch (Exception e) - {- throw e;- } } -
- finally
- { - this.printWriter.close(); - Housekeeper.getInstance().shutDown(this.result ? 0 : 1); - } -
- } -
- protected void doInstallFromPropertiesFile(String strFile) throws Exception
- {
- FileInputStream in = new FileInputStream(strFile);
- try
- { - properties = new Properties(); - properties.load(in); - iterateAndPerformAction("doInstallFromPropertiesFile"); - }
- catch (Exception e)
- { - throw e; - }
- finally
- { - in.close(); - Housekeeper.getInstance().shutDown(this.result ? 0 : 1); - }
- }
-}
+/*
+ * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
+ *
+ * http://izpack.org/
+ * http://izpack.codehaus.org/
+ *
+ * Copyright 2007 Dennis Reil
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.izforge.izpack.installer;
+
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.FileInputStream;
+import java.util.Iterator;
+import java.util.Properties;
+
+import com.izforge.izpack.LocaleDatabase;
+import com.izforge.izpack.Panel;
+import com.izforge.izpack.installer.DataValidator.Status;
+import com.izforge.izpack.util.Debug;
+import com.izforge.izpack.util.Housekeeper;
+import com.izforge.izpack.util.OsConstraint;
+import com.izforge.izpack.util.VariableSubstitutor;
+
+/**
+ * Runs the console installer
+ *
+ * @author Mounir el hajj
+ */
+public class ConsoleInstaller extends InstallerBase
+{
+
+ private AutomatedInstallData installdata = new AutomatedInstallData();
+
+ private boolean result = false;
+
+ private Properties properties;
+
+ private PrintWriter printWriter;
+
+ public ConsoleInstaller() throws Exception
+ Unknown macro: {+ super();+ loadInstallData(this.installdata);+ this.installdata.localeISO3 = "eng";+ InputStream in = getClass().getResourceAsStream(+ "/langpacks/" + this.installdata.localeISO3 + ".xml");+ this.installdata.langpack = new LocaleDatabase(in);+ this.installdata.setVariable(ScriptParser.ISO3_LANG, this.installdata.localeISO3);+ ResourceManager.create(this.installdata);+ loadConditions(installdata);+ loadInstallerRequirements();+ loadDynamicVariables();+ if (!checkInstallerRequirements(installdata))+ { + Debug.log("not all installerconditions are fulfilled."); + return; + } + addCustomLangpack(installdata); + } + + protected void iterateAndPerformAction(String strAction) throws Exception + { + if (!checkInstallerRequirements(this.installdata)) + {+ Debug.log("not all installerconditions are fulfilled.");+ return;+ } }+ Debug.log("[ Starting console installation ] " + strAction); + + try + { + this.result = true; + Iterator<Panel> panelsIterator = this.installdata.panelsOrder.iterator(); + this.installdata.curPanelNumber = -1; + VariableSubstitutor substitutor = new VariableSubstitutor(this.installdata.getVariables()); + while (panelsIterator.hasNext()) + { + Panel p = (Panel) panelsIterator.next(); + this.installdata.curPanelNumber++; + String praefix = "com.izforge.izpack.panels."; + if (p.className.compareTo(".") > -1) + { + praefix = ""; + } + if (!OsConstraint.oneMatchesCurrentSystem(p.osConstraints)) + { + continue; + } + String panelClassName = p.className; + String consoleHelperClassName = praefix + panelClassName + "ConsoleHelper"; + Class<PanelConsole> consoleHelperClass = null; + + Debug.log("ConsoleHelper:" + consoleHelperClassName); + try + { + + consoleHelperClass = (Class<PanelConsole>) Class + .forName(consoleHelperClassName); + + } + catch (ClassNotFoundException e) + { + Debug.log("ClassNotFoundException-skip :" + consoleHelperClassName); + continue; + } + PanelConsole consoleHelperInstance = null; + if (consoleHelperClass != null) +Unknown macro: {+ try+ { + Debug.log("Instantiate :" + consoleHelperClassName); + refreshDynamicVariables(substitutor, installdata); + consoleHelperInstance = consoleHelperClass.newInstance(); + }+ catch (Exception e)+ { + Debug.log("ERROR: no default constructor for " + consoleHelperClassName + + ", skipping..."); + continue; + }+ }+ + if (consoleHelperInstance != null) + { + try + { + Debug.log("consoleHelperInstance." + strAction + ":" + + consoleHelperClassName + " entered."); + boolean bActionResult = true; + boolean bIsConditionFulfilled = true; + String strCondition = p.getCondition(); + if (strCondition != null) + { + bIsConditionFulfilled = installdata.getRules().isConditionTrue( + strCondition); + } + + if (strAction.equals("doInstall") && bIsConditionFulfilled) +Unknown macro: {+ do+ { + bActionResult = consoleHelperInstance.runConsole(this.installdata); + }+ while (!validatePanel(p));+ }+ else if (strAction.equals("doGeneratePropertiesFile")) + { + bActionResult = consoleHelperInstance.runGeneratePropertiesFile( + this.installdata, this.printWriter); + } + else if (strAction.equals("doInstallFromPropertiesFile") + && bIsConditionFulfilled) + { + bActionResult = consoleHelperInstance.runConsoleFromPropertiesFile( + this.installdata, this.properties); + } + if (!bActionResult) + { + this.result = false; + return; + } + else + { + Debug.log("consoleHelperInstance." + strAction + ":" + + consoleHelperClassName + " successfully done."); + } + } + catch (Exception e) + { + Debug.log("ERROR: console installation failed for panel " + panelClassName); + e.printStackTrace(); + this.result = false; + } + + } + + } + + if (this.result) + { + System.out.println("[ Console installation done ]"); + } + else + { + System.out.println("[ Console installation FAILED! ]"); + } + } + catch (Exception e) + { + this.result = false; + System.err.println(e.toString()); + e.printStackTrace(); + System.out.println("[ Console installation FAILED! ]"); + } + + } + + protected void doInstall() throws Exception +Unknown macro: {+ try+ { + iterateAndPerformAction("doInstall"); + }+ catch (Exception e)+ { + throw e; + } + + finally + { + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + } + } + + protected void doGeneratePropertiesFile(String strFile) throws Exception + { + try + { + this.printWriter = new PrintWriter(strFile); + iterateAndPerformAction("doGeneratePropertiesFile"); + this.printWriter.flush(); + } + catch (Exception e) + {+ throw e;+ } }+ + finally + { + this.printWriter.close(); + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + } + + } + + protected void doInstallFromPropertiesFile(String strFile) throws Exception +Unknown macro: {+ FileInputStream in = new FileInputStream(strFile);+ try+ { + properties = new Properties(); + properties.load(in); + iterateAndPerformAction("doInstallFromPropertiesFile"); + }+ catch (Exception e)+ { + throw e; + }+ finally+ { + in.close(); + Housekeeper.getInstance().shutDown(this.result ? 0 : 1); + }+ }+ + /** + * Validate a panel. + * + * @param p The panel to validate + * @throws InstallerException thrown if the validation fails. + */ + private boolean validatePanel(final Panel p) throws InstallerException + { + boolean bValidity = true; + String dataValidator = p.getValidator(); + if (dataValidator != null) + { + DataValidator validator = DataValidatorFactory.createDataValidator(dataValidator); + Status validationResult = validator.validateData(installdata); + if (validationResult != DataValidator.Status.OK) +Unknown macro: {+ // if defaultAnswer is true, result is ok+ if (validationResult == Status.WARNING && validator.getDefaultAnswer())+ { + System.out + .println("Configuration said, it's ok to go on, if validation is not successfull"); + + }+ // make installation fail instantly+ bValidity = false;+ System.out.println("Validation failed, please verify your input");+ }+ } + return bValidity; + } +}
Added patches to fix described problems:
a) dynamic variables are now refreshed after panel switch
b) default "text values" are replaced with previous user input if panel is redisplayed
Is anyone adding the logic to support field types "file" and "password"? Also, what about supporting the langpacks, because it didn't appear to be substituting the language for the id.
Why I'm asking about these is because I would be glad to work on this and provide a patch, if no one is currently adding these options.
Attached my latest version of the patch.
I'm currently not adding more functionality to the console mode
Thanks I will have a look Peter.
@Van: sure, feel free to contribute a patch!
This patch adds the following:
- supports Processor for obtaining choices in the combo or radio field types
- support for Password field type
- fixed bug on return from calling getInputFromField(...), needed to handle null.
- added Space and Divider field types for visual appearance
Next capabilities to add are:
- support Validators and DataValidators
- support more complex installation options based on pack selection
- supports Processor for obtaining choices in the combo or radio field types
- support for Password field type
- fixed bug on return from calling getInputFromField(...), needed to handle null.
- added Space and Divider field types for visual appearance
- support Validators and DataValidators
- support more complex installation options based on pack selection
@Peter: I tried to apply your patch (Index_ src_lib_com_izforge_izpack_installer_ConsoleInstaller.java.txt) but it did not work. Since there are some patch bits in the issue comments, I guess you had a problem to properly upload it. Could you please re-submit one single patch?
@Van: your patch applies fine, but just to make sure: you applied the one from Mounir (patch.txt) first right?
yes, that patch added the support for rules and check boxes (and others). I added additional logic for check boxes to support processors.
2nd try to upload patch. it includes the changes from Mounir + some fixes
I also have a small correction, for generating properties file, and playback form that file, when an input has no variable attached to it like for example a statictext input. i will post the patch once the available patches are submitted. it is very simple
107,113c107,111
< if(strVariableName!=null){
< String strVariableValue = p.getProperty(strVariableName);
< if (strVariableValue != null)
< {
< installData.setVariable(strVariableName, strVariableValue);
< }
< }
—
> String strVariableValue = p.getProperty(strVariableName);
> if (strVariableValue != null)
> {
> installData.setVariable(strVariableName, strVariableValue);
> }
125,128c123
< Input input=(Input) inputIterator.next();
< if (input.strVariableName!=null){
< printWriter.println(input.strVariableName + "=");
< }
—
> printWriter.println(((Input) inputIterator.next()).strVariableName + "=");
Van's patch applies fine. I am applying it to the IzPack source tree, in branches/4.3 under SVN.
Peter, your patch does not apply after Van's one:
julien@jponge ~/C/i/s/lib> patch --dry-run -p0 < ../../patch_20090527.txt (Stripping trailing CRs from patch.) patching file com/izforge/izpack/installer/ConsoleInstaller.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/JDKPathPanel.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/JDKPathPanelConsoleHelper.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/UserInputPanelConsoleHelper.java Hunk #1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file com/izforge/izpack/panels/UserInputPanelConsoleHelper.java.rej
@Mounir: ok to get your patch after the ones from Van and Peter ![]()
julien@jponge ~/C/i/s/lib> patch --dry-run -p0 < ../../patch_20090527.txt (Stripping trailing CRs from patch.) patching file com/izforge/izpack/installer/ConsoleInstaller.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/JDKPathPanel.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/JDKPathPanelConsoleHelper.java (Stripping trailing CRs from patch.) patching file com/izforge/izpack/panels/UserInputPanelConsoleHelper.java Hunk #1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file com/izforge/izpack/panels/UserInputPanelConsoleHelper.java.rej
Julien, this is the patch based on revision 2783 - you should be able to apply it now
Thanks Peter, it has been applied.
I am now waiting on an update from Mounir before I can close the issue.
This patch applies to rev 2785.
It does the following:
- adds the display of the description (header) for the combo or radio boxes
- fixes the setting of the selected default for combo / radio boxes (including when only one exist in the combo, therefore setting that as the default)
- adds the display of the description (header) for the combo or radio boxes
- fixes the setting of the selected default for combo / radio boxes (including when only one exist in the combo, therefore setting that as the default)
This is a patch to rev 2787. It provides the following:
- the default value for a text field wasn't being substituted for
- adds logic to support installation groups and OS specific panels/fields (see patch src_lib_com_izforge_izpack_panels_InstallationGroup_20090601_patches.txt that adds installationgroup console helper for presenting installation group options)
- the default value for a text field wasn't being substituted for
- adds logic to support installation groups and OS specific panels/fields (see patch src_lib_com_izforge_izpack_panels_InstallationGroup_20090601_patches.txt that adds installationgroup console helper for presenting installation group options)
The attached patch adds the ability in console mode to support selecting an installation group.
After working on the console mode for userinputpanel, realized there was alot of code duplication when dealing with the xml elements and properties. Therefore, in this patch, i've tried to consolidate the code for use by the UI and console mode logic. I'm not sure if this is how you would have preferred to break out the code, so please direct me if you would like to handle it differently.
This is the patch to the build.xml file to support the InstallationGroup patches.
Van, with revision 2785 I found the following behaviour with radio boxes:
in userinputpanel definition for this panel option 0 has the option set="true", others have no set defined
1.: Initial display
Select Installation Type
0 [x] Single Node Installation
1 [ ] Cluster Installation
2 [ ] DemoInstallation
2. select "1"
3. Redisplay:
0 [x] Single Node Installation
1 [x] Cluster Installation
2 [ ] DemoInstallation
Both Options are marked (which should not happen with a radio box)
after removing the "set="true"" Parameter from the radio box definition display was as expected
Thanks Van, but the first patch in the queue fails to apply:
patch --dry-run -p0 < src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090601_patch.txt patching file src/lib/com/izforge/izpack/panels/UserInputPanelConsoleHelper.java Hunk #3 FAILED at 172. Hunk #4 succeeded at 247 (offset -1 lines). Hunk #5 succeeded at 259 (offset -1 lines). Hunk #6 succeeded at 341 (offset -1 lines). Hunk #7 succeeded at 851 (offset -1 lines). 1 out of 7 hunks FAILED -- saving rejects to file src/lib/com/izforge/izpack/panels/UserInputPanelConsoleHelper.java.rej
Could you please have a look and consolidate with the other ones?
Thanks!
patch --dry-run -p0 < src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090601_patch.txt patching file src/lib/com/izforge/izpack/panels/UserInputPanelConsoleHelper.java Hunk #3 FAILED at 172. Hunk #4 succeeded at 247 (offset -1 lines). Hunk #5 succeeded at 259 (offset -1 lines). Hunk #6 succeeded at 341 (offset -1 lines). Hunk #7 succeeded at 851 (offset -1 lines). 1 out of 7 hunks FAILED -- saving rejects to file src/lib/com/izforge/izpack/panels/UserInputPanelConsoleHelper.java.rej
Julien, I figured out that variables in staticText fields are not replaced.
Here is my code snippet for UserInputPanelConsoleHelper (too many open patches at the moment - think it's not good to add another one right now).
Could you please put it in there "manually"?
boolean processSimpleField(Input input, AutomatedInstallData idata)
{ VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables()); System.out.println(vs.substitute(input.strText, null)); return true; }Sorry for the unacceptable patch.
Here's a new patch that's run thru the patch process:
src_lib_com_izforge_izpack_panels_UserInputPanelConsoleHelper_20090608_patch.txt was created against rev 2792.
sorry for the late notice, but i think the small correction posted by me on 27/May/09 09:11 AM was not merged. Julien how to proceed?
Hi Mounir,
Sorry for the delay. I guess the best would be that you have a look, and upload a fresh patch.
Cheers
Great.
Shall I now consider the issue as resolved?
If you guys have further fixes, new issues should be created. What do you think?
Thanks Julien
you can consider everything is resolved from my side
Thank You
currently these features are not implemented. i will have a look and try to submit a patch