diff --git a/install/.classpath b/install/.classpath index 742be55d11..75ec5583bd 100644 --- a/install/.classpath +++ b/install/.classpath @@ -16,7 +16,6 @@ - diff --git a/install/Adempiere/AdempiereEnvTemplate.properties b/install/Adempiere/AdempiereEnvTemplate.properties new file mode 100644 index 0000000000..610358e6d2 --- /dev/null +++ b/install/Adempiere/AdempiereEnvTemplate.properties @@ -0,0 +1,67 @@ +#AdempiereEnv.properties Template + +#Adempiere home +ADEMPIERE_HOME=C\:\\Adempiere +#Java home +JAVA_HOME=C\:\\Program Files\\Java\\jdk1.5.0_09 + +#Type of jvm, sun|mac| +ADEMPIERE_JAVA_TYPE=sun +#Java runtime options +ADEMPIERE_JAVA_OPTIONS=-Xms64M -Xmx512M + +#Type of database, postgresql|oracle|oracleXE|fyracle +ADEMPIERE_DB_TYPE=postgresql +#Database server host name +ADEMPIERE_DB_SERVER=localhost +#Database port, oracle[1512], postgresql[5432], fyracle[3500] +ADEMPIERE_DB_PORT=5432 +#Database name +ADEMPIERE_DB_NAME=adempiere +#Database system user password +ADEMPIERE_DB_SYSTEM=postgres +#Database user name +ADEMPIERE_DB_USER=adempiere +#Database user password +ADEMPIERE_DB_PASSWORD=adempiere + +#Type of application server +ADEMPIERE_APPS_TYPE=jboss +#Application server host name +ADEMPIERE_APPS_SERVER=localhost +#Application server port +ADEMPIERE_JNP_PORT=1099 +ADEMPIERE_WEB_PORT=80 +ADEMPIERE_SSL_PORT=443 + +#Keystore setting +ADEMPIERE_KEYSTORE=C\:\\Adempiere\\keystore\\myKeystore +ADEMPIERE_KEYSTOREWEBALIAS=adempiere +ADEMPIERE_KEYSTORECODEALIAS=adempiere +ADEMPIERE_KEYSTOREPASS=myPassword + +#Certificate details +#Common name, default to host name +ADEMPIERE_CERT_CN= +#Organization, default to the user name +ADEMPIERE_CERT_ORG=ADempiere Bazaar +#Organization Unit, default to 'AdempiereUser' +ADEMPIERE_CERT_ORG_UNIT=AdempiereUser +#town +ADEMPIERE_CERT_LOCATION=myTown +#state +ADEMPIERE_CERT_STATE= +#2 character country code +ADEMPIERE_CERT_COUNTRY= + +#Mail server setting +ADEMPIERE_MAIL_SERVER=localhost +ADEMPIERE_ADMIN_EMAIL=admin@host.com +ADEMPIERE_MAIL_USER= +ADEMPIERE_MAIL_PASSWORD= + +#ftp server setting +ADEMPIERE_FTP_SERVER=localhost +ADEMPIERE_FTP_PREFIX=my +ADEMPIERE_FTP_USER=anonymous +ADEMPIERE_FTP_PASSWORD=user@host.com diff --git a/install/Adempiere/RUN_silentsetup.bat b/install/Adempiere/RUN_silentsetup.bat new file mode 100644 index 0000000000..fbcd0e7c01 --- /dev/null +++ b/install/Adempiere/RUN_silentsetup.bat @@ -0,0 +1,53 @@ +@Title Install Adempiere Server +@Rem $Header: /cvsroot/adempiere/install/Adempiere/RUN_setup.bat,v 1.19 2005/09/08 21:54:12 jjanke Exp $ +@Echo off + + +@if not "%JAVA_HOME%" == "" goto JAVA_HOME_OK +@Set JAVA=java +@Echo JAVA_HOME is not set. +@Echo You may not be able to start the required Setup window !! +@Echo Set JAVA_HOME to the directory of your local 1.5 JDK. +@Echo If you experience problems, run utils/WinEnv.js +@Echo Example: cscript utils\WinEnv.js C:\Adempiere "C:\Program Files\Java\jdk1.5.0_04" +goto START + +:JAVA_HOME_OK +@Set JAVA=%JAVA_HOME%\bin\java + + +:START +@Echo ======================================= +@Echo Starting Setup ... +@Echo ======================================= +@SET CP=lib\CInstall.jar;lib\Adempiere.jar;lib\CCTools.jar;lib\oracle.jar;lib\fyracle.jar;lib\derby.jar;lib\jboss.jar;lib\postgresql.jar; + +@Rem Trace Level Parameter, e.g. SET ARGS=ALL +@SET ARGS=CONFIG + +@Rem To test the OCI driver, add -DTestOCI=Y to the command - example: +@Rem %JAVA% -classpath %CP% -DADEMPIERE_HOME=%ADEMPIERE_HOME% -DTestOCI=Y org.compiere.install.Setup %ARGS% + +@"%JAVA%" -classpath %CP% -DADEMPIERE_HOME=%ADEMPIERE_HOME% org.compiere.install.SilentSetup %ARGS% +@Echo ErrorLevel = %ERRORLEVEL% +@IF NOT ERRORLEVEL = 1 GOTO NEXT +@Echo *************************************** +@Echo Check the error messabe above. +@Echo *************************************** +@Echo Maske sure that the environment is set correctly! +@Echo Set environment variable JAVA_HOME manually +@Echo or use WinEnv.js in the util directory +@Echo *************************************** +@Pause +@Exit + + +:NEXT +@Rem =================================== +@Rem Setup Adempiere Environment +@Rem =================================== +@Call utils\RUN_WinEnv.bat + +@Echo . +@Echo For problems, check log file in base directory +@pause \ No newline at end of file diff --git a/install/Adempiere/RUN_silentsetup.sh b/install/Adempiere/RUN_silentsetup.sh new file mode 100644 index 0000000000..6ff44691e8 --- /dev/null +++ b/install/Adempiere/RUN_silentsetup.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +echo Install Adempiere Server +# $Header: /cvsroot/adempiere/install/Adempiere/RUN_setup.sh,v 1.19 2005/09/08 21:54:12 jjanke Exp $ + +if [ $JAVA_HOME ]; then + JAVA=$JAVA_HOME/bin/java + KEYTOOL=$JAVA_HOME/bin/keytool +else + JAVA=java + KEYTOOL=keytool + echo JAVA_HOME is not set. + echo You may not be able to start the Setup + echo Set JAVA_HOME to the directory of your local JDK. +fi + + +echo =================================== +echo Starting Setup ... +echo =================================== +CP=lib/CInstall.jar:lib/Adempiere.jar:lib/CCTools.jar:lib/oracle.jar:lib/derby.jar:lib/fyracle.jar:lib/jboss.jar:lib/postgresql.jar: + +# Trace Level Parameter, e.g. ARGS=ALL +ARGS=CONFIG + +$JAVA -classpath $CP -DADEMPIERE_HOME=$ADEMPIERE_HOME org.compiere.install.SilentSetup $ARGS + + +echo =================================== +echo Make .sh executable & set Env +echo =================================== +chmod -R a+x *.sh +find . -name '*.sh' -exec chmod a+x '{}' \; + +. utils/RUN_UnixEnv.sh + +echo . +echo For problems, check log file in base directory diff --git a/install/Adempiere/build.xml b/install/Adempiere/build.xml index d69259cbeb..5c9206f674 100644 --- a/install/Adempiere/build.xml +++ b/install/Adempiere/build.xml @@ -161,7 +161,6 @@ - @@ -207,7 +206,6 @@ - diff --git a/install/build.xml b/install/build.xml index bd2e22fc79..e6eb236693 100644 --- a/install/build.xml +++ b/install/build.xml @@ -34,9 +34,6 @@ - - - diff --git a/install/src/org/compiere/install/ConfigDB2.java b/install/src/org/compiere/install/ConfigDB2.java deleted file mode 100644 index 954642e848..0000000000 --- a/install/src/org/compiere/install/ConfigDB2.java +++ /dev/null @@ -1,252 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.install; - -import java.io.*; -import java.net.*; -import java.sql.*; - -import org.compiere.db.*; -import org.compiere.util.*; - -import com.ibm.db2.jcc.*; - -/** - * DB/2 Configuration Test - * - * @author Jorg Janke - * @version $Id: ConfigDB2.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ - */ -public class ConfigDB2 extends Config -{ - /** - * ConfigOracle - * @param data configuration - */ - public ConfigDB2 (ConfigurationData data) - { - super (data); - } // ConfigOracle - - /** DB/2 Driver */ - private static DB2Driver s_db2Driver = null; - /** Last Connection */ - private Connection m_con = null; - - /** - * Init - */ - public void init() - { - p_data.setDatabasePort(String.valueOf(DB_DB2.DEFAULT_PORT_0)); - p_data.setDatabaseName("adempiere"); - p_data.setDatabaseSystemPassword(true); - } // init - - - /************************************************************************** - * Test - * @return error message or null if OK - */ - public String test() - { - // Database Server - String server = p_data.getDatabaseServer(); - boolean pass = server != null && server.length() > 0 - && server.toLowerCase().indexOf("localhost") == -1 - && !server.equals("127.0.0.1"); - String error = "Not correct: DB Server = " + server; - InetAddress databaseServer = null; - try - { - if (pass) - databaseServer = InetAddress.getByName(server); - } - catch (Exception e) - { - error += " - " + e.getMessage(); - pass = false; - } - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); - log.info("OK: Database Server = " + databaseServer); - setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); - setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, p_data.getDatabaseType()); - - // Database Port - int databasePort = p_data.getDatabasePort(); - pass = p_data.testPort (databaseServer, databasePort, true); - error = "DB Server Port = " + databasePort; - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); - if (!pass) - return error; - log.info("OK: Database Port = " + databasePort); - setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); - - - // JDBC Database Info - String databaseName = p_data.getDatabaseName(); // Service Name - String systemPassword = p_data.getDatabaseSystemPassword(); - pass = systemPassword != null && systemPassword.length() > 0; - error = "No Database System Password entered"; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); - if (!pass) - return error; - // - // URL (derived) jdbc:oracle:thin:@//prod1:1521/prod1 - String url = "jdbc:db2://" + databaseServer.getHostName() - + ":" + databasePort - + "/" + databaseName; - pass = testJDBC(url, "db2admin", systemPassword); - error = "Error connecting: " + url - + " - as db2admin/" + systemPassword; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); - if (!pass) - return error; - log.info("OK: Connection = " + url); - setProperty(ConfigurationData.ADEMPIERE_DB_URL, url); - log.info("OK: Database System User " + databaseName); - setProperty(ConfigurationData.ADEMPIERE_DB_NAME, databaseName); - setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword); - - - // Database User Info - String databaseUser = p_data.getDatabaseUser(); // UID - String databasePassword = p_data.getDatabasePassword(); // PWD - pass = databasePassword != null && databasePassword.length() > 0; - error = "Invalid Database User Password"; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); - if (!pass) - return error; - // Ignore result as it might not be imported - pass = testJDBC(url, databaseUser, databasePassword); - error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); - if (pass) - { - log.info("OK: Database User = " + databaseUser); - if (m_con != null) - setProperty(ConfigurationData.ADEMPIERE_WEBSTORES, getWebStores(m_con)); - } - else - log.warning(error); - setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); - setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); - - if (!p_data.getAppsServerType().equals(ConfigurationData.APPSTYPE_TOMCAT)) - { - String cmd = "db2 "; - if (Env.isWindows()) - cmd = "db2cmd -c -w -i db2 "; - String sqlcmd1 = cmd + "connect to xx"; - String sqlcmd2 = cmd + "-f utils/db2/Test.sql"; - log.config(sqlcmd2); - pass = testSQL(sqlcmd2); - error = "Error connecting via: " + sqlcmd2; - signalOK(getPanel().okDatabaseSQL, "ErrorTNS", - pass, true, error); - if (pass) - log.info("OK: Database SQL Connection"); - } - - m_con = null; - return null; - } // test - - /** - * Test JDBC Connection to Server - * @param url connection string - * @param uid user id - * @param pwd password - * @return true if OK - */ - private boolean testJDBC (String url, String uid, String pwd) - { - log.fine("Url=" + url + ", UID=" + uid); - try - { - if (s_db2Driver == null) - { - s_db2Driver = new DB2Driver(); - DriverManager.registerDriver(s_db2Driver); - } - m_con = DriverManager.getConnection(url, uid, pwd); - } - catch (Exception e) - { - log.warning(e.toString()); - return false; - } - return true; - } // testJDBC - - /** - * Test Command Line Connection - * @param sqlcmd sql command line - * @return true if OK - */ - private boolean testSQL (String sqlcmd) - { - if (true) - return true; - // - StringBuffer sbOut = new StringBuffer(); - StringBuffer sbErr = new StringBuffer(); - int result = -1; - try - { - Process p = Runtime.getRuntime().exec (sqlcmd); - InputStream in = p.getInputStream(); - int c; - while ((c = in.read()) != -1) - { - sbOut.append((char)c); - System.out.print((char)c); - } - in.close(); - in = p.getErrorStream(); - while ((c = in.read()) != -1) - sbErr.append((char)c); - in.close(); - // Get result - try - { - Thread.yield(); - result = p.exitValue(); - } - catch (Exception e) // Timing issue on Solaris. - { - Thread.sleep(200); // .2 sec - result = p.exitValue(); - } - } - catch (Exception ex) - { - log.warning(ex.toString()); - } - log.finer(sbOut.toString()); - if (sbErr.length() > 0) - log.warning(sbErr.toString()); - return result == 0; - } // testSQL - -} // ConfigDB2 diff --git a/install/src/org/compiere/install/ConfigFyracle.java b/install/src/org/compiere/install/ConfigFyracle.java index a23eefb920..822561a5b0 100644 --- a/install/src/org/compiere/install/ConfigFyracle.java +++ b/install/src/org/compiere/install/ConfigFyracle.java @@ -21,13 +21,13 @@ import org.compiere.db.*; * Firebird Fyracle Configuration * * @author Marek Mosiewicz - * @version $Id: ConfigSybase.java,v 1.4 2005/03/11 20:30:23 jjanke Exp $ + * @version $Id: ConfigFyracle.java,v 1.4 2005/03/11 20:30:23 jjanke Exp $ */ public class ConfigFyracle extends Config { /** - * ConfigSybase + * ConfigFyracle * @param data */ public ConfigFyracle (ConfigurationData data) @@ -86,8 +86,9 @@ public class ConfigFyracle extends Config error += " - " + e.getMessage(); pass = false; } - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", + pass, true, error); log.info("OK: Database Server = " + databaseServer); setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, p_data.getDatabaseType()); @@ -95,9 +96,10 @@ public class ConfigFyracle extends Config // Database Port int databasePort = p_data.getDatabasePort(); pass = p_data.testPort (databaseServer, databasePort, true); - error = "DB Server Port = " + databasePort; - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); + error = "DB Server Port = " + databasePort; + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", + pass, true, error); if (!pass) return error; log.info("OK: Database Port = " + databasePort); @@ -113,8 +115,9 @@ public class ConfigFyracle extends Config pass = testJDBC(urlSystem, p_db.getSystemUser(), systemPassword); error = "Error connecting: " + urlSystem + " - " + p_db.getSystemUser() + "/" + systemPassword; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", + pass, true, error); if (!pass) return error; log.info("OK: System Connection = " + urlSystem); @@ -126,8 +129,9 @@ public class ConfigFyracle extends Config String databasePassword = p_data.getDatabasePassword(); // PWD pass = databasePassword != null && databasePassword.length() > 0; error = "No Database User Password entered"; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, true, error); if (!pass) return error; // @@ -136,8 +140,9 @@ public class ConfigFyracle extends Config // Ignore result as it might not be imported pass = testJDBC(url, databaseUser, databasePassword); error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, false, error); if (pass) log.info("OK: Database User = " + databaseUser); else diff --git a/install/src/org/compiere/install/ConfigJBoss.java b/install/src/org/compiere/install/ConfigJBoss.java index c9ed32a3e3..48acdd029c 100644 --- a/install/src/org/compiere/install/ConfigJBoss.java +++ b/install/src/org/compiere/install/ConfigJBoss.java @@ -90,8 +90,9 @@ public class ConfigJBoss extends Config error += " - " + e.getMessage(); pass = false; } - signalOK(getPanel().okAppsServer, "ErrorAppsServer", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okAppsServer, "ErrorAppsServer", + pass, true, error); if (!pass) return error; log.info("OK: AppsServer = " + appsServer); @@ -103,8 +104,9 @@ public class ConfigJBoss extends Config File deploy = new File (p_data.getAppsServerDeployDir()); pass = deploy.exists(); error = "Not found: " + deploy; - signalOK(getPanel().okDeployDir, "ErrorDeployDir", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDeployDir, "ErrorDeployDir", + pass, true, error); if (!pass) return error; setProperty(ConfigurationData.ADEMPIERE_APPS_DEPLOY, p_data.getAppsServerDeployDir()); @@ -115,8 +117,9 @@ public class ConfigJBoss extends Config pass = !p_data.testPort (appsServer, JNPPort, false) && p_data.testServerPort(JNPPort); error = "Not correct: JNP Port = " + JNPPort; - signalOK(getPanel().okJNPPort, "ErrorJNPPort", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJNPPort, "ErrorJNPPort", + pass, true, error); if (!pass) return error; log.info("OK: JNPPort = " + JNPPort); @@ -127,8 +130,9 @@ public class ConfigJBoss extends Config pass = !p_data.testPort ("http", appsServer.getHostName(), WebPort, "/") && p_data.testServerPort(WebPort); error = "Not correct: Web Port = " + WebPort; - signalOK(getPanel().okWebPort, "ErrorWebPort", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okWebPort, "ErrorWebPort", + pass, true, error); if (!pass) return error; log.info("OK: Web Port = " + WebPort); @@ -139,8 +143,9 @@ public class ConfigJBoss extends Config pass = !p_data.testPort ("https", appsServer.getHostName(), sslPort, "/") && p_data.testServerPort(sslPort); error = "Not correct: SSL Port = " + sslPort; - signalOK(getPanel().okSSLPort, "ErrorWebPort", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okSSLPort, "ErrorWebPort", + pass, true, error); if (!pass) return error; log.info("OK: SSL Port = " + sslPort); diff --git a/install/src/org/compiere/install/ConfigOracle.java b/install/src/org/compiere/install/ConfigOracle.java index cba52e9268..b2d94a9661 100644 --- a/install/src/org/compiere/install/ConfigOracle.java +++ b/install/src/org/compiere/install/ConfigOracle.java @@ -299,8 +299,9 @@ public class ConfigOracle extends Config error += " - " + e.getMessage(); pass = false; } - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", + pass, true, error); log.info("OK: Database Server = " + databaseServer); setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, p_data.getDatabaseType()); @@ -309,9 +310,10 @@ public class ConfigOracle extends Config // Database Port int databasePort = p_data.getDatabasePort(); pass = p_data.testPort (databaseServer, databasePort, true); - error = "DB Server Port = " + databasePort; - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); + error = "DB Server Port = " + databasePort; + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", + pass, true, error); if (!pass) return error; log.info("OK: Database Port = " + databasePort); @@ -323,8 +325,9 @@ public class ConfigOracle extends Config String systemPassword = p_data.getDatabaseSystemPassword(); pass = systemPassword != null && systemPassword.length() > 0; error = "No Database System Password entered"; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", + pass, true, error); if (!pass) return error; // @@ -335,8 +338,9 @@ public class ConfigOracle extends Config pass = testJDBC(url, "system", systemPassword); error = "Error connecting: " + url + " - as system/" + systemPassword; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", + pass, true, error); if (!pass) return error; log.info("OK: Connection = " + url); @@ -351,15 +355,17 @@ public class ConfigOracle extends Config String databasePassword = p_data.getDatabasePassword(); // PWD pass = databasePassword != null && databasePassword.length() > 0; error = "Invalid Database User Password"; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, true, error); if (!pass) return error; // Ignore result as it might not be imported pass = testJDBC(url, databaseUser, databasePassword); error = "Cannot connect to User: " + databaseUser + "/" + databasePassword + " - Database may not be imported yet (OK on initial run)."; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, false, error); if (pass) { log.info("OK: Database User = " + databaseUser); @@ -380,8 +386,9 @@ public class ConfigOracle extends Config log.config(sqlplus); pass = testSQL(sqlplus); error = "Error connecting via: " + sqlplus; - signalOK(getPanel().okDatabaseSQL, "ErrorTNS", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseSQL, "ErrorTNS", + pass, true, error); if (pass) log.info("OK: Database SQL Connection"); } diff --git a/install/src/org/compiere/install/ConfigPostgreSQL.java b/install/src/org/compiere/install/ConfigPostgreSQL.java index c31dc0b652..47c30f551c 100755 --- a/install/src/org/compiere/install/ConfigPostgreSQL.java +++ b/install/src/org/compiere/install/ConfigPostgreSQL.java @@ -34,11 +34,11 @@ public class ConfigPostgreSQL extends Config public ConfigPostgreSQL (ConfigurationData data) { super (data); - } // ConfigSybase + } // ConfigPostgreSQL /** Discoverd TNS */ private String[] p_discovered = null; - /** Sybase DB Info */ + /** PostgreSQL DB Info */ private DB_PostgreSQL p_db = new DB_PostgreSQL(); /** @@ -88,8 +88,9 @@ public class ConfigPostgreSQL extends Config error += " - " + e.getMessage(); pass = false; } - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", + pass, true, error); log.info("OK: Database Server = " + databaseServer); setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, p_data.getDatabaseType()); @@ -98,9 +99,10 @@ public class ConfigPostgreSQL extends Config // Database Port int databasePort = p_data.getDatabasePort(); pass = p_data.testPort (databaseServer, databasePort, true); - error = "DB Server Port = " + databasePort; - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); + error = "DB Server Port = " + databasePort; + if (getPanel() != null) + signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", + pass, true, error); if (!pass) return error; log.info("OK: Database Port = " + databasePort); @@ -111,14 +113,15 @@ public class ConfigPostgreSQL extends Config String databaseName = p_data.getDatabaseName(); // Service Name String systemPassword = p_data.getDatabaseSystemPassword(); - // URL (derived) jdbc:sybase:Tds:prod1:5000/prod1 + // URL (derived) String urlSystem = p_db.getConnectionURL(databaseServer.getHostName(), databasePort, p_db.getSystemDatabase(databaseName), p_db.getSystemUser()); pass = testJDBC(urlSystem, p_db.getSystemUser(), systemPassword); error = "Error connecting: " + urlSystem + " - " + p_db.getSystemUser() + "/" + systemPassword; - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", + pass, true, error); if (!pass) return error; log.info("OK: System Connection = " + urlSystem); @@ -130,8 +133,9 @@ public class ConfigPostgreSQL extends Config String databasePassword = p_data.getDatabasePassword(); // PWD pass = databasePassword != null && databasePassword.length() > 0; error = "Invalid Database User Password"; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, true, error); if (!pass) return error; // @@ -140,8 +144,9 @@ public class ConfigPostgreSQL extends Config // Ignore result as it might not be imported pass = testJDBC(url, databaseUser, databasePassword); error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword; - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); + if (getPanel() != null) + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, false, error); if (pass) log.info("OK: Database User = " + databaseUser); else diff --git a/install/src/org/compiere/install/ConfigTomcat.java b/install/src/org/compiere/install/ConfigTomcat.java index 89965f7818..a1649d117a 100644 --- a/install/src/org/compiere/install/ConfigTomcat.java +++ b/install/src/org/compiere/install/ConfigTomcat.java @@ -101,8 +101,9 @@ public class ConfigTomcat extends Config error += " - " + e.getMessage(); pass = false; } - signalOK(getPanel().okAppsServer, "ErrorAppsServer", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okAppsServer, "ErrorAppsServer", + pass, true, error); if (!pass) return error; log.info("OK: AppsServer = " + appsServer); @@ -113,8 +114,9 @@ public class ConfigTomcat extends Config File deploy = new File (p_data.getAppsServerDeployDir()); pass = deploy.exists(); error = "CATALINA_HOME Not found: " + deploy; - signalOK(getPanel().okDeployDir, "ErrorDeployDir", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDeployDir, "ErrorDeployDir", + pass, true, error); if (!pass) return error; setProperty(ConfigurationData.ADEMPIERE_APPS_DEPLOY, p_data.getAppsServerDeployDir()); @@ -128,8 +130,9 @@ public class ConfigTomcat extends Config File sharedLibDir = new File (sharedLib); pass = sharedLibDir.exists(); error = "Not found (shared library): " + sharedLib; - signalOK(getPanel().okDeployDir, "ErrorDeployDir", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDeployDir, "ErrorDeployDir", + pass, true, error); if (!pass) return error; @@ -138,8 +141,9 @@ public class ConfigTomcat extends Config File webAppsDir = new File (webApps); pass = webAppsDir.exists(); error = "Not found (webapps): " + sharedLib; - signalOK(getPanel().okDeployDir, "ErrorDeployDir", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okDeployDir, "ErrorDeployDir", + pass, true, error); if (!pass) return error; // diff --git a/install/src/org/compiere/install/ConfigVMMac.java b/install/src/org/compiere/install/ConfigVMMac.java index 9387948fc2..94d70d3623 100644 --- a/install/src/org/compiere/install/ConfigVMMac.java +++ b/install/src/org/compiere/install/ConfigVMMac.java @@ -60,8 +60,9 @@ public class ConfigVMMac extends Config File javaHome = new File (p_data.getJavaHome()); boolean pass = javaHome.exists(); String error = "Not found: Java Home"; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJavaHome, "ErrorJavaHome", + pass, true, error); if (!pass) return error; /** Different VM structure @@ -101,8 +102,9 @@ public class ConfigVMMac extends Config log.info("OK: Version=" + thisJV); } error = "Wrong Java Version: Should be " + VERSION2; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJavaHome, "ErrorJavaHome", + pass, true, error); if (!pass) return error; // diff --git a/install/src/org/compiere/install/ConfigVMSun.java b/install/src/org/compiere/install/ConfigVMSun.java index 30c3d6b9dc..49908471fa 100644 --- a/install/src/org/compiere/install/ConfigVMSun.java +++ b/install/src/org/compiere/install/ConfigVMSun.java @@ -60,8 +60,9 @@ public class ConfigVMSun extends Config File javaHome = new File (p_data.getJavaHome()); boolean pass = javaHome.exists(); String error = "Not found: Java Home"; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJavaHome, "ErrorJavaHome", + pass, true, error); if (!pass) return error; // Look for tools.jar to make sure that it is not the JRE @@ -69,8 +70,9 @@ public class ConfigVMSun extends Config + File.separator + "lib" + File.separator + "tools.jar"); pass = tools.exists(); error = "Not found: Java SDK = " + tools; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJavaHome, "ErrorJavaHome", + pass, true, error); if (!pass) return error; // @@ -102,8 +104,9 @@ public class ConfigVMSun extends Config log.info("OK: Version=" + thisJV); } error = "Wrong Java Version: Should be " + VERSION2; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); + if (getPanel() != null) + signalOK(getPanel().okJavaHome, "ErrorJavaHome", + pass, true, error); if (!pass) return error; // diff --git a/install/src/org/compiere/install/ConfigurationData.java b/install/src/org/compiere/install/ConfigurationData.java index e27caa324a..327bdcb063 100644 --- a/install/src/org/compiere/install/ConfigurationData.java +++ b/install/src/org/compiere/install/ConfigurationData.java @@ -96,6 +96,18 @@ public class ConfigurationData public static final String ADEMPIERE_KEYSTORECODEALIAS = "ADEMPIERE_KEYSTORECODEALIAS"; /** */ public static final String ADEMPIERE_KEYSTOREWEBALIAS = "ADEMPIERE_KEYSTOREWEBALIAS"; + + public static final String ADEMPIERE_CERT_CN = "ADEMPIERE_CERT_CN"; + + public static final String ADEMPIERE_CERT_ORG = "ADEMPIERE_CERT_ORG"; + + public static final String ADEMPIERE_CERT_ORG_UNIT = "ADEMPIERE_CERT_ORG_UNIT"; + + public static final String ADEMPIERE_CERT_LOCATION = "ADEMPIERE_CERT_LOCATION"; + + public static final String ADEMPIERE_CERT_STATE = "ADEMPIERE_CERT_STATE"; + + public static final String ADEMPIERE_CERT_COUNTRY = "ADEMPIERE_CERT_COUNTRY"; /** DB Type */ public static final String ADEMPIERE_DB_TYPE = "ADEMPIERE_DB_TYPE"; @@ -142,6 +154,14 @@ public class ConfigurationData public static final String ADEMPIERE_WEBSTORES = "ADEMPIERE_WEBSTORES"; + private void updateProperty(String property, String value) { + if (value == null) value = ""; + String currentValue = (String)p_properties.get(property); + if (currentValue == null) + p_properties.put(property, value); + else if (!currentValue.equals(value)) + p_properties.put(property, value); + } /** * Load Configuration Data @@ -173,26 +193,29 @@ public class ConfigurationData if (p_properties.size() > 5) envLoaded = true; // - setJavaType((String)p_properties.get(JAVA_TYPE)); - initJava(); + int javaIndex = setJavaType((String)p_properties.get(JAVA_TYPE)); + initJava(javaIndex); setJavaHome((String)p_properties.get(JAVA_HOME)); // setAdempiereHome((String)p_properties.get(ADEMPIERE_HOME)); String s = (String)p_properties.get(ADEMPIERE_KEYSTOREPASS); if (s == null || s.length() == 0) + { s = KEYSTORE_PASSWORD; + p_properties.put(ADEMPIERE_KEYSTOREPASS, s); + } setKeyStore(s); // - setAppsServerType((String)p_properties.get(ADEMPIERE_APPS_TYPE)); - initAppsServer(); + int appServerIndex = setAppsServerType((String)p_properties.get(ADEMPIERE_APPS_TYPE)); + initAppsServer(appServerIndex); setAppsServer((String)p_properties.get(ADEMPIERE_APPS_SERVER)); setAppsServerDeployDir((String)p_properties.get(ADEMPIERE_APPS_DEPLOY)); setAppsServerJNPPort((String)p_properties.get(ADEMPIERE_JNP_PORT)); setAppsServerWebPort((String)p_properties.get(ADEMPIERE_WEB_PORT)); setAppsServerSSLPort((String)p_properties.get(ADEMPIERE_SSL_PORT)); // - setDatabaseType((String)p_properties.get(ADEMPIERE_DB_TYPE)); - initDatabase((String)p_properties.get(ADEMPIERE_DB_NAME)); // fills Database Options + int dbTypeIndex = setDatabaseType((String)p_properties.get(ADEMPIERE_DB_TYPE)); + initDatabase((String)p_properties.get(ADEMPIERE_DB_NAME), dbTypeIndex); // fills Database Options setDatabaseDiscovered((String)p_properties.get(ADEMPIERE_DB_NAME)); setDatabaseServer((String)p_properties.get(ADEMPIERE_DB_SERVER)); setDatabasePort((String)p_properties.get(ADEMPIERE_DB_PORT)); @@ -202,10 +225,13 @@ public class ConfigurationData setDatabasePassword((String)p_properties.get(ADEMPIERE_DB_PASSWORD)); setDatabaseSystemPassword((String)p_properties.get(ADEMPIERE_DB_SYSTEM)); - p_panel.fMailServer.setText((String)p_properties.get(ADEMPIERE_MAIL_SERVER)); - p_panel.fMailUser.setText((String)p_properties.get(ADEMPIERE_MAIL_USER)); - p_panel.fMailPassword.setText((String)p_properties.get(ADEMPIERE_MAIL_PASSWORD)); - p_panel.fAdminEMail.setText((String)p_properties.get(ADEMPIERE_ADMIN_EMAIL)); + if (p_panel != null) + { + p_panel.fMailServer.setText((String)p_properties.get(ADEMPIERE_MAIL_SERVER)); + p_panel.fMailUser.setText((String)p_properties.get(ADEMPIERE_MAIL_USER)); + p_panel.fMailPassword.setText((String)p_properties.get(ADEMPIERE_MAIL_PASSWORD)); + p_panel.fAdminEMail.setText((String)p_properties.get(ADEMPIERE_ADMIN_EMAIL)); + } } InetAddress localhost = null; @@ -243,10 +269,13 @@ public class ConfigurationData setDatabaseUser("adempiere"); setDatabasePassword("adempiere"); // Mail Server - p_panel.fMailServer.setText(hostName); - p_panel.fMailUser.setText("info"); - p_panel.fMailPassword.setText(""); - p_panel.fAdminEMail.setText("info@" + hostName); + if (p_panel != null) + { + p_panel.fMailServer.setText(hostName); + p_panel.fMailUser.setText("info"); + p_panel.fMailPassword.setText(""); + p_panel.fAdminEMail.setText("info@" + hostName); + } // } // !envLoaded @@ -308,7 +337,8 @@ public class ConfigurationData return false; } - p_panel.setStatusBar(p_panel.lAppsServer.getText()); + if (p_panel != null) + p_panel.setStatusBar(p_panel.lAppsServer.getText()); error = testAppsServer(); if (error != null) { @@ -316,7 +346,8 @@ public class ConfigurationData return false; } - p_panel.setStatusBar(p_panel.lDatabaseServer.getText()); + if (p_panel != null) + p_panel.setStatusBar(p_panel.lDatabaseServer.getText()); error = testDatabase(); if (error != null) { @@ -324,7 +355,8 @@ public class ConfigurationData return false; } - p_panel.setStatusBar(p_panel.lMailServer.getText()); + if (p_panel != null) + p_panel.setStatusBar(p_panel.lMailServer.getText()); error = testMail(); if (error != null) { @@ -346,8 +378,9 @@ public class ConfigurationData m_adempiereHome = new File (getAdempiereHome()); boolean pass =m_adempiereHome.exists(); String error = "Not found: AdempiereHome = " + m_adempiereHome; - p_panel.signalOK(p_panel.okAdempiereHome, "ErrorAdempiereHome", - pass, true, error); + if (p_panel != null) + p_panel.signalOK(p_panel.okAdempiereHome, "ErrorAdempiereHome", + pass, true, error); if (!pass) return error; log.info("OK: AdempiereHome = " + m_adempiereHome); @@ -359,19 +392,33 @@ public class ConfigurationData p_properties.setProperty(ADEMPIERE_KEYSTORE, fileName); // KeyStore Password - String pw = new String(p_panel.fKeyStore.getPassword()); + String pw = p_panel != null + ? new String(p_panel.fKeyStore.getPassword()) + : (String)p_properties.get(ADEMPIERE_KEYSTOREPASS); pass = pw != null && pw.length() > 0; error = "Invalid Key Store Password = " + pw; - p_panel.signalOK(p_panel.okKeyStore, "KeyStorePassword", - pass, true, error); + if (p_panel != null) + p_panel.signalOK(p_panel.okKeyStore, "KeyStorePassword", + pass, true, error); if (!pass) return error; p_properties.setProperty(ADEMPIERE_KEYSTOREPASS, pw); - KeyStoreMgt ks = new KeyStoreMgt (fileName, p_panel.fKeyStore.getPassword()); - error = ks.verify((JFrame)SwingUtilities.getWindowAncestor(p_panel)); + KeyStoreMgt ks = p_panel != null + ? new KeyStoreMgt (fileName, p_panel.fKeyStore.getPassword()) + : new KeyStoreMgt (fileName, pw.toCharArray()); + ks.setCommonName((String)p_properties.getProperty(ADEMPIERE_CERT_CN)); + ks.setOrganization((String)p_properties.getProperty(ADEMPIERE_CERT_ORG)); + ks.setOrganizationUnit((String)p_properties.getProperty(ADEMPIERE_CERT_ORG_UNIT)); + ks.setLocation((String)p_properties.getProperty(ADEMPIERE_CERT_LOCATION)); + ks.setState((String)p_properties.getProperty(ADEMPIERE_CERT_STATE)); + ks.setCountry((String)p_properties.getProperty(ADEMPIERE_CERT_COUNTRY)); + error = p_panel != null + ? ks.verify((JFrame)SwingUtilities.getWindowAncestor(p_panel)) + : ks.verify(null); pass = error == null; - p_panel.signalOK(p_panel.okKeyStore, "KeyStorePassword", - pass, true, error); + if (p_panel != null) + p_panel.signalOK(p_panel.okKeyStore, "KeyStorePassword", + pass, true, error); if (!pass) return error; log.info("OK: KeyStore = " + fileName); @@ -386,7 +433,9 @@ public class ConfigurationData private String testMail() { // Mail Server - String server = p_panel.fMailServer.getText(); + String server = p_panel != null + ? p_panel.fMailServer.getText() + : (String)p_properties.get(ADEMPIERE_MAIL_SERVER); boolean pass = server != null && server.length() > 0 && server.toLowerCase().indexOf("localhost") == -1 && !server.equals("127.0.0.1"); @@ -402,8 +451,9 @@ public class ConfigurationData error += " - " + e.getMessage(); pass = false; } - p_panel.signalOK(p_panel.okMailServer, "ErrorMailServer", - pass, true, error); + if (p_panel != null) + p_panel.signalOK(p_panel.okMailServer, "ErrorMailServer", + pass, true, error); if (!pass) { p_properties.setProperty(ADEMPIERE_MAIL_SERVER, ""); @@ -412,13 +462,19 @@ public class ConfigurationData p_properties.setProperty(ADEMPIERE_MAIL_SERVER, mailServer.getHostName()); // Mail User - String mailUser = p_panel.fMailUser.getText(); - String mailPassword = new String(p_panel.fMailPassword.getPassword()); + String mailUser = p_panel != null + ? p_panel.fMailUser.getText() + : (String)p_properties.get(ADEMPIERE_MAIL_USER); + String mailPassword = p_panel != null + ? new String(p_panel.fMailPassword.getPassword()) + : (String)p_properties.get(ADEMPIERE_MAIL_PASSWORD); // m_errorString = "ErrorMailUser"; // log.config("Mail User = " + mailUser + "/" + mailPassword); // Mail Address - String adminEMailString = p_panel.fAdminEMail.getText(); + String adminEMailString = p_panel != null + ? p_panel.fAdminEMail.getText() + : (String)p_properties.get(ADEMPIERE_ADMIN_EMAIL); InternetAddress adminEMail = null; try { @@ -435,8 +491,9 @@ public class ConfigurationData error = "Not verified EMail = " + adminEMail; pass = testMailServer(mailServer, adminEMail, mailUser, mailPassword); } - p_panel.signalOK(p_panel.okMailUser, "ErrorMail", - pass, false, error); + if (p_panel != null) + p_panel.signalOK(p_panel.okMailUser, "ErrorMail", + pass, false, error); if (pass) { log.info("OK: EMail = " + adminEMail); @@ -492,8 +549,9 @@ public class ConfigurationData if (!smtpOK) { String error = "No active Mail Server"; - p_panel.signalOK (p_panel.okMailServer, "ErrorMailServer", - false, false, error); + if (p_panel != null) + p_panel.signalOK (p_panel.okMailServer, "ErrorMailServer", + false, false, error); log.warning(error); return false; } @@ -707,19 +765,25 @@ public class ConfigurationData catch (Exception e) { log.severe("Cannot save Properties to " + fileName + " - " + e.toString()); - JOptionPane.showConfirmDialog(p_panel, - ConfigurationPanel.res.getString("ErrorSave"), - ConfigurationPanel.res.getString("AdempiereServerSetup"), - JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); + if (p_panel != null) + JOptionPane.showConfirmDialog(p_panel, + ConfigurationPanel.res.getString("ErrorSave"), + ConfigurationPanel.res.getString("AdempiereServerSetup"), + JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); + else + System.err.println(ConfigurationPanel.res.getString("ErrorSave")); return false; } catch (Throwable t) { log.severe("Cannot save Properties to " + fileName + " - " + t.toString()); - JOptionPane.showConfirmDialog(p_panel, - ConfigurationPanel.res.getString("ErrorSave"), - ConfigurationPanel.res.getString("AdempiereServerSetup"), - JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); + if (p_panel != null) + JOptionPane.showConfirmDialog(p_panel, + ConfigurationPanel.res.getString("ErrorSave"), + ConfigurationPanel.res.getString("AdempiereServerSetup"), + JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); + else + System.err.println(ConfigurationPanel.res.getString("ErrorSave")); return false; } log.info(fileName); @@ -736,11 +800,7 @@ public class ConfigurationData // Create Connection String ccType = Database.DB_ORACLE; - if (getDatabaseType().equals(DBTYPE_MS)) - ccType = Database.DB_MSSQLServer; - else if (getDatabaseType().equals(DBTYPE_DB2)) - ccType = Database.DB_DB2; - else if (getDatabaseType().equals(DBTYPE_DERBY)) + if (getDatabaseType().equals(DBTYPE_DERBY)) ccType = Database.DB_DERBY; //begin vpj-cd e-evolution 03/17/2005 PostgreSQL else if (getDatabaseType().equals(DBTYPE_POSTGRESQL)) @@ -755,7 +815,7 @@ public class ConfigurationData cc = CConnection.get (ccType, getDatabaseServer(), getDatabasePort(), getDatabaseName(), getDatabaseUser(), getDatabasePassword()); - cc.setAppsHost(p_panel.fAppsServer.getText()); + cc.setAppsHost(getAppsServer()); cc.setConnectionProfile(CConnection.PROFILE_LAN); } catch(Exception e) @@ -789,7 +849,9 @@ public class ConfigurationData */ public String getAdempiereHome() { - return p_panel.fAdempiereHome.getText(); + return p_panel != null + ? p_panel.fAdempiereHome.getText() + : (String)p_properties.get(ADEMPIERE_HOME); } // getAdempiereHome /** @@ -798,7 +860,10 @@ public class ConfigurationData */ public void setAdempiereHome (String adempiereHome) { - p_panel.fAdempiereHome.setText(adempiereHome); + if (p_panel != null) + p_panel.fAdempiereHome.setText(adempiereHome); + else + updateProperty(ADEMPIERE_HOME, adempiereHome); } // setAdempiereHome /** @@ -819,7 +884,10 @@ public class ConfigurationData */ public void setKeyStore (String password) { - p_panel.fKeyStore.setText(password); + if (p_panel != null) + p_panel.fKeyStore.setText(password); + else + updateProperty(ADEMPIERE_KEYSTOREPASS, password); } // setKeyStore @@ -845,17 +913,23 @@ public class ConfigurationData */ public void initJava() { - int index = p_panel.fJavaType.getSelectedIndex(); + int index = (p_panel != null ? p_panel.fJavaType.getSelectedIndex() : 0); + initJava(index); + } // initDatabase + + private void initJava(int index) + { if (index < 0 || index >= JAVATYPE.length) log.warning("JavaType Index invalid: " + index); else if (m_javaConfig[index] == null) { log.warning("JavaType Config missing: " + JAVATYPE[index]); - p_panel.fJavaType.setSelectedIndex(0); + if (p_panel != null) + p_panel.fJavaType.setSelectedIndex(0); } else m_javaConfig[index].init(); - } // initDatabase + } /** * Test Java @@ -863,7 +937,9 @@ public class ConfigurationData */ public String testJava() { - int index = p_panel.fJavaType.getSelectedIndex(); + int index = p_panel != null + ? p_panel.fJavaType.getSelectedIndex() + : setJavaType((String)p_properties.get(JAVA_TYPE)); if (index < 0 || index >= JAVATYPE.length) return "JavaType Index invalid: " + index; else if (m_javaConfig[index] == null) @@ -875,7 +951,7 @@ public class ConfigurationData * Set Java Type * @param javaType The javaType to set. */ - public void setJavaType (String javaType) + public int setJavaType (String javaType) { int index = -1; for (int i = 0; i < JAVATYPE.length; i++) @@ -891,7 +967,12 @@ public class ConfigurationData index = 0; log.warning("Invalid JavaType=" + javaType); } - p_panel.fJavaType.setSelectedIndex(index); + if (p_panel != null) + p_panel.fJavaType.setSelectedIndex(index); + else + updateProperty(JAVA_TYPE, javaType); + + return index; } // setJavaType /** @@ -899,7 +980,10 @@ public class ConfigurationData */ public String getJavaType () { - return (String)p_panel.fJavaType.getSelectedItem(); + if( p_panel != null ) + return (String)p_panel.fJavaType.getSelectedItem(); + else + return (String)p_properties.get(JAVA_TYPE); } /** @@ -907,14 +991,20 @@ public class ConfigurationData */ public String getJavaHome () { - return p_panel.fJavaHome.getText(); + if (p_panel != null) + return p_panel.fJavaHome.getText(); + else + return (String)p_properties.get(JAVA_HOME); } /** * @param javaHome The javaHome to set. */ public void setJavaHome (String javaHome) { - p_panel.fJavaHome.setText(javaHome); + if (p_panel != null) + p_panel.fJavaHome.setText(javaHome); + else + updateProperty(JAVA_HOME, javaHome); } /************************************************************************** @@ -943,7 +1033,12 @@ public class ConfigurationData */ public void initAppsServer() { - int index = p_panel.fAppsType.getSelectedIndex(); + int index = (p_panel != null ? p_panel.fAppsType.getSelectedIndex() : 0); + initAppsServer(index); + } // initAppsServer + + private void initAppsServer(int index) + { if (index < 0 || index >= APPSTYPE.length) log.warning("AppsServerType Index invalid: " + index); else if (m_appsConfig[index] == null) @@ -953,7 +1048,7 @@ public class ConfigurationData } else m_appsConfig[index].init(); - } // initAppsServer + } /** * Test Apps Server @@ -961,7 +1056,9 @@ public class ConfigurationData */ public String testAppsServer() { - int index = p_panel.fAppsType.getSelectedIndex(); + int index = p_panel != null + ? p_panel.fAppsType.getSelectedIndex() + : setAppsServerType((String)p_properties.get(ADEMPIERE_APPS_TYPE)); if (index < 0 || index >= APPSTYPE.length) return "AppsServerType Index invalid: " + index; else if (m_appsConfig[index] == null) @@ -974,7 +1071,7 @@ public class ConfigurationData * Set Apps Server Type * @param appsType The appsType to set. */ - public void setAppsServerType (String appsType) + public int setAppsServerType (String appsType) { int index = -1; for (int i = 0; i < APPSTYPE.length; i++) @@ -990,7 +1087,12 @@ public class ConfigurationData index = 0; log.warning("Invalid AppsType=" + appsType); } - p_panel.fAppsType.setSelectedIndex(index); + if (p_panel != null) + p_panel.fAppsType.setSelectedIndex(index); + else + updateProperty(ADEMPIERE_APPS_TYPE, appsType); + + return index; } // setAppsServerType /** @@ -999,7 +1101,9 @@ public class ConfigurationData */ public String getAppsServerType () { - return (String)p_panel.fAppsType.getSelectedItem(); + return p_panel != null + ? (String)p_panel.fAppsType.getSelectedItem() + : (String)p_properties.get(ADEMPIERE_APPS_TYPE); } // setDatabaseType /** @@ -1007,14 +1111,19 @@ public class ConfigurationData */ public String getAppsServer () { - return p_panel.fAppsServer.getText(); + return p_panel != null + ? p_panel.fAppsServer.getText() + : (String)p_properties.get(ADEMPIERE_APPS_SERVER); } /** * @param appsServer The appsServer to set. */ public void setAppsServer (String appsServer) { - p_panel.fAppsServer.setText(appsServer); + if (p_panel != null) + p_panel.fAppsServer.setText(appsServer); + else + updateProperty(ADEMPIERE_APPS_SERVER, appsServer); } /** @@ -1022,31 +1131,42 @@ public class ConfigurationData */ public String getAppsServerDeployDir () { - return p_panel.fDeployDir.getText(); + return p_panel != null + ? p_panel.fDeployDir.getText() + : (String)p_properties.get(ADEMPIERE_APPS_DEPLOY); } /** * @param appsServerDeployDir The appsServerDeployDir to set. */ public void setAppsServerDeployDir (String appsServerDeployDir) { - p_panel.fDeployDir.setText(appsServerDeployDir); + if (p_panel != null) + p_panel.fDeployDir.setText(appsServerDeployDir); + else + updateProperty(ADEMPIERE_APPS_DEPLOY, appsServerDeployDir); } /** * @param enable if true enable entry */ public void setAppsServerDeployDir (boolean enable) { - p_panel.fDeployDir.setEnabled(enable); - p_panel.bDeployDir.setEnabled(enable); + if (p_panel != null) + { + p_panel.fDeployDir.setEnabled(enable); + p_panel.bDeployDir.setEnabled(enable); + } } /** * @return Returns the appsServerJNPPort. */ public int getAppsServerJNPPort () { + String port = p_panel != null + ? p_panel.fJNPPort.getText() + : (String)p_properties.get(ADEMPIERE_JNP_PORT); try { - return Integer.parseInt(p_panel.fJNPPort.getText()); + return Integer.parseInt(port); } catch (Exception e) { @@ -1059,23 +1179,31 @@ public class ConfigurationData */ public void setAppsServerJNPPort (String appsServerJNPPort) { - p_panel.fJNPPort.setText(appsServerJNPPort); + if (p_panel != null) + p_panel.fJNPPort.setText(appsServerJNPPort); + else + updateProperty(ADEMPIERE_JNP_PORT, appsServerJNPPort); } + /** * @param enable if enable JNP entry */ public void setAppsServerJNPPort (boolean enable) { - p_panel.fJNPPort.setEnabled(enable); + if (p_panel != null) + p_panel.fJNPPort.setEnabled(enable); } /** * @return Returns the appsServerSSLPort. */ public int getAppsServerSSLPort () { + String port = p_panel != null + ? p_panel.fSSLPort.getText() + : (String)p_properties.get(ADEMPIERE_SSL_PORT); try { - return Integer.parseInt(p_panel.fSSLPort.getText()); + return Integer.parseInt(port); } catch (Exception e) { @@ -1088,23 +1216,30 @@ public class ConfigurationData */ public void setAppsServerSSLPort (String appsServerSSLPort) { - p_panel.fSSLPort.setText(appsServerSSLPort); + if (p_panel != null) + p_panel.fSSLPort.setText(appsServerSSLPort); + else + updateProperty(ADEMPIERE_SSL_PORT, appsServerSSLPort); } /** * @param enable if tre enable SSL entry */ public void setAppsServerSSLPort (boolean enable) { - p_panel.fSSLPort.setEnabled(enable); + if (p_panel != null) + p_panel.fSSLPort.setEnabled(enable); } /** * @return Returns the appsServerWebPort. */ public int getAppsServerWebPort () { + String port = p_panel != null + ? p_panel.fWebPort.getText() + : (String)p_properties.get(ADEMPIERE_WEB_PORT); try { - return Integer.parseInt(p_panel.fWebPort.getText()); + return Integer.parseInt(port); } catch (Exception e) { @@ -1117,14 +1252,18 @@ public class ConfigurationData */ public void setAppsServerWebPort (String appsServerWebPort) { - p_panel.fWebPort.setText(appsServerWebPort); + if (p_panel != null) + p_panel.fWebPort.setText(appsServerWebPort); + else + updateProperty(ADEMPIERE_WEB_PORT, appsServerWebPort); } /** * @param enable if tre enable Web entry */ public void setAppsServerWebPort (boolean enable) { - p_panel.fWebPort.setEnabled(enable); + if (p_panel != null) + p_panel.fWebPort.setEnabled(enable); } @@ -1138,10 +1277,6 @@ public class ConfigurationData private static String DBTYPE_ORACLE = "oracle"; /** Oracle XP */ private static String DBTYPE_ORACLEXE = "oracleXE"; - /** DB/2 */ - private static String DBTYPE_DB2 = ""; - /** MS SQL Server */ - private static String DBTYPE_MS = ""; // begin e-evolution vpj-cd 02/07/2005 PostgreSQL /** PostgreSQL */ @@ -1155,8 +1290,6 @@ public class ConfigurationData static String[] DBTYPE = new String[] {DBTYPE_ORACLEXE, DBTYPE_ORACLE, - //DBTYPE_DB2, - //DBTYPE_MS, DBTYPE_FYRACLE, //begin e-evolution vpj-cd 02/07/2005 PostgreSQL DBTYPE_POSTGRESQL @@ -1169,7 +1302,6 @@ public class ConfigurationData { new ConfigOracle(this,true), new ConfigOracle(this,false), - //new ConfigDB2(this), //begin e-evolution vpj-cd 02/07/2005 PostgreSQL //null //null, @@ -1185,25 +1317,34 @@ public class ConfigurationData */ public void initDatabase(String selected) { - int index = p_panel.fDatabaseType.getSelectedIndex(); + int index = (p_panel != null ? p_panel.fDatabaseType.getSelectedIndex() : 0); + initDatabase(selected, index); + } // initDatabase + + private void initDatabase(String selected, int index) + { if (index < 0 || index >= DBTYPE.length) log.warning("DatabaseType Index invalid: " + index); else if (m_databaseConfig[index] == null) { log.warning("DatabaseType Config missing: " + DBTYPE[index]); - p_panel.fDatabaseType.setSelectedIndex(0); + if (p_panel != null) + p_panel.fDatabaseType.setSelectedIndex(0); } else { m_databaseConfig[index].init(); - String[] databases = m_databaseConfig[index].discoverDatabases(selected); - DefaultComboBoxModel model = new DefaultComboBoxModel(databases); - p_panel.fDatabaseDiscovered.setModel(model); - p_panel.fDatabaseDiscovered.setEnabled(databases.length != 0); - if (databases.length > 0) - p_panel.fDatabaseName.setText(databases[0]); + if (p_panel != null) + { + String[] databases = m_databaseConfig[index].discoverDatabases(selected); + DefaultComboBoxModel model = new DefaultComboBoxModel(databases); + p_panel.fDatabaseDiscovered.setModel(model); + p_panel.fDatabaseDiscovered.setEnabled(databases.length != 0); + if (databases.length > 0) + p_panel.fDatabaseName.setText(databases[0]); + } } - } // initDatabase + } /** * Test Database @@ -1211,7 +1352,9 @@ public class ConfigurationData */ public String testDatabase() { - int index = p_panel.fDatabaseType.getSelectedIndex(); + int index = p_panel != null + ? p_panel.fDatabaseType.getSelectedIndex() + : setDatabaseType((String)p_properties.get(ADEMPIERE_DB_TYPE)); if (index < 0 || index >= DBTYPE.length) return "DatabaseType Index invalid: " + index; else if (m_databaseConfig[index] == null) @@ -1224,7 +1367,7 @@ public class ConfigurationData * Set Database Type * @param databaseType The databaseType to set. */ - public void setDatabaseType (String databaseType) + public int setDatabaseType (String databaseType) { int index = -1; for (int i = 0; i < DBTYPE.length; i++) @@ -1240,7 +1383,12 @@ public class ConfigurationData index = 0; log.warning("Invalid DatabaseType=" + databaseType); } - p_panel.fDatabaseType.setSelectedIndex(index); + if (p_panel != null) + p_panel.fDatabaseType.setSelectedIndex(index); + else + updateProperty(ADEMPIERE_DB_TYPE, databaseType); + + return index; } // setDatabaseType /** @@ -1248,7 +1396,9 @@ public class ConfigurationData */ public String getDatabaseType () { - return (String)p_panel.fDatabaseType.getSelectedItem(); + return p_panel != null + ? (String)p_panel.fDatabaseType.getSelectedItem() + : (String)p_properties.get(ADEMPIERE_DB_TYPE); } /** * @return Returns the database Discovered. @@ -1262,7 +1412,8 @@ public class ConfigurationData */ public void setDatabaseDiscovered (String databaseDiscovered) { - p_panel.fDatabaseDiscovered.setSelectedItem(databaseDiscovered); + if (p_panel != null) + p_panel.fDatabaseDiscovered.setSelectedItem(databaseDiscovered); } /** @@ -1270,14 +1421,19 @@ public class ConfigurationData */ public String getDatabaseName () { - return p_panel.fDatabaseName.getText(); + return p_panel != null + ? p_panel.fDatabaseName.getText() + : (String)p_properties.get(ADEMPIERE_DB_NAME); } /** * @param databaseName The databaseName to set. */ public void setDatabaseName (String databaseName) { - p_panel.fDatabaseName.setText(databaseName); + if (p_panel != null) + p_panel.fDatabaseName.setText(databaseName); + else + updateProperty(ADEMPIERE_DB_NAME, databaseName); } /** @@ -1285,26 +1441,40 @@ public class ConfigurationData */ public String getDatabasePassword () { - char[] pw = p_panel.fDatabasePassword.getPassword(); - if (pw != null) - return new String(pw); - return ""; + if (p_panel != null) + { + char[] pw = p_panel.fDatabasePassword.getPassword(); + if (pw != null) + return new String(pw); + return ""; + } + else + { + String pw = (String)p_properties.get(ADEMPIERE_DB_PASSWORD); + return (pw != null ? pw : ""); + } } /** * @param databasePassword The databasePassword to set. */ public void setDatabasePassword (String databasePassword) { - p_panel.fDatabasePassword.setText(databasePassword); + if (p_panel != null) + p_panel.fDatabasePassword.setText(databasePassword); + else + updateProperty(ADEMPIERE_DB_PASSWORD, databasePassword); } /** * @return Returns the databasePort. */ public int getDatabasePort () { + String port = p_panel != null + ? p_panel.fDatabasePort.getText() + : (String)p_properties.get(ADEMPIERE_DB_PORT); try { - return Integer.parseInt(p_panel.fDatabasePort.getText()); + return Integer.parseInt(port); } catch (Exception e) { @@ -1317,59 +1487,84 @@ public class ConfigurationData */ public void setDatabasePort (String databasePort) { - p_panel.fDatabasePort.setText(databasePort); + if (p_panel != null) + p_panel.fDatabasePort.setText(databasePort); + else + updateProperty(ADEMPIERE_DB_PORT, databasePort); } /** * @return Returns the databaseServer. */ public String getDatabaseServer () { - return p_panel.fDatabaseServer.getText(); + return p_panel != null + ? p_panel.fDatabaseServer.getText() + : (String)p_properties.get(ADEMPIERE_DB_SERVER); } /** * @param databaseServer The databaseServer to set. */ public void setDatabaseServer (String databaseServer) { - p_panel.fDatabaseServer.setText(databaseServer); + if (p_panel != null) + p_panel.fDatabaseServer.setText(databaseServer); + else + updateProperty(ADEMPIERE_DB_SERVER, databaseServer); } /** * @return Returns the databaseSystemPassword. */ public String getDatabaseSystemPassword () { - char[] pw = p_panel.fSystemPassword.getPassword(); - if (pw != null) - return new String(pw); - return ""; + if (p_panel != null) + { + char[] pw = p_panel.fSystemPassword.getPassword(); + if (pw != null) + return new String(pw); + return ""; + } + else + { + String pw = (String)p_properties.get(ADEMPIERE_DB_SYSTEM); + return (pw != null ? pw : ""); + } } /** * @param databaseSystemPassword The databaseSystemPassword to set. */ public void setDatabaseSystemPassword (String databaseSystemPassword) { - p_panel.fSystemPassword.setText(databaseSystemPassword); + if (p_panel != null) + p_panel.fSystemPassword.setText(databaseSystemPassword); + else + updateProperty(ADEMPIERE_DB_SYSTEM, databaseSystemPassword); } /** * @param enable enable Database System Password */ public void setDatabaseSystemPassword (boolean enable) { - p_panel.fSystemPassword.setEnabled(enable); + if (p_panel != null) + p_panel.fSystemPassword.setEnabled(enable); } /** * @return Returns the databaseUser. */ public String getDatabaseUser () { - return p_panel.fDatabaseUser.getText(); + return p_panel != null + ? p_panel.fDatabaseUser.getText() + : (String)p_properties.get(ADEMPIERE_DB_USER); } /** * @param databaseUser The databaseUser to set. */ public void setDatabaseUser (String databaseUser) { - p_panel.fDatabaseUser.setText(databaseUser); + if (p_panel != null) + p_panel.fDatabaseUser.setText(databaseUser); + else + updateProperty(ADEMPIERE_DB_USER, databaseUser); } } // ConfigurationData diff --git a/install/src/org/compiere/install/KeyStoreMgt.java b/install/src/org/compiere/install/KeyStoreMgt.java index 765c7efd7d..2c08f34c5f 100644 --- a/install/src/org/compiere/install/KeyStoreMgt.java +++ b/install/src/org/compiere/install/KeyStoreMgt.java @@ -55,6 +55,12 @@ public class KeyStoreMgt private char[] m_password = null; /** KeyStore */ private KeyStore m_keyStore = null; + private String organizationUnit; + private String location; + private String state; + private String country; + private String commonName; + private String organization; /** Directory below ADEMPIERE_HOME */ @@ -210,7 +216,7 @@ public class KeyStoreMgt log.log(Level.SEVERE, "directory", e); } - String dname = getDname(parent); + String dname = getDname(this, parent); if (dname == null) return; // @@ -225,27 +231,71 @@ public class KeyStoreMgt } } // createCertificate + public void setCommonName(String cn) + { + commonName = cn; + } + + public void setOrganization(String o) + { + organization = o; + } + + public void setOrganizationUnit(String o) + { + organizationUnit = o; + } + + public void setLocation(String l) + { + location = l; + } + + public void setState(String s) + { + state = s; + } + + public void setCountry(String c) + { + country = c; + } + /** * Get Distinguised Name * @param parent interactive dialog * @return dname or null */ - public static String getDname(JFrame parent) + public static String getDname(KeyStoreMgt mgt, JFrame parent) { - String cn = null; - try + String cn = mgt.commonName; + if (cn == null) { - InetAddress address = InetAddress.getLocalHost(); - cn = address.getCanonicalHostName(); + try + { + InetAddress address = InetAddress.getLocalHost(); + cn = address.getCanonicalHostName(); + } + catch (Exception e) + { + } } - catch (Exception e) - { - } - String ou = System.getProperty("user.name"); - String o = "AdempiereUser"; - String l = "MyTown"; - String s = ""; - String c = System.getProperty("user.country"); + + String ou = mgt.organization != null + ? mgt.organization + : System.getProperty("user.name"); + String o = mgt.organizationUnit != null + ? mgt.organizationUnit + : "AdempiereUser"; + String l = mgt.location != null + ? mgt.location + : "MyTown"; + String s = mgt.state != null + ? mgt.state + : ""; + String c = mgt.country != null + ? mgt.country + : System.getProperty("user.country"); // if (parent != null) { @@ -260,6 +310,7 @@ public class KeyStoreMgt s = skd.getS(); c = skd.getC(); } + // if (cn == null || cn.length() == 0) { diff --git a/install/src/org/compiere/install/SilentSetup.java b/install/src/org/compiere/install/SilentSetup.java new file mode 100644 index 0000000000..b84bd1f78c --- /dev/null +++ b/install/src/org/compiere/install/SilentSetup.java @@ -0,0 +1,73 @@ +package org.compiere.install; + +import java.io.File; +import java.util.logging.Handler; +import java.util.logging.Level; + +import org.apache.tools.ant.Main; +import org.compiere.util.CLogFile; +import org.compiere.util.CLogMgt; +import org.compiere.util.CLogger; +import org.compiere.util.Ini; + +public class SilentSetup { + + public SilentSetup() + { + //Load C:\Adempiere\AdempiereEnv.properties + String adempiereHome = System.getProperty(ConfigurationData.ADEMPIERE_HOME); + if (adempiereHome == null || adempiereHome.length() == 0) + adempiereHome = System.getProperty("user.dir"); + + boolean envLoaded = false; + String fileName = adempiereHome + File.separator + ConfigurationData.ADEMPIERE_ENV_FILE; + File env = new File(fileName); + if (!env.exists()) + { + System.err.println("Usage: Please edit AdempiereEnvTemplate.properties and save as AdempiereEnv.properties"); + return; + } + + Ini.setShowLicenseDialog(false); + ConfigurationData data = new ConfigurationData(null); + if (!data.load()) return; + if (!data.test()) return; + if (!data.save()) return; + + /** Run Ant **/ + try + { + CLogger.get().info("Starting Ant ... "); + System.setProperty("ant.home", "."); + String[] args = new String[] {"setup"}; + // Launcher.main (args); // calls System.exit + Main antMain = new Main(); + antMain.startAnt(args, null, null); + } + catch (Exception e) + { + CLogger.get().log(Level.SEVERE, "ant", e); + } + } + + /** + * Start + * @param args Log Level e.g. ALL, FINE + */ + public static void main(String[] args) + { + CLogMgt.initialize(true); + Handler fileHandler = new CLogFile(System.getProperty("user.dir"), false, false); + CLogMgt.addHandler(fileHandler); + // Log Level + if (args.length > 0) + CLogMgt.setLevel(args[0]); + else + CLogMgt.setLevel(Level.INFO); + // File Loger at least FINE + if (fileHandler.getLevel().intValue() > Level.FINE.intValue()) + fileHandler.setLevel(Level.FINE); + + new SilentSetup(); + } // main +}