From af5cd44af87cc454471c565d19c211d74df7552f Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 29 Nov 2010 01:59:28 +0800 Subject: [PATCH] Implemented db configuration as extension. Remove JVM type checking. --- org.adempiere.install/META-INF/MANIFEST.MF | 3 +- org.adempiere.install/build.xml | 41 +++++ org.adempiere.install/install.app.launch | 8 +- .../install.console.app.launch | 6 +- org.adempiere.install/plugin.xml | 1 + ...org.adempiere.install.IDatabaseConfig.exsd | 109 +++++++++++ .../org/adempiere/install/DBConfigStatus.java | 122 ++++++++++++ .../adempiere/install/IDBConfigMonitor.java | 28 +++ .../adempiere/install/IDatabaseConfig.java | 54 ++++++ .../src/org/compiere/install/Config.java | 70 +------ .../{ConfigVMOpenJDK.java => ConfigVM.java} | 63 +++---- .../src/org/compiere/install/ConfigVMMac.java | 117 ------------ .../src/org/compiere/install/ConfigVMSun.java | 118 ------------ .../compiere/install/ConfigurationData.java | 174 +++++++++--------- .../compiere/install/ConfigurationPanel.java | 74 ++++---- .../src/org/compiere/install/SilentSetup.java | 12 +- .../install/console/ConfigurationConsole.java | 54 +----- org.adempiere.server-feature/build.xml | 1 - .../server.product.launch | 4 +- .../META-INF/MANIFEST.MF | 3 +- org.compiere.db.oracle.provider/plugin.xml | 9 + .../db/oracle/config}/ConfigOracle.java | 143 +++++++------- .../META-INF/MANIFEST.MF | 3 +- .../plugin.xml | 9 + .../postgresql/config}/ConfigPostgreSQL.java | 117 ++++++------ 25 files changed, 685 insertions(+), 658 deletions(-) create mode 100644 org.adempiere.install/build.xml create mode 100644 org.adempiere.install/schema/org.adempiere.install.IDatabaseConfig.exsd create mode 100644 org.adempiere.install/src/org/adempiere/install/DBConfigStatus.java create mode 100644 org.adempiere.install/src/org/adempiere/install/IDBConfigMonitor.java create mode 100644 org.adempiere.install/src/org/adempiere/install/IDatabaseConfig.java rename org.adempiere.install/src/org/compiere/install/{ConfigVMOpenJDK.java => ConfigVM.java} (66%) delete mode 100644 org.adempiere.install/src/org/compiere/install/ConfigVMMac.java delete mode 100644 org.adempiere.install/src/org/compiere/install/ConfigVMSun.java rename {org.adempiere.install/src/org/compiere/install => org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config}/ConfigOracle.java (78%) rename {org.adempiere.install/src/org/compiere/install => org.compiere.db.postgresql.provider/src/org/adempiere/db/postgresql/config}/ConfigPostgreSQL.java (60%) diff --git a/org.adempiere.install/META-INF/MANIFEST.MF b/org.adempiere.install/META-INF/MANIFEST.MF index ba9cf01f58..24b78d5e81 100644 --- a/org.adempiere.install/META-INF/MANIFEST.MF +++ b/org.adempiere.install/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Bundle-SymbolicName: org.adempiere.install;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-ClassPath: install.jar, ant-contrib-1.0b3.jar -Export-Package: org.compiere.install +Export-Package: org.adempiere.install, + org.compiere.install Require-Bundle: org.adempiere.base;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: javax.mail;version="1.4.0", diff --git a/org.adempiere.install/build.xml b/org.adempiere.install/build.xml new file mode 100644 index 0000000000..fa02272fb4 --- /dev/null +++ b/org.adempiere.install/build.xml @@ -0,0 +1,41 @@ + + + + + + + + This buildfile is used to setup the Adempiere Environment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.adempiere.install/install.app.launch b/org.adempiere.install/install.app.launch index 9b74393e20..b9d923a622 100644 --- a/org.adempiere.install/install.app.launch +++ b/org.adempiere.install/install.app.launch @@ -10,17 +10,17 @@ - + - + - - + + diff --git a/org.adempiere.install/install.console.app.launch b/org.adempiere.install/install.console.app.launch index 88d0ad29d9..625668ba29 100644 --- a/org.adempiere.install/install.console.app.launch +++ b/org.adempiere.install/install.console.app.launch @@ -14,13 +14,13 @@ - + - - + + diff --git a/org.adempiere.install/plugin.xml b/org.adempiere.install/plugin.xml index 18bb0df87c..2cc89a0dda 100644 --- a/org.adempiere.install/plugin.xml +++ b/org.adempiere.install/plugin.xml @@ -1,6 +1,7 @@ + diff --git a/org.adempiere.install/schema/org.adempiere.install.IDatabaseConfig.exsd b/org.adempiere.install/schema/org.adempiere.install.IDatabaseConfig.exsd new file mode 100644 index 0000000000..3e63471b80 --- /dev/null +++ b/org.adempiere.install/schema/org.adempiere.install.IDatabaseConfig.exsd @@ -0,0 +1,109 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PostgreSQL or Oracle + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/org.adempiere.install/src/org/adempiere/install/DBConfigStatus.java b/org.adempiere.install/src/org/adempiere/install/DBConfigStatus.java new file mode 100644 index 0000000000..7e0477bbb6 --- /dev/null +++ b/org.adempiere.install/src/org/adempiere/install/DBConfigStatus.java @@ -0,0 +1,122 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2010 Heng Sin Low * + * 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. * + *****************************************************************************/ +package org.adempiere.install; + +/** + * + * @author hengsin + * + */ +public class DBConfigStatus { + + public final static String DATABASE_SERVER = "DATABASE_SERVER"; + public final static String DATABASE_SYSTEM_PASSWORD = "DATABASE_SYSTEM_PASSWORD"; + public final static String DATABASE_USER = "DATABASE_USER"; + public final static String DATABASE_SQL_TEST = "DATABASE_SQL_TEST"; + + private String statusType; + private String resourseString; + private boolean pass; + private boolean critical; + private String errorMessage; + + /** + * @param statusType + * @param resourseString + * @param pass + * @param critical + * @param errorMessage + */ + public DBConfigStatus(String statusType, String resourseString, boolean pass, + boolean critical, String errorMessage) { + super(); + this.statusType = statusType; + this.resourseString = resourseString; + this.pass = pass; + this.critical = critical; + this.errorMessage = errorMessage; + } + + /** + * @return the statusType + */ + public String getStatusType() { + return statusType; + } + + /** + * @param statusType the statusType to set + */ + public void setStatusType(String statusType) { + this.statusType = statusType; + } + + /** + * @return the resourseString + */ + public String getResourseString() { + return resourseString; + } + + /** + * @param resourseString the resourseString to set + */ + public void setResourseString(String resourseString) { + this.resourseString = resourseString; + } + + /** + * @return the pass + */ + public boolean isPass() { + return pass; + } + + /** + * @param pass the pass to set + */ + public void setPass(boolean pass) { + this.pass = pass; + } + + /** + * @return the critical + */ + public boolean isCritical() { + return critical; + } + + /** + * @param critical the critical to set + */ + public void setCritical(boolean critical) { + this.critical = critical; + } + + /** + * @return the errorMessage + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * @param errorMessage the errorMessage to set + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + +} diff --git a/org.adempiere.install/src/org/adempiere/install/IDBConfigMonitor.java b/org.adempiere.install/src/org/adempiere/install/IDBConfigMonitor.java new file mode 100644 index 0000000000..f1d8b9eb21 --- /dev/null +++ b/org.adempiere.install/src/org/adempiere/install/IDBConfigMonitor.java @@ -0,0 +1,28 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2010 Heng Sin Low * + * 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. * + *****************************************************************************/ +package org.adempiere.install; + +/** + * + * @author hengsin + * + */ +public interface IDBConfigMonitor { + + /** + * + * @param status + */ + public void update(DBConfigStatus status); +} diff --git a/org.adempiere.install/src/org/adempiere/install/IDatabaseConfig.java b/org.adempiere.install/src/org/adempiere/install/IDatabaseConfig.java new file mode 100644 index 0000000000..106bb56ded --- /dev/null +++ b/org.adempiere.install/src/org/adempiere/install/IDatabaseConfig.java @@ -0,0 +1,54 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2010 Heng Sin Low * + * 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. * + *****************************************************************************/ +package org.adempiere.install; + +import org.compiere.install.ConfigurationData; + +/** + * + * @author hengsin + * + */ +public interface IDatabaseConfig { + + /** + * Get real database name from native connection profile name + * return from discoverDatabases + * @param nativeConnectioName + * @return Database name + */ + public String getDatabaseName(String nativeConnectioName); + + /** + * Init Configuration Data + * @param configurationData + */ + public void init(ConfigurationData configurationData); + + /** + * Discover Databases. + * To be overwritten by database configs + * @param selected selected database + * @return array of databases + */ + public String[] discoverDatabases(String selected); + + /************************************************************************** + * Test + * @param monitor + * @param data + * @return error message or null if OK + */ + public String test(IDBConfigMonitor monitor, ConfigurationData data); +} diff --git a/org.adempiere.install/src/org/compiere/install/Config.java b/org.adempiere.install/src/org/compiere/install/Config.java index c02f18a830..cc9c3300b8 100644 --- a/org.adempiere.install/src/org/compiere/install/Config.java +++ b/org.adempiere.install/src/org/compiere/install/Config.java @@ -16,19 +16,13 @@ *****************************************************************************/ package org.compiere.install; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; - import javax.swing.JCheckBox; import org.compiere.util.CLogger; -import org.compiere.util.DB; - /** * Configuration Setup and Test - * + * * @author Jorg Janke * @version $Id: Config.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ */ @@ -48,13 +42,13 @@ public abstract class Config protected ConfigurationData p_data = null; /** Logger */ static CLogger log = CLogger.getCLogger (Config.class); - - + + /** * Initialize */ abstract void init(); - + /** * Test * @return error message or null of OK @@ -71,18 +65,7 @@ public abstract class Config { return new String[]{}; } // discoverDatabases - - /** - * Get real database name from native connection profile name - * return from discoverDatabases - * @param nativeConnectioName - * @return Database name - */ - public String getDatabaseName(String nativeConnectioName) - { - return nativeConnectioName; - } - + /** * Get Panel * @return panel @@ -91,7 +74,7 @@ public abstract class Config { return p_data.p_panel; } // getPanel - + /** * Set Configuration Property * @param key key @@ -99,7 +82,7 @@ public abstract class Config */ protected void setProperty(String key, String value) { - p_data.p_properties.setProperty(key, value); + p_data.setProperty(key, value); } // setProperty /** @@ -111,7 +94,7 @@ public abstract class Config { return p_data.p_properties.getProperty(key, ""); } // getProperty - + /** * UI Signal OK * @param cb ckeck box @@ -120,45 +103,10 @@ public abstract class Config * @param critical true if critical * @param errorMsg error Message */ - void signalOK (JCheckBox cb, String resString, + protected void signalOK (JCheckBox cb, String resString, boolean pass, boolean critical, String errorMsg) { p_data.p_panel.signalOK(cb, resString, pass, critical, errorMsg); } // signalOK - /** - * Get Web Store Context Names separated by , - * @param con connection - * @return String of Web Store Names - e.g. /wstore - */ - protected String getWebStores(Connection con) - { - String sql = "SELECT WebContext FROM W_Store WHERE IsActive='Y'"; - Statement stmt = null; - ResultSet rs = null; - StringBuffer result = new StringBuffer(); - try - { - stmt = con.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next ()) - { - if (result.length() > 0) - result.append(","); - result.append(rs.getString(1)); - } - } - catch (Exception e) - { - log.severe(e.toString()); - } - finally - { - DB.close(rs, stmt); - rs = null; - stmt = null; - } - return result.toString(); - } // getWebStores - } // Config diff --git a/org.adempiere.install/src/org/compiere/install/ConfigVMOpenJDK.java b/org.adempiere.install/src/org/compiere/install/ConfigVM.java similarity index 66% rename from org.adempiere.install/src/org/compiere/install/ConfigVMOpenJDK.java rename to org.adempiere.install/src/org/compiere/install/ConfigVM.java index 92c53d82f2..8888587c0e 100644 --- a/org.adempiere.install/src/org/compiere/install/ConfigVMOpenJDK.java +++ b/org.adempiere.install/src/org/compiere/install/ConfigVM.java @@ -22,21 +22,21 @@ import org.compiere.util.CLogMgt; /** - * Open JDK JVM Configuration - * + * Java VM Configuration + * * @author Jorg Janke - * @author Trifon Trifonov */ -public class ConfigVMOpenJDK extends Config +public class ConfigVM extends Config { /** + * ConfigVM * @param data configuration */ - public ConfigVMOpenJDK (ConfigurationData data) + public ConfigVM (ConfigurationData data) { super (data); - } - + } // ConfigVMSun + /** * Init */ @@ -48,8 +48,8 @@ public class ConfigVMOpenJDK extends Config if (javaHome.endsWith("jre")) javaHome = javaHome.substring(0, javaHome.length()-4); p_data.setJavaHome(javaHome); - } - + } // init + /** * Test * @return error message or null of OK @@ -65,52 +65,33 @@ public class ConfigVMOpenJDK extends Config pass, true, error); if (!pass) return error; - /** Different VM structure - File tools = new File (p_data.getJavaHome() - + File.separator + "lib" + File.separator + "tools.jar"); - pass = tools.exists(); - error = "Not found: Java SDK = " + tools; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - **/ + // if (CLogMgt.isLevelFinest()) CLogMgt.printProperties(System.getProperties(), "System", true); // log.info("OK: JavaHome=" + javaHome.getAbsolutePath()); setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); System.setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); - + // Java Version - final String VERSION = "1.5.0"; - final String VERSION2 = "1.6.0"; + final String VERSION = "1.6.0"; + final String VERSION2 = "1.7.0"; // The real one pass = false; - String jh = javaHome.getAbsolutePath(); - if (jh.indexOf(VERSION) != -1) // file name has version = assuming OK + String thisJV = System.getProperty("java.version"); + pass = thisJV.indexOf(VERSION) != -1; + if (!pass && thisJV.indexOf(VERSION2) != -1) pass = true; - if (!pass && jh.indexOf(VERSION2) != -1) // - pass = true; - String thisJH = System.getProperty("java.home"); - if (thisJH.indexOf(jh) != -1) // we are running the version currently - { - String thisJV = System.getProperty("java.version"); - pass = thisJV.indexOf(VERSION) != -1; - if (!pass && thisJV.indexOf(VERSION2) != -1) - pass = true; - if (pass) - log.info("OK: Version=" + thisJV); - } - error = "Wrong Java Version: Should be " + VERSION2; + if (pass) + log.info("OK: Version=" + thisJV); + + error = "Wrong Java Version: Should be " + VERSION + " and above."; if (getPanel() != null) signalOK(getPanel().okJavaHome, "ErrorJavaHome", pass, true, error); if (!pass) return error; - // - setProperty(ConfigurationData.JAVA_TYPE, p_data.getJavaType()); - + return null; - } + } // test } diff --git a/org.adempiere.install/src/org/compiere/install/ConfigVMMac.java b/org.adempiere.install/src/org/compiere/install/ConfigVMMac.java deleted file mode 100644 index 41cfc25369..0000000000 --- a/org.adempiere.install/src/org/compiere/install/ConfigVMMac.java +++ /dev/null @@ -1,117 +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.File; - -import org.compiere.util.CLogMgt; - - -/** - * Apple Mac Java VM Configuration - * - * @author Jorg Janke - * @version $Id: ConfigVMMac.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ - */ -public class ConfigVMMac extends Config -{ - /** - * ConfigVMMac - * @param data configuration - */ - public ConfigVMMac (ConfigurationData data) - { - super (data); - } // ConfigVMMac - - /** - * Init - */ - public void init() - { - // Java Home, e.g. D:\j2sdk1.4.1\jre - String javaHome = System.getProperty("java.home"); - log.fine(javaHome); - if (javaHome.endsWith("jre")) - javaHome = javaHome.substring(0, javaHome.length()-4); - p_data.setJavaHome(javaHome); - } // init - - /** - * Test - * @return error message or null of OK - */ - public String test() - { - // Java Home - File javaHome = new File (p_data.getJavaHome()); - boolean pass = javaHome.exists(); - String error = "Not found: Java Home"; - if (getPanel() != null) - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - /** Different VM structure - File tools = new File (p_data.getJavaHome() - + File.separator + "lib" + File.separator + "tools.jar"); - pass = tools.exists(); - error = "Not found: Java SDK = " + tools; - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - **/ - if (CLogMgt.isLevelFinest()) - CLogMgt.printProperties(System.getProperties(), "System", true); - // - log.info("OK: JavaHome=" + javaHome.getAbsolutePath()); - setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); - System.setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); - - // Java Version - final String VERSION = "1.5.0"; - final String VERSION2 = "1.6.0"; - pass = false; - String jh = javaHome.getAbsolutePath(); - if (jh.indexOf(VERSION) != -1) // file name has version = assuming OK - pass = true; - if (!pass && jh.indexOf(VERSION2) != -1) // - pass = true; - String thisJH = System.getProperty("java.home"); - if (thisJH.indexOf(jh) != -1) // we are running the version currently - { - String thisJV = System.getProperty("java.version"); - pass = thisJV.indexOf(VERSION) != -1; - if (!pass && thisJV.indexOf(VERSION2) != -1) - pass = true; - if (pass) - log.info("OK: Version=" + thisJV); - } - error = "Wrong Java Version: Should be " + VERSION2; - if (getPanel() != null) - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - // - setProperty(ConfigurationData.JAVA_TYPE, p_data.getJavaType()); - - return null; - } // test - -} diff --git a/org.adempiere.install/src/org/compiere/install/ConfigVMSun.java b/org.adempiere.install/src/org/compiere/install/ConfigVMSun.java deleted file mode 100644 index f82b93b93b..0000000000 --- a/org.adempiere.install/src/org/compiere/install/ConfigVMSun.java +++ /dev/null @@ -1,118 +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.File; - -import org.compiere.util.CLogMgt; - - -/** - * Sun Java VM Configuration - * - * @author Jorg Janke - * @version $Id: ConfigVMSun.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ - */ -public class ConfigVMSun extends Config -{ - /** - * ConfigVMSun - * @param data configuration - */ - public ConfigVMSun (ConfigurationData data) - { - super (data); - } // ConfigVMSun - - /** - * Init - */ - public void init() - { - // Java Home, e.g. D:\j2sdk1.4.1\jre - String javaHome = System.getProperty("java.home"); - log.fine(javaHome); - if (javaHome.endsWith("jre")) - javaHome = javaHome.substring(0, javaHome.length()-4); - p_data.setJavaHome(javaHome); - } // init - - /** - * Test - * @return error message or null of OK - */ - public String test() - { - // Java Home - File javaHome = new File (p_data.getJavaHome()); - boolean pass = javaHome.exists(); - String error = "Not found: Java Home"; - 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 - File tools = new File (p_data.getJavaHome() - + File.separator + "lib" + File.separator + "tools.jar"); - pass = tools.exists(); - error = "Not found: Java SDK = " + tools; - if (getPanel() != null) - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - // - if (CLogMgt.isLevelFinest()) - CLogMgt.printProperties(System.getProperties(), "System", true); - // - log.info("OK: JavaHome=" + javaHome.getAbsolutePath()); - setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); - System.setProperty(ConfigurationData.JAVA_HOME, javaHome.getAbsolutePath()); - - // Java Version - final String VERSION = "1.5.0"; - final String VERSION2 = "1.6.0"; // The real one - pass = false; - String jh = javaHome.getAbsolutePath(); - if (jh.indexOf(VERSION) != -1) // file name has version = assuming OK - pass = true; - if (!pass && jh.indexOf(VERSION2) != -1) // - pass = true; - String thisJH = System.getProperty("java.home"); - if (thisJH.indexOf(jh) != -1) // we are running the version currently - { - String thisJV = System.getProperty("java.version"); - pass = thisJV.indexOf(VERSION) != -1; - if (!pass && thisJV.indexOf(VERSION2) != -1) - pass = true; - if (pass) - log.info("OK: Version=" + thisJV); - } - error = "Wrong Java Version: Should be " + VERSION2; - if (getPanel() != null) - signalOK(getPanel().okJavaHome, "ErrorJavaHome", - pass, true, error); - if (!pass) - return error; - // - setProperty(ConfigurationData.JAVA_TYPE, p_data.getJavaType()); - - return null; - } // test - -} diff --git a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java index de5d278389..f25f437bc8 100644 --- a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java +++ b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java @@ -26,6 +26,10 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.URL; import java.net.URLConnection; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -40,11 +44,15 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import org.adempiere.base.Service; +import org.adempiere.install.IDBConfigMonitor; +import org.adempiere.install.IDatabaseConfig; import org.compiere.Adempiere; import org.compiere.db.CConnection; import org.compiere.db.Database; import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; +import org.compiere.util.DB; import org.compiere.util.EMail; import org.compiere.util.EMailAuthenticator; import org.compiere.util.Ini; @@ -66,8 +74,19 @@ public class ConfigurationData { super (); p_panel = panel; + initDatabaseConfig(); } // ConfigurationData + private void initDatabaseConfig() + { + List configList = Service.list(IDatabaseConfig.class); + m_databaseConfig = new IDatabaseConfig[configList.size()]; + for(int i = 0; i < configList.size(); i++) + { + m_databaseConfig[i] = configList.get(i); + } + } + /** UI Panel */ protected ConfigurationPanel p_panel = null; /** Environment Properties */ @@ -88,8 +107,6 @@ public class ConfigurationData /** */ public static final String JAVA_HOME = "JAVA_HOME"; /** */ - public static final String JAVA_TYPE = "ADEMPIERE_JAVA_TYPE"; - /** */ public static final String ADEMPIERE_JAVA_OPTIONS = "ADEMPIERE_JAVA_OPTIONS"; /** Default Keysore Password */ public static final String KEYSTORE_PASSWORD = "myPassword"; @@ -183,7 +200,7 @@ public class ConfigurationData else if (!currentValue.equals(value)) p_properties.put(property, value); } - + public String getProperty(String property) { return p_properties.getProperty(property); @@ -222,8 +239,7 @@ public class ConfigurationData Properties loaded = new Properties(); loaded.putAll(p_properties); // - int javaIndex = setJavaType((String)p_properties.get(JAVA_TYPE)); - initJava(javaIndex); + initJava(); if (loaded.containsKey(JAVA_HOME)) setJavaHome((String)loaded.get(JAVA_HOME)); // @@ -356,7 +372,7 @@ public class ConfigurationData * test * @return true if test ok */ - public boolean test() + public boolean test(IDBConfigMonitor monitor) { String error = testJava(); if (error != null) @@ -383,7 +399,7 @@ public class ConfigurationData if (p_panel != null) p_panel.setStatusBar(p_panel.lDatabaseServer.getText()); - error = testDatabase(); + error = testDatabase(monitor); if (error != null) { log.warning(error); @@ -680,7 +696,7 @@ public class ConfigurationData * @param file file name * @return true if able to connect */ - protected boolean testPort (String protocol, String server, int port, String file) + public boolean testPort (String protocol, String server, int port, String file) { System.out.println("testPort[" + protocol + "," + server + ", " + port + ", " + file +"]"); URL url = null; @@ -742,7 +758,7 @@ public class ConfigurationData * @param shouldBeUsed true if it should be used * @return true if some server answered on port */ - protected boolean testPort (InetAddress host, int port, boolean shouldBeUsed) + public boolean testPort (InetAddress host, int port, boolean shouldBeUsed) { System.out.println("testPort[" + host.getHostAddress() + ", " + port + "]"); Socket pingSocket = null; @@ -944,8 +960,7 @@ public class ConfigurationData {JAVATYPE_SUN, JAVATYPE_OPENJDK, JAVATYPE_MAC}; /** Virtual machine Configurations */ - private Config[] m_javaConfig = new Config[] - {new ConfigVMSun(this), new ConfigVMOpenJDK(this), new ConfigVMMac(this)}; + private Config m_javaConfig = new ConfigVM(this); private ConfigAppServer m_appsConfig = new ConfigAppServer(this); /** @@ -953,79 +968,18 @@ public class ConfigurationData */ public void initJava() { - int index = (p_panel != null ? p_panel.fJavaType.getSelectedIndex() : 0); - initJava(index); + m_javaConfig.init(); } // initDatabase - public 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]); - if (p_panel != null) - p_panel.fJavaType.setSelectedIndex(0); - } - else - m_javaConfig[index].init(); - } - /** * Test Java * @return error message or null of OK */ public String testJava() { - 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) - return "JavaType Config class missing: " + index; - return m_javaConfig[index].test(); + return m_javaConfig.test(); } // testJava - /** - * Set Java Type - * @param javaType The javaType to set. - */ - public int setJavaType (String javaType) - { - int index = -1; - for (int i = 0; i < JAVATYPE.length; i++) - { - if (JAVATYPE[i].equals(javaType)) - { - index = i; - break; - } - } - if (index == -1) - { - index = 0; - log.warning("Invalid JavaType=" + javaType); - } - if (p_panel != null) - p_panel.fJavaType.setSelectedIndex(index); - else - updateProperty(JAVA_TYPE, javaType); - - return index; - } // setJavaType - - /** - * @return Returns the javaType. - */ - public String getJavaType () - { - if( p_panel != null ) - return (String)p_panel.fJavaType.getSelectedItem(); - else - return (String)p_properties.get(JAVA_TYPE); - } - /** * @return Returns the javaHome. */ @@ -1177,13 +1131,7 @@ public class ConfigurationData //end e-evolution vpj-cd 02/07/2005 PostgreSQL /** Database Configs */ - private Config[] m_databaseConfig = new Config[] - { - new ConfigOracle(this,true), - //begin e-evolution vpj-cd 02/07/2005 PostgreSQL - new ConfigPostgreSQL(this) - // end e-evolution vpj-cd 02/07/2005 PostgreSQL - }; + private IDatabaseConfig[] m_databaseConfig = null; /** * Init Database @@ -1220,7 +1168,7 @@ public class ConfigurationData } else { - m_databaseConfig[index].init(); + m_databaseConfig[index].init(this); if (p_panel != null) { @@ -1236,9 +1184,10 @@ public class ConfigurationData /** * Test Database + * @param monitor * @return error message or null of OK */ - public String testDatabase() + public String testDatabase(IDBConfigMonitor monitor) { int index = p_panel != null ? p_panel.fDatabaseType.getSelectedIndex() @@ -1247,7 +1196,7 @@ public class ConfigurationData return "DatabaseType Index invalid: " + index; else if (m_databaseConfig[index] == null) return "DatabaseType Config class missing: " + index; - return m_databaseConfig[index].test(); + return m_databaseConfig[index].test(monitor, this); } // testDatabase @@ -1354,7 +1303,7 @@ public class ConfigurationData else updateProperty(ADEMPIERE_DB_PASSWORD, databasePassword); } - + /** * @return Returns the databasePort. */ @@ -1457,7 +1406,7 @@ public class ConfigurationData else updateProperty(ADEMPIERE_DB_USER, databaseUser); } - + /** * @return Returns the mail Server. */ @@ -1467,7 +1416,7 @@ public class ConfigurationData ? p_panel.fMailServer.getText() : (String)p_properties.get(ADEMPIERE_MAIL_SERVER); } - + public void setMailServer(String mailServer) { if (p_panel != null) @@ -1475,7 +1424,7 @@ public class ConfigurationData else updateProperty(ADEMPIERE_MAIL_SERVER, mailServer); } - + /** * @return Returns the mailUser. */ @@ -1495,7 +1444,7 @@ public class ConfigurationData else updateProperty(ADEMPIERE_MAIL_USER, mailUser); } - + /** * @return Returns the mail User Password. */ @@ -1524,7 +1473,7 @@ public class ConfigurationData else updateProperty(ADEMPIERE_MAIL_PASSWORD, mailPassword); } - + /** * @return Returns the admin email */ @@ -1544,4 +1493,49 @@ public class ConfigurationData else updateProperty(ADEMPIERE_ADMIN_EMAIL, adminEMail); } + + /** + * Get Web Store Context Names separated by , + * @param con connection + * @return String of Web Store Names - e.g. /wstore + */ + public String getWebStores(Connection con) + { + String sql = "SELECT WebContext FROM W_Store WHERE IsActive='Y'"; + Statement stmt = null; + ResultSet rs = null; + StringBuffer result = new StringBuffer(); + try + { + stmt = con.createStatement(); + rs = stmt.executeQuery(sql); + while (rs.next ()) + { + if (result.length() > 0) + result.append(","); + result.append(rs.getString(1)); + } + } + catch (Exception e) + { + log.severe(e.toString()); + } + finally + { + DB.close(rs, stmt); + rs = null; + stmt = null; + } + return result.toString(); + } // getWebStores + + /** + * Set Configuration Property + * @param key key + * @param value value + */ + public void setProperty(String key, String value) + { + p_properties.setProperty(key, value); + } // setProperty } // ConfigurationData diff --git a/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java b/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java index 731c7db470..9454b456c5 100644 --- a/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java +++ b/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java @@ -42,7 +42,8 @@ import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.TitledBorder; -import org.adempiere.base.Core; +import org.adempiere.install.DBConfigStatus; +import org.adempiere.install.IDBConfigMonitor; import org.apache.tools.ant.Main; import org.compiere.util.CLogger; @@ -52,7 +53,7 @@ import org.compiere.util.CLogger; * @author Jorg Janke * @version $Id: ConfigurationPanel.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ */ -public class ConfigurationPanel extends JPanel implements ActionListener +public class ConfigurationPanel extends JPanel implements ActionListener, IDBConfigMonitor { /** * @@ -106,8 +107,6 @@ public class ConfigurationPanel extends JPanel implements ActionListener JTextField fJavaHome = new JTextField(FIELDLENGTH); JCheckBox okJavaHome = new JCheckBox(); private JButton bJavaHome = new JButton(iOpen); - private JLabel lJavaType = new JLabel(); - JComboBox fJavaType = new JComboBox(ConfigurationData.JAVATYPE); // Adempiere - KeyStore private JLabel lAdempiereHome = new JLabel(); JTextField fAdempiereHome = new JTextField(FIELDLENGTH); @@ -145,10 +144,10 @@ public class ConfigurationPanel extends JPanel implements ActionListener JTextField fDatabaseUser = new JTextField(FIELDLENGTH); private JLabel lDatabasePassword = new JLabel(); JPasswordField fDatabasePassword = new JPasswordField(); - JCheckBox okDatabaseServer = new JCheckBox(); - JCheckBox okDatabaseUser = new JCheckBox(); - JCheckBox okDatabaseSystem = new JCheckBox(); - JCheckBox okDatabaseSQL = new JCheckBox(); + public JCheckBox okDatabaseServer = new JCheckBox(); + public JCheckBox okDatabaseUser = new JCheckBox(); + public JCheckBox okDatabaseSystem = new JCheckBox(); + public JCheckBox okDatabaseSQL = new JCheckBox(); // JLabel lMailServer = new JLabel(); JTextField fMailServer = new JTextField(FIELDLENGTH); @@ -183,9 +182,6 @@ public class ConfigurationPanel extends JPanel implements ActionListener okJavaHome.setEnabled(false); bJavaHome.setMargin(bInsets); bJavaHome.setToolTipText(res.getString("JavaHomeInfo")); - lJavaType.setToolTipText(res.getString("JavaTypeInfo")); - lJavaType.setText(res.getString("JavaType")); - fJavaType.setPreferredSize(fJavaHome.getPreferredSize()); JLabel sectionLabel = new JLabel("Java"); sectionLabel.setForeground(titledBorder.getTitleColor()); @@ -203,10 +199,6 @@ public class ConfigurationPanel extends JPanel implements ActionListener ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 2, 5), 0, 0)); this.add(bJavaHome, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - this.add(lJavaType, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0)); - this.add(fJavaType, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 2, 0), 0, 0)); // AdempiereHome - KeyStore lAdempiereHome.setToolTipText(res.getString("AdempiereHomeInfo")); lAdempiereHome.setText(res.getString("AdempiereHome")); @@ -431,7 +423,6 @@ public class ConfigurationPanel extends JPanel implements ActionListener // bAdempiereHome.addActionListener(this); bJavaHome.addActionListener(this); - fJavaType.addActionListener(this); fDatabaseType.addActionListener(this); fDatabaseDiscovered.addActionListener(this); bHelp.addActionListener(this); @@ -475,8 +466,6 @@ public class ConfigurationPanel extends JPanel implements ActionListener fDatabaseName.setText(m_data.resolveDatabaseName(dbName)); } // - else if (e.getSource() == fJavaType) - m_data.initJava(); else if (e.getSource() == fDatabaseType) m_data.initDatabase(""); // @@ -570,7 +559,7 @@ public class ConfigurationPanel extends JPanel implements ActionListener private void test() throws Exception { bSave.setEnabled(false); - if (!m_data.test()) + if (!m_data.test(this)) return; // m_statusBar.setText(res.getString("Ok")); @@ -621,30 +610,37 @@ public class ConfigurationPanel extends JPanel implements ActionListener if (!m_data.save()) return; - // Final Info - JOptionPane.showConfirmDialog(this, res.getString("EnvironmentSaved"), - res.getString("AdempiereServerSetup"), - JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE); - - /** 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); - } - // To be sure ((Frame)SwingUtilities.getWindowAncestor(this)).dispose(); System.exit(0); // remains active when License Dialog called /** **/ } // save + /* (non-Javadoc) + * @see org.adempiere.install.IDBConfigMonitor#update(org.adempiere.install.DBConfigStatus) + */ + @Override + public void update(DBConfigStatus status) { + if (status.getStatusType().equals(DBConfigStatus.DATABASE_SERVER)) + { + signalOK(okDatabaseServer, status.getResourseString(), + status.isPass(), status.isCritical(), status.getErrorMessage()); + } + else if (status.getStatusType().equals(DBConfigStatus.DATABASE_SYSTEM_PASSWORD)) + { + signalOK(okDatabaseSystem, status.getResourseString(), status.isPass(), + status.isCritical(), status.getErrorMessage()); + } + else if (status.getStatusType().equals(DBConfigStatus.DATABASE_USER)) + { + signalOK(okDatabaseUser, status.getResourseString(), status.isPass(), + status.isCritical(), status.getErrorMessage()); + } + else if (status.getStatusType().equals(DBConfigStatus.DATABASE_SQL_TEST)) + { + signalOK(okDatabaseSQL, status.getResourseString(), status.isPass(), + status.isCritical(), status.getErrorMessage()); + } + } + } // ConfigurationPanel diff --git a/org.adempiere.install/src/org/compiere/install/SilentSetup.java b/org.adempiere.install/src/org/compiere/install/SilentSetup.java index 6496ed2540..12f42645ea 100644 --- a/org.adempiere.install/src/org/compiere/install/SilentSetup.java +++ b/org.adempiere.install/src/org/compiere/install/SilentSetup.java @@ -18,7 +18,7 @@ public class SilentSetup { 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); @@ -27,18 +27,18 @@ public class SilentSetup { 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()) + if (!data.test(null)) { System.err.println(""); System.err.println("Warning: One or more of the configuration test failed."); System.err.println(""); } if (!data.save()) return; - + /** Run Ant **/ try { @@ -54,7 +54,7 @@ public class SilentSetup { CLogger.get().log(Level.SEVERE, "ant", e); } } - + /** * Start * @param args Log Level e.g. ALL, FINE @@ -72,7 +72,7 @@ public class SilentSetup { // File Logger at least FINE if (fileHandler.getLevel().intValue() > Level.FINE.intValue()) fileHandler.setLevel(Level.FINE); - + new SilentSetup(); } } diff --git a/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java b/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java index 3d5d190629..74f0bd0d77 100644 --- a/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java +++ b/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java @@ -41,9 +41,9 @@ public class ConfigurationConsole { Ini.setShowLicenseDialog(false); data.load(); + data.initJava(); try { - jvmType(reader, writer); jvmHome(reader, writer); adempiereHome(reader, writer); @@ -169,7 +169,7 @@ public class ConfigurationConsole { { data.setDatabaseSystemPassword(dbPassword); } - String error = data.testDatabase(); + String error = data.testDatabase(null); if (error != null && error.trim().length() > 0) { writer.println("Database test fail: " + error); @@ -416,62 +416,12 @@ public class ConfigurationConsole { if (error != null && error.trim().length() > 0) { writer.println("JVM test fail: " + error); - jvmType(reader, writer); continue; } break; } } - private void jvmType(BufferedReader reader, PrintWriter writer) throws IOException { - //java type - String javaType = data.getJavaType(); - int javaTypeSelected = 0; - for(int i = 0; i < ConfigurationData.JAVATYPE.length; i++) - { - if (ConfigurationData.JAVATYPE[i].equals(javaType)) - { - javaTypeSelected = i; - break; - } - } -// console.writer().println("JVM Type:"); - for(int i = 0; i < ConfigurationData.JAVATYPE.length; i++) - { - writer.println((i+1) + ". " + ConfigurationData.JAVATYPE[i]); - } - - while (true) - { - writer.println("JVM Type [" + (javaTypeSelected+1) + "]:"); - String input = reader.readLine(); - if (input != null && input.trim().length() > 0) - { - try - { - int inputIndex = Integer.parseInt(input); - if (inputIndex <= 0 || inputIndex > ConfigurationData.JAVATYPE.length) - { - writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.JAVATYPE.length); - continue; - } - data.initJava(inputIndex-1); - data.setJavaType(ConfigurationData.JAVATYPE[inputIndex-1]); - break; - } - catch (NumberFormatException e){ - writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.JAVATYPE.length); - continue; - } - } - else - { - data.initJava(javaTypeSelected); - data.setJavaType(ConfigurationData.JAVATYPE[javaTypeSelected]); - } - break; - } - } private void dbType(BufferedReader reader, PrintWriter writer) throws IOException { String dbType = data.getDatabaseType(); diff --git a/org.adempiere.server-feature/build.xml b/org.adempiere.server-feature/build.xml index bd3fff5331..80bb7c289c 100644 --- a/org.adempiere.server-feature/build.xml +++ b/org.adempiere.server-feature/build.xml @@ -11,7 +11,6 @@ - diff --git a/org.adempiere.server-feature/server.product.launch b/org.adempiere.server-feature/server.product.launch index 9ed4f9fc2a..7ae02cb9a6 100644 --- a/org.adempiere.server-feature/server.product.launch +++ b/org.adempiere.server-feature/server.product.launch @@ -21,8 +21,8 @@ - - + + diff --git a/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF b/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF index f72d6e7a9d..1cce3a2b3a 100644 --- a/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF +++ b/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Bundle-Name: OracleProvider Bundle-SymbolicName: org.compiere.db.oracle.provider;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.adempiere.base;bundle-version="1.0.0" +Require-Bundle: org.adempiere.base;bundle-version="1.0.0", + org.adempiere.install;bundle-version="1.0.0" Bundle-ClassPath: ., ojdbc6.jar, c3p0-0.9.1.2.jar, diff --git a/org.compiere.db.oracle.provider/plugin.xml b/org.compiere.db.oracle.provider/plugin.xml index 283468c75b..669443a88e 100644 --- a/org.compiere.db.oracle.provider/plugin.xml +++ b/org.compiere.db.oracle.provider/plugin.xml @@ -8,5 +8,14 @@ id="Oracle"> + + + + diff --git a/org.adempiere.install/src/org/compiere/install/ConfigOracle.java b/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java similarity index 78% rename from org.adempiere.install/src/org/compiere/install/ConfigOracle.java rename to org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java index 7563f84dad..4b8e7dfeb7 100644 --- a/org.adempiere.install/src/org/compiere/install/ConfigOracle.java +++ b/org.compiere.db.oracle.provider/src/org/adempiere/db/oracle/config/ConfigOracle.java @@ -14,7 +14,7 @@ * 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; +package org.adempiere.db.oracle.config; import java.io.File; import java.io.FileReader; @@ -26,27 +26,30 @@ import java.sql.DriverManager; import java.util.ArrayList; import java.util.regex.Pattern; +import org.adempiere.install.DBConfigStatus; +import org.adempiere.install.IDBConfigMonitor; +import org.adempiere.install.IDatabaseConfig; import org.compiere.db.Database; +import org.compiere.install.ConfigurationData; +import org.compiere.util.CLogger; /** * Oracle Configuration - * + * * @author Jorg Janke * @version $Id: ConfigOracle.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $ */ -public class ConfigOracle extends Config +public class ConfigOracle implements IDatabaseConfig { + private final static CLogger log = CLogger.getCLogger(ConfigOracle.class); + /** * ConfigOracle - * @param data configuration - * @param XE express edition */ - public ConfigOracle (ConfigurationData data, boolean XE) + public ConfigOracle () { - super (data); - m_XE = XE; } // ConfigOracle - + /** Discoverd TNS */ private String[] p_discovered = null; /** Discovered Database Name */ @@ -55,17 +58,17 @@ public class ConfigOracle extends Config private Connection m_con = null; /** Express Edition */ private boolean m_XE = false; - + /** * Init */ - public void init() + public void init(ConfigurationData configurationData) { - p_data.setDatabasePort(String.valueOf(Database.DB_ORACLE_DEFAULT_PORT)); + configurationData.setDatabasePort(String.valueOf(Database.DB_ORACLE_DEFAULT_PORT)); // - p_data.setDatabaseSystemPassword(true); + configurationData.setDatabaseSystemPassword(true); } // init - + /** * Discover Databases. * To be overwritten by database configs @@ -87,7 +90,7 @@ public class ConfigOracle extends Config list.add(def.toLowerCase()); dblist.add(def.toLowerCase()); } - + if (m_XE) { String serviceName = "xe"; @@ -97,9 +100,9 @@ public class ConfigOracle extends Config dblist.add(serviceName); } } - + String path = System.getenv("ORACLE_HOME"); - if (path == null) + if (path == null) { // Search for Oracle Info path = System.getProperty("java.library.path"); @@ -165,9 +168,9 @@ public class ConfigOracle extends Config dblist.toArray(p_dbname); return p_discovered; } // discoverDatabases - + @Override - public String getDatabaseName(String nativeConnectioName) + public String getDatabaseName(String nativeConnectioName) { int idx = -1; if (p_discovered == null) return nativeConnectioName; @@ -179,8 +182,8 @@ public class ConfigOracle extends Config break; } } - if (idx >= 0 - && p_dbname != null + if (idx >= 0 + && p_dbname != null && idx < p_dbname.length) return p_dbname[idx]; else @@ -265,7 +268,7 @@ public class ConfigOracle extends Config log.fine(entry); list.add(entry); } - + } } // Convert to Array @@ -275,18 +278,20 @@ public class ConfigOracle extends Config list.toArray(retValue); return retValue; } // getTNS_Names - - + + /************************************************************************** * Test + * @param monitor + * @param data * @return error message or null if OK */ - public String test() + public String test(IDBConfigMonitor monitor, ConfigurationData data) { // Database Server - String server = p_data.getDatabaseServer(); + String server = data.getDatabaseServer(); boolean pass = server != null && server.length() > 0 - && server.toLowerCase().indexOf("localhost") == -1 + && server.toLowerCase().indexOf("localhost") == -1 && !server.equals("127.0.0.1"); String error = "Not correct: DB Server = " + server; InetAddress databaseServer = null; @@ -300,35 +305,35 @@ public class ConfigOracle extends Config error += " - " + e.getMessage(); pass = false; } - if (getPanel() != null) - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SERVER, "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()); - setProperty(ConfigurationData.ADEMPIERE_DB_PATH, p_data.getDatabaseType()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, data.getDatabaseType()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PATH, data.getDatabaseType()); // Database Port - int databasePort = p_data.getDatabasePort(); - pass = p_data.testPort (databaseServer, databasePort, true); + int databasePort = data.getDatabasePort(); + pass = data.testPort (databaseServer, databasePort, true); error = "DB Server Port = " + databasePort; - if (getPanel() != null) - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SERVER, "ErrorDatabasePort", + pass, true, error)); if (!pass) return error; log.info("OK: Database Port = " + databasePort); - setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); // JDBC Database Info - String databaseName = p_data.getDatabaseName(); // Service Name - String systemPassword = p_data.getDatabaseSystemPassword(); + String databaseName = data.getDatabaseName(); // Service Name + String systemPassword = data.getDatabaseSystemPassword(); pass = systemPassword != null && systemPassword.length() > 0; error = "No Database System Password entered"; - if (getPanel() != null) - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SYSTEM_PASSWORD, "ErrorJDBC", + pass, true, error)); if (!pass) return error; // @@ -337,48 +342,48 @@ public class ConfigOracle extends Config + ":" + databasePort + "/" + databaseName; pass = testJDBC(url, "system", systemPassword); - error = "Error connecting: " + url + error = "Error connecting: " + url + " - as system/" + systemPassword; - if (getPanel() != null) - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SYSTEM_PASSWORD, "ErrorJDBC", + pass, true, error)); if (!pass) return error; log.info("OK: Connection = " + url); - setProperty(ConfigurationData.ADEMPIERE_DB_URL, url); + data.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); + data.setProperty(ConfigurationData.ADEMPIERE_DB_NAME, databaseName); + data.setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword); // Database User Info - String databaseUser = p_data.getDatabaseUser(); // UID - String databasePassword = p_data.getDatabasePassword(); // PWD + String databaseUser = data.getDatabaseUser(); // UID + String databasePassword = data.getDatabasePassword(); // PWD pass = databasePassword != null && databasePassword.length() > 0; error = "Invalid Database User Password"; - if (getPanel() != null) - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "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)."; - if (getPanel() != null) - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "ErrorJDBC", + pass, false, error)); if (pass) { log.info("OK: Database User = " + databaseUser); if (m_con != null) - setProperty(ConfigurationData.ADEMPIERE_WEBSTORES, getWebStores(m_con)); + data.setProperty(ConfigurationData.ADEMPIERE_WEBSTORES, data.getWebStores(m_con)); } else log.warning(error); - setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); - setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); + data.setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); - // TNS Name Info via sqlplus + // TNS Name Info via sqlplus String sqlplus = "sqlplus system/" + systemPassword + "@" + "//" + databaseServer.getHostName() + ":" + databasePort @@ -387,12 +392,12 @@ public class ConfigOracle extends Config log.config(sqlplus); pass = testSQL(sqlplus); error = "Error connecting via: " + sqlplus; - if (getPanel() != null) - signalOK(getPanel().okDatabaseSQL, "ErrorTNS", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SQL_TEST, "ErrorTNS", + pass, true, error)); if (pass) log.info("OK: Database SQL Connection"); - + // OCI Test if (System.getProperty("TestOCI", "N").equals("Y")) { @@ -404,7 +409,7 @@ public class ConfigOracle extends Config log.warning("Cannot connect via Net8: " + url); } log.info("OCI Test Skipped"); - + // m_con = null; return null; @@ -485,5 +490,5 @@ public class ConfigOracle extends Config log.warning(sbErr.toString()); return result == 0; } // testSQL - + } // ConfigOracle diff --git a/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF b/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF index cbc7ebdafc..8e800f2ce5 100644 --- a/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF +++ b/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ClassPath: ., postgresql.jar, c3p0-0.9.1.2.jar -Require-Bundle: org.adempiere.base;bundle-version="1.0.0" +Require-Bundle: org.adempiere.base;bundle-version="1.0.0", + org.adempiere.install;bundle-version="1.0.0" Import-Package: junit.framework;version="3.8.2", org.junit;version="4.8.1" diff --git a/org.compiere.db.postgresql.provider/plugin.xml b/org.compiere.db.postgresql.provider/plugin.xml index c2aa14b28d..e853c82e7a 100644 --- a/org.compiere.db.postgresql.provider/plugin.xml +++ b/org.compiere.db.postgresql.provider/plugin.xml @@ -8,5 +8,14 @@ id="PostgreSQL"> + + + + diff --git a/org.adempiere.install/src/org/compiere/install/ConfigPostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/adempiere/db/postgresql/config/ConfigPostgreSQL.java similarity index 60% rename from org.adempiere.install/src/org/compiere/install/ConfigPostgreSQL.java rename to org.compiere.db.postgresql.provider/src/org/adempiere/db/postgresql/config/ConfigPostgreSQL.java index e6b58b7d79..845a15cb33 100755 --- a/org.adempiere.install/src/org/compiere/install/ConfigPostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/adempiere/db/postgresql/config/ConfigPostgreSQL.java @@ -12,43 +12,49 @@ * Portions created by Victor Perez are Copyright (C) 1999-2005 e-Evolution,S.C * Contributor(s): Victor Perez *****************************************************************************/ -package org.compiere.install; +package org.adempiere.db.postgresql.config; import java.net.InetAddress; import java.sql.Connection; +import org.adempiere.install.DBConfigStatus; +import org.adempiere.install.IDBConfigMonitor; +import org.adempiere.install.IDatabaseConfig; import org.compiere.db.AdempiereDatabase; import org.compiere.db.Database; +import org.compiere.install.ConfigurationData; +import org.compiere.util.CLogger; /** * PostgreSQL Configuration - * + * * @author Victor Perez e-Evolution * @version $Id: ConfigPostgreSQL.java,v 1.0 2005/01/31 06:08:15 vpj-cd Exp $ */ -public class ConfigPostgreSQL extends Config +public class ConfigPostgreSQL implements IDatabaseConfig { + private final static CLogger log = CLogger.getCLogger(ConfigPostgreSQL.class); + /** * ConfigPostgreSQL - * @param data */ - public ConfigPostgreSQL (ConfigurationData data) + public ConfigPostgreSQL () { - super (data); } // ConfigPostgreSQL /** Discovered TNS */ private String[] p_discovered = null; - + private AdempiereDatabase p_db = Database.getDatabase(Database.DB_POSTGRESQL); - + /** - * Init + * Init + * @param configurationData */ - public void init() + public void init(ConfigurationData configurationData) { - p_data.setDatabasePort(String.valueOf(Database.DB_POSTGRESQL_DEFAULT_PORT)); + configurationData.setDatabasePort(String.valueOf(Database.DB_POSTGRESQL_DEFAULT_PORT)); } // init /** @@ -64,20 +70,22 @@ public class ConfigPostgreSQL extends Config p_discovered = new String[]{}; return p_discovered; } // discoveredDatabases - - + + /************************************************************************** * Test + * @param monitor + * @param data * @return error message or null if OK */ - public String test() + public String test(IDBConfigMonitor monitor, ConfigurationData data) { // Database Server - String server = p_data.getDatabaseServer(); + String server = data.getDatabaseServer(); boolean pass = server != null && server.length() > 0; - // vpj-cd e-evolution && server.toLowerCase().indexOf("localhost") == -1 + // vpj-cd e-evolution && server.toLowerCase().indexOf("localhost") == -1 // vpj-cd e-evolution && !server.equals("127.0.0.1"); - + String error = "Not correct: DB Server = " + server; InetAddress databaseServer = null; try @@ -90,77 +98,77 @@ public class ConfigPostgreSQL extends Config error += " - " + e.getMessage(); pass = false; } - if (getPanel() != null) - signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SERVER, "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()); - setProperty(ConfigurationData.ADEMPIERE_DB_PATH, p_data.getDatabaseType()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, data.getDatabaseType()); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PATH, data.getDatabaseType()); // Database Port - int databasePort = p_data.getDatabasePort(); - pass = p_data.testPort (databaseServer, databasePort, true); + int databasePort = data.getDatabasePort(); + pass = data.testPort (databaseServer, databasePort, true); error = "DB Server Port = " + databasePort; - if (getPanel() != null) - signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SERVER, "ErrorDatabasePort", + pass, true, error)); if (!pass) return error; log.info("OK: Database Port = " + databasePort); - setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); // JDBC Database Info - String databaseName = p_data.getDatabaseName(); // Service Name - String systemPassword = p_data.getDatabaseSystemPassword(); + String databaseName = data.getDatabaseName(); // Service Name + String systemPassword = data.getDatabaseSystemPassword(); // URL (derived) - String urlSystem = p_db.getConnectionURL(databaseServer.getHostName(), databasePort, + 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 + error = "Error connecting: " + urlSystem + " - " + p_db.getSystemUser() + "/" + systemPassword; - if (getPanel() != null) - signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SYSTEM_PASSWORD, "ErrorJDBC", + pass, true, error)); if (!pass) return error; log.info("OK: System Connection = " + urlSystem); - setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword); + data.setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword); // Database User Info - String databaseUser = p_data.getDatabaseUser(); // UID - String databasePassword = p_data.getDatabasePassword(); // PWD + String databaseUser = data.getDatabaseUser(); // UID + String databasePassword = data.getDatabasePassword(); // PWD pass = databasePassword != null && databasePassword.length() > 0; error = "Invalid Database User Password"; - if (getPanel() != null) - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, true, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "ErrorJDBC", + pass, true, error)); if (!pass) return error; // - String url= p_db.getConnectionURL(databaseServer.getHostName(), databasePort, + String url= p_db.getConnectionURL(databaseServer.getHostName(), databasePort, databaseName, databaseUser); // Ignore result as it might not be imported pass = testJDBC(url, databaseUser, databasePassword); error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword; - if (getPanel() != null) - signalOK(getPanel().okDatabaseUser, "ErrorJDBC", - pass, false, error); + if (monitor != null) + monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "ErrorJDBC", + pass, false, error)); if (pass) log.info("OK: Database User = " + databaseUser); else log.warning(error); - setProperty(ConfigurationData.ADEMPIERE_DB_URL, url); - setProperty(ConfigurationData.ADEMPIERE_DB_NAME, databaseName); - setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); - setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); + data.setProperty(ConfigurationData.ADEMPIERE_DB_URL, url); + data.setProperty(ConfigurationData.ADEMPIERE_DB_NAME, databaseName); + data.setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); + data.setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); return null; } // test - + /** * Test JDBC Connection to Server * @param url connection string @@ -182,5 +190,10 @@ public class ConfigPostgreSQL extends Config } return true; } // testJDBC - + + @Override + public String getDatabaseName(String nativeConnectioName) { + return nativeConnectioName; + } + } // ConfigPostgreSQL