Implemented db configuration as extension. Remove JVM type checking.

This commit is contained in:
Heng Sin Low 2010-11-29 01:59:28 +08:00
parent 92ea2ef0bb
commit af5cd44af8
25 changed files with 685 additions and 658 deletions

View File

@ -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",

View File

@ -0,0 +1,41 @@
<!-- ====================================================== -->
<!-- Setup Tomcat For Development Environment -->
<!-- ====================================================== -->
<project name="setup" default="setup" basedir=".">
<description>
This buildfile is used to setup the Adempiere Environment.
</description>
<property environment="env" />
<property name="envFile" value="../AdempiereEnv.properties" />
<!-- ==================================================== -->
<!-- Init -->
<!-- ==================================================== -->
<target name="setupTomcat"
description="setup tomcat">
<echo message="Setup Tomcat ===================" />
<echo message="ADEMPIERE_HOME = ${env.ADEMPIERE_HOME}" />
<!-- create the time stamp and environment -->
<tstamp />
<available file="${envFile}" property="envFileExists" />
<fail message="**** RUN_setup was not successful - please re-run ****" unless="envFileExists" />
<property file="${envFile}"/>
<filter filtersfile="${envFile}" />
<copy file="../org.adempiere.tomcat.config/META-INF/tomcat/serverTemplate.xml"
tofile="../org.adempiere.tomcat.config/META-INF/tomcat/server.xml" filtering="yes" overwrite="yes"/>
</target>
<!-- ==================================================== -->
<!-- Setup (Main) -->
<!-- ==================================================== -->
<target name="setup" depends="setupTomcat"
description="Setup Adempiere">
</target>
</project>

View File

@ -10,17 +10,17 @@
<booleanAttribute key="clearConfig" value="false"/>
<booleanAttribute key="clearws" value="false"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/New_configuration"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/install.app"/>
<booleanAttribute key="default" value="false"/>
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-install.app"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -noExit"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -arch ${target.arch} -nl ${target.nl} -consoleLog -noExit"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.server.server_product"/>
<stringAttribute key="selected_target_plugins" value="com.springsource.javax.mail@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.equinox.common@2:true,org.eclipse.core.jobs@default:default,org.eclipse.osgi@-1:true,com.springsource.org.apache.poi@default:default,com.springsource.org.junit@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.runtime@default:true,com.springsource.javax.jms@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.javax.ejb@default:default,org.restlet@default:default,org.apache.ant@default:default,com.springsource.org.apache.commons.collections@default:default,com.springsource.org.apache.commons.logging@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.servlet@default:default,com.springsource.javax.activation@default:default,org.eclipse.equinox.app@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.javax.management.j2ee@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.base@default:default,org.adempiere.extend@default:false,org.adempiere.install@default:true,org.apache.ecs@default:default"/>
<stringAttribute key="selected_target_plugins" value="org.restlet@default:default,org.eclipse.core.contenttype@default:default,com.springsource.javax.servlet@default:default,com.springsource.javax.mail@default:default,com.springsource.org.junit@default:default,com.springsource.org.apache.poi@default:default,com.springsource.javax.activation@default:default,com.springsource.javax.xml.rpc@default:default,org.eclipse.equinox.registry@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.core.runtime@default:true,com.springsource.org.apache.commons.logging@default:default,org.eclipse.core.jobs@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.ejb@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.preferences@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.org.apache.commons.collections@default:default,com.springsource.javax.jms@default:default,org.eclipse.equinox.common@2:true,com.springsource.javax.xml.soap@default:default,org.apache.ant@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.apache.ecs@default:default,org.compiere.db.postgresql.provider@default:default,org.compiere.db.oracle.provider@default:default,org.adempiere.extend@default:false,org.adempiere.install@default:true,org.adempiere.base@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
<booleanAttribute key="tracing" value="false"/>

View File

@ -14,13 +14,13 @@
<booleanAttribute key="default" value="false"/>
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-install.console.app"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.server.server_product"/>
<stringAttribute key="selected_target_plugins" value="com.springsource.org.apache.commons.collections@default:default,com.springsource.org.apache.poi@default:default,com.springsource.org.apache.commons.logging@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.javax.activation@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.javax.mail@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.osgi@-1:true,com.springsource.javax.management.j2ee@default:default,org.restlet@default:default,org.eclipse.equinox.common@2:true,com.springsource.org.apache.activemq@default:default,org.apache.ant@default:default,com.springsource.org.apache.kahadb@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.ejb@default:default,org.eclipse.core.runtime@default:true,com.springsource.javax.servlet@default:default,com.springsource.org.junit@default:default,com.springsource.javax.jms@default:default,com.springsource.net.sf.cglib@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.contenttype@default:default,com.springsource.org.apache.commons.net@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.base@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.extend@default:false,org.compiere.db.oracle.provider@default:default,org.apache.ecs@default:default,org.adempiere.install@default:true"/>
<stringAttribute key="selected_target_plugins" value="org.restlet@default:default,com.springsource.javax.servlet@default:default,org.eclipse.equinox.common@2:true,com.springsource.javax.xml.rpc@default:default,com.springsource.javax.jms@default:default,com.springsource.org.junit@default:default,com.springsource.org.apache.commons.collections@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.javax.ejb@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.mail@default:default,org.apache.ant@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.javax.activation@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.preferences@default:default,org.eclipse.core.contenttype@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.equinox.app@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.jobs@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.org.apache.poi@default:default,com.springsource.org.apache.commons.logging@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.apache.ecs@default:default,org.adempiere.extend@default:false,org.adempiere.install@default:true,org.compiere.db.oracle.provider@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.base@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
<booleanAttribute key="tracing" value="false"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="org.adempiere.install.IDatabaseConfig" name="Database configuration extension" schema="schema/org.adempiere.install.IDatabaseConfig.exsd"/>
<extension
id="org.adempiere.install.application"
point="org.eclipse.core.runtime.applications">

View File

@ -0,0 +1,109 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.adempiere.install" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.adempiere.install" id="org.adempiere.install.IDatabaseConfig" name="Database configuration extension"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice>
<element ref="database"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="database">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
PostgreSQL or Oracle
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.adempiere.install.IDatabaseConfig"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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<IDatabaseConfig> 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

View File

@ -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

View File

@ -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();
}
}

View File

@ -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();

View File

@ -11,7 +11,6 @@
<property environment="env" />
<property name="envFile" value="AdempiereEnv.properties" />
<property name="server" value="nas" />
<!-- ==================================================== -->
<!-- Init -->

View File

@ -21,8 +21,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.server.server_product"/>
<stringAttribute key="productFile" value="/org.adempiere.server-feature/server.product"/>
<stringAttribute key="selected_target_plugins" value="org.eclipse.equinox.p2.touchpoint.natives@default:default,org.springframework.osgi.io@default:default,com.springsource.org.apache.commons.collections@default:default,com.springsource.javax.servlet.jsp.jstl@default:default,com.springsource.javax.servlet.jsp@default:default,com.springsource.org.apache.xerces@default:false,com.springsource.org.apache.poi@default:default,com.springsource.org.apache.xml.serializer@default:default,org.eclipse.virgo.util.parser.manifest@default:default,org.eclipse.equinox.p2.ql@default:default,com.springsource.slf4j.api@default:default,com.springsource.org.apache.commons.logging@default:default,javax.xml@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,com.springsource.org.apache.catalina.ha.springsource@default:false,org.eclipse.virgo.util.io@default:default,org.springframework.core@default:default,org.eclipse.equinox.p2.director@default:default,com.springsource.org.aopalliance@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,com.springsource.org.apache.jasper.springsource@default:false,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,com.springsource.slf4j.simple@default:false,com.springsource.javax.xml.soap@default:default,org.eclipse.gemini.web.extender@4:true,com.springsource.org.apache.juli.extras.springsource@default:default,com.springsource.javax.activation@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,com.springsource.javax.el@default:default,org.apache.commons.codec@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.console@default:default,org.springframework.aop@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.ds@4:true,org.eclipse.ecf@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.org.apache.catalina.springsource@default:default,org.eclipse.gemini.web.tomcat@4:true,org.springframework.osgi.core@default:default,org.eclipse.virgo.util.osgi@default:default,com.springsource.javax.mail@default:default,org.eclipse.virgo.util.math@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.security@default:default,com.springsource.org.apache.catalina.tribes.springsource@default:false,com.springsource.org.apache.el.springsource@default:default,org.eclipse.equinox.preferences@default:default,org.springframework.beans@default:default,org.eclipse.virgo.util.common@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.p2.jarprocessor@default:default,com.springsource.javax.annotation@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,com.springsource.javax.xml.ws@default:default,com.springsource.javax.management.j2ee@default:default,org.restlet@3:true,org.eclipse.equinox.util@default:default,com.springsource.org.eclipse.jdt.core.compiler.batch@default:default,org.eclipse.equinox.common@2:true,org.apache.commons.httpclient@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.osgi.services@4:true,org.sat4j.pb@default:default,org.eclipse.equinox.p2.metadata@default:default,org.apache.ant@default:default,com.springsource.org.apache.kahadb@default:default,org.eclipse.equinox.registry@default:default,org.sat4j.core@default:default,com.springsource.javax.xml.stream@default:default,org.restlet.ext.servlet@default:default,com.springsource.org.apache.xmlcommons@default:default,com.springsource.javax.ejb@default:default,org.eclipse.equinox.p2.engine@default:default,org.springframework.context@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.gemini.web.core@4:true,org.eclipse.core.runtime@4:true,com.springsource.org.apache.xml.resolver@default:default,com.springsource.org.apache.taglibs.standard@default:default,com.springsource.javax.servlet@default:default,com.springsource.org.junit@default:default,com.springsource.javax.xml.bind@default:default,com.springsource.org.apache.coyote.springsource@default:false,com.springsource.javax.jms@default:default,org.apache.commons.logging@default:default,org.eclipse.equinox.launcher.gtk.linux.x86@default:false,com.springsource.net.sf.cglib@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.contenttype@default:default,com.springsource.javax.persistence@default:default,com.springsource.org.apache.commons.net@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.tomcat.config@default:false,org.adempiere.base@default:default,org.adempiere.payment.processor@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.pipo.handlers@default:default,org.adempiere.extend@default:false,org.adempiere.plugin.utils@default:default,org.adempiere.replication@default:default,org.compiere.db.oracle.provider@default:default,org.apache.ecs@default:default,org.adempiere.base.process@default:default,org.adempiere.report.jasper.library@default:default,org.adempiere.report.jasper@default:default,org.adempiere.ui@default:default,org.adempiere.install@3:true,org.adempiere.report.jasper.webapp@4:true,org.adempiere.replication.server@4:true,org.adempiere.base.callout@default:default,org.adempiere.pipo@default:default,org.adempiere.ui.zk@4:true,org.adempiere.server@4:true,org.adempiere.webstore@4:true"/>
<stringAttribute key="selected_target_plugins" value="org.eclipse.equinox.security@default:default,org.eclipse.virgo.util.common@default:default,org.restlet@3:true,com.springsource.javax.xml.ws@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.osgi.services@4:true,com.springsource.org.apache.el.springsource@default:default,com.springsource.javax.xml.bind@default:default,org.springframework.osgi.core@default:default,org.eclipse.equinox.launcher@default:default,com.springsource.javax.servlet@default:default,org.eclipse.equinox.common@2:true,com.springsource.javax.xml.stream@default:default,com.springsource.javax.xml.rpc@default:default,org.restlet.ext.servlet@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.p2.director@default:default,com.springsource.javax.jms@default:default,org.eclipse.ecf@default:default,org.eclipse.virgo.util.io@default:default,org.eclipse.gemini.web.extender@4:true,org.eclipse.equinox.ds@4:true,org.eclipse.equinox.p2.core@default:default,org.springframework.core@default:default,com.springsource.org.junit@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,com.springsource.org.apache.commons.collections@default:default,org.springframework.beans@default:default,com.springsource.org.apache.xml.resolver@default:default,org.eclipse.equinox.launcher.gtk.linux.x86@default:false,com.springsource.javax.management.j2ee@default:default,org.eclipse.virgo.util.math@default:default,com.springsource.javax.ejb@default:default,com.springsource.javax.persistence@default:default,com.springsource.javax.annotation@default:default,com.springsource.slf4j.api@default:default,com.springsource.org.apache.taglibs.standard@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,com.springsource.org.apache.xmlcommons@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.gemini.web.tomcat@4:true,com.springsource.javax.servlet.jsp@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.springframework.aop@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.repository@default:default,com.springsource.org.apache.catalina.tribes.springsource@default:false,com.springsource.org.apache.commons.net@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.servlet.jsp.jstl@default:default,com.springsource.javax.mail@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.apache.ant@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,com.springsource.org.apache.xerces@default:false,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.gemini.web.core@4:true,com.springsource.net.sf.cglib@default:default,com.springsource.javax.activation@default:default,org.apache.commons.httpclient@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.equinox.http.registry@default:default,com.springsource.org.apache.catalina.springsource@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.osgi@-1:true,org.eclipse.virgo.util.parser.manifest@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.virgo.util.osgi@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.p2.ql@default:default,com.springsource.org.apache.juli.extras.springsource@default:default,com.springsource.org.apache.coyote.springsource@default:false,com.springsource.org.apache.activemq@default:default,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.apache.commons.logging@default:default,com.springsource.org.apache.catalina.ha.springsource@default:false,org.springframework.osgi.io@default:default,org.eclipse.equinox.app@default:default,org.springframework.context@default:default,org.eclipse.equinox.util@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.core.runtime@4:true,com.springsource.org.aopalliance@default:default,org.eclipse.core.jobs@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.javax.el@default:default,com.springsource.org.apache.jasper.springsource@default:false,com.springsource.org.apache.kahadb@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,com.springsource.org.apache.xml.serializer@default:default,com.springsource.slf4j.simple@default:false,com.springsource.org.eclipse.jdt.core.compiler.batch@default:default,com.springsource.org.apache.poi@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,com.springsource.org.apache.commons.logging@default:default,javax.xml@default:default,org.apache.commons.codec@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.apache.ecs@default:default,org.adempiere.report.jasper@default:default,org.adempiere.report.jasper.webapp@4:true,org.adempiere.report.jasper.library@default:default,org.adempiere.replication@default:default,org.adempiere.extend@default:false,org.adempiere.install@3:true,org.adempiere.replication.server@4:true,org.compiere.db.oracle.provider@default:default,org.adempiere.pipo@default:default,org.adempiere.tomcat.config@default:false,org.adempiere.plugin.utils@default:default,org.adempiere.server@4:true,org.adempiere.pipo.handlers@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.payment.processor@default:default,org.adempiere.ui.zk@4:true,org.adempiere.base.process@default:default,org.adempiere.base.callout@default:default,org.adempiere.webstore@4:true,org.adempiere.base@default:default,org.adempiere.ui@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>

View File

@ -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,

View File

@ -8,5 +8,14 @@
id="Oracle">
</database>
</extension>
<extension
id="org.adempiere.db.config.ConfigOracle"
name="Oracle Database Configuration"
point="org.adempiere.install.IDatabaseConfig">
<database
class="org.adempiere.db.oracle.config.ConfigOracle"
id="Oracle">
</database>
</extension>
</plugin>

View File

@ -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

View File

@ -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"

View File

@ -8,5 +8,14 @@
id="PostgreSQL">
</database>
</extension>
<extension
id="org.adempiere.db.postgresql.config.ConfigPostgreSQL"
name="PostgreSQL Database Configuration"
point="org.adempiere.install.IDatabaseConfig">
<database
class="org.adempiere.db.postgresql.config.ConfigPostgreSQL"
id="PostgreSQL">
</database>
</extension>
</plugin>

View File

@ -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