IDEMPIERE-472 Allow postgresql connection via SSL

This commit is contained in:
Juan David Arboleda 2012-10-26 13:46:05 -05:00
parent 494c20a6b5
commit e99ca7f076
9 changed files with 217 additions and 62 deletions

View File

@ -19,6 +19,12 @@
*****************************************************************************/
package org.adempiere.base;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import org.adempiere.base.equinox.StackTraceCommand;
import org.compiere.Adempiere;
import org.eclipse.osgi.framework.console.CommandProvider;
@ -44,10 +50,52 @@ public class BaseActivator implements BundleActivator {
*/
@Override
public void start(BundleContext context) throws Exception {
//Load SSL
loadSSLDBProperties(Adempiere.getAdempiereHome());
bundleContext = context;
context.registerService(CommandProvider.class.getName(), new StackTraceCommand(), null);
}
/*
* Load idempiereInit.properties into the system.
*/
private void loadSSLDBProperties(String filePath) {
Properties s_prop = new Properties();
String fileName = filePath+ File.separator+"idempiereInit.properties";
File env = new File (fileName);
boolean loadOk = true;
if (env.exists())
{
FileInputStream fis = null;
try
{
fis = new FileInputStream(env);
s_prop.load(fis);
}catch (Exception e){
loadOk = false;
System.err.println("Exception while loading idempiereInit.properties: "+ e.toString());
}finally{
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (loadOk) {
String key = null;
String value =null;
Enumeration<?> enumeration = s_prop.propertyNames();
while (enumeration.hasMoreElements()) {
key = (String) enumeration.nextElement();
value = s_prop.getProperty(key);
System.setProperty(key,value) ;
//System.out.println("Loaded Key: "+ key + "- Value :"+value);
}
}
}
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/

View File

@ -169,7 +169,8 @@ public class ConfigurationData
public static final String ADEMPIERE_DB_PASSWORD = "ADEMPIERE_DB_PASSWORD";
/** */
public static final String ADEMPIERE_DB_SYSTEM = "ADEMPIERE_DB_SYSTEM";
/** */
public static final String ADEMPIERE_DB_EXISTS = "ADEMPIERE_DB_EXISTS";
/** */
public static final String ADEMPIERE_MAIL_SERVER = "ADEMPIERE_MAIL_SERVER";
/** */
@ -277,6 +278,9 @@ public class ConfigurationData
setDatabasePassword((String)loaded.get(ADEMPIERE_DB_PASSWORD));
if (loaded.containsKey(ADEMPIERE_DB_SYSTEM))
setDatabaseSystemPassword((String)loaded.get(ADEMPIERE_DB_SYSTEM));
if (loaded.containsKey(ADEMPIERE_DB_EXISTS))
setDatabaseExists((String)loaded.get(ADEMPIERE_DB_EXISTS));
if (p_panel != null)
{
@ -1385,6 +1389,28 @@ public class ConfigurationData
if (p_panel != null)
p_panel.fSystemPassword.setEnabled(enable);
}
/**
* @param ADEMPIERE_DB_EXISTS
*/
public void setDatabaseExists(String pass)
{
if (p_panel != null)
p_panel.okdbExists.setSelected("Yes".equalsIgnoreCase(pass));
else
updateProperty(ADEMPIERE_DB_EXISTS, pass);
}
/**
* @param
*/
public boolean getDatabaseExists()
{
return p_panel != null
? p_panel.okdbExists.isSelected()
: "Yes".equalsIgnoreCase(p_properties.get(ADEMPIERE_DB_EXISTS).toString());
}
/**
* @return Returns the databaseUser.
*/

View File

@ -130,7 +130,8 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
private JLabel lDatabaseType = new JLabel();
JComboBox fDatabaseType = new JComboBox(ConfigurationData.DBTYPE);
//
JLabel lDatabaseServer = new JLabel();
JLabel lDatabaseServer = new JLabel("Base de Datos Existe");
JLabel ldbExists = new JLabel();
JTextField fDatabaseServer = new JTextField(FIELDLENGTH);
private JLabel lDatabaseName = new JLabel();
JTextField fDatabaseName = new JTextField(FIELDLENGTH);
@ -148,6 +149,7 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
public JCheckBox okDatabaseUser = new JCheckBox();
public JCheckBox okDatabaseSystem = new JCheckBox();
public JCheckBox okDatabaseSQL = new JCheckBox();
public JCheckBox okdbExists = new JCheckBox();
//
JLabel lMailServer = new JLabel();
JTextField fMailServer = new JTextField(FIELDLENGTH);
@ -282,19 +284,26 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
sectionLabel = new JLabel(res.getString("DatabaseServer"));
sectionLabel.setForeground(titledBorder.getTitleColor());
separator = new JSeparator();
ldbExists.setToolTipText(res.getString("DbExists"));
ldbExists.setText(res.getString("DbExists"));
this.add(sectionLabel, new GridBagConstraints(0, 11, 6, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 0, 0), 0, 0));
this.add(separator, new GridBagConstraints(0, 12, 7, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 10), 0, 0));
this.add(lDatabaseServer, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0
this.add(ldbExists, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
this.add(okdbExists, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 2, 5), 0, 0));
this.add(lDatabaseServer, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
this.add(fDatabaseServer, new GridBagConstraints(1, 13, 1, 1, 0.5, 0.0
this.add(fDatabaseServer, new GridBagConstraints(1, 14, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 2, 0), 0, 0));
this.add(okDatabaseServer, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0
this.add(okDatabaseServer, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 2, 5), 0, 0));
this.add(lDatabaseType, new GridBagConstraints(4, 13, 1, 1, 0.0, 0.0
this.add(lDatabaseType, new GridBagConstraints(4, 14, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
this.add(fDatabaseType, new GridBagConstraints(5, 13, 1, 1, 0.0, 0.0
this.add(fDatabaseType, new GridBagConstraints(5, 14, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 2, 0), 0, 0));
//Database/Service Name
lDatabaseName.setToolTipText(res.getString("DatabaseNameInfo"));
@ -307,15 +316,15 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
fDatabaseDiscovered.setEditable(true);
fDatabaseDiscovered.setPreferredSize(fDatabaseName.getPreferredSize());
okDatabaseSQL.setEnabled(false);
this.add(lDatabaseName, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0
this.add(lDatabaseName, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fDatabaseName, new GridBagConstraints(1, 14, 1, 1, 0.5, 0.0
this.add(fDatabaseName, new GridBagConstraints(1, 15, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 0), 0, 0));
this.add(okDatabaseSQL, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0
this.add(okDatabaseSQL, new GridBagConstraints(2, 15, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
this.add(lDatabaseDiscovered, new GridBagConstraints(4, 14, 1, 1, 0.0, 0.0
this.add(lDatabaseDiscovered, new GridBagConstraints(4, 15, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
this.add(fDatabaseDiscovered, new GridBagConstraints(5, 14, 1, 1, 0.5, 0.0
this.add(fDatabaseDiscovered, new GridBagConstraints(5, 15, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 0), 0, 0));
// Port - System
lDatabasePort.setToolTipText(res.getString("DatabasePortInfo"));
@ -325,15 +334,15 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
lSystemPassword.setText(res.getString("SystemPassword"));
fSystemPassword.setText(".");
okDatabaseSystem.setEnabled(false);
this.add(lDatabasePort, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0
this.add(lDatabasePort, new GridBagConstraints(0, 16, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fDatabasePort, new GridBagConstraints(1, 15, 1, 1, 0.5, 0.0
this.add(fDatabasePort, new GridBagConstraints(1, 16, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 0), 0, 0));
this.add(lSystemPassword, new GridBagConstraints(4, 15, 1, 1, 0.0, 0.0
this.add(lSystemPassword, new GridBagConstraints(4, 16, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fSystemPassword, new GridBagConstraints(5, 15, 1, 1, 0.5, 0.0
this.add(fSystemPassword, new GridBagConstraints(5, 16, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 0), 0, 0));
this.add(okDatabaseSystem, new GridBagConstraints(6, 15, 1, 1, 0.0, 0.0
this.add(okDatabaseSystem, new GridBagConstraints(6, 16, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
// User - Password
@ -344,23 +353,23 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
lDatabasePassword.setText(res.getString("DatabasePassword"));
fDatabasePassword.setText(".");
okDatabaseUser.setEnabled(false);
this.add(lDatabaseUser, new GridBagConstraints(0, 16, 1, 1, 0.0, 0.0
this.add(lDatabaseUser, new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fDatabaseUser, new GridBagConstraints(1, 16, 1, 1, 0.5, 0.0
this.add(fDatabaseUser, new GridBagConstraints(1, 17, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 0), 0, 0));
this.add(lDatabasePassword, new GridBagConstraints(4, 16, 1, 1, 0.0, 0.0
this.add(lDatabasePassword, new GridBagConstraints(4, 17, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fDatabasePassword, new GridBagConstraints(5, 16, 1, 1, 0.5, 0.0
this.add(fDatabasePassword, new GridBagConstraints(5, 17, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 0), 0, 0));
this.add(okDatabaseUser, new GridBagConstraints(6, 16, 1, 1, 0.0, 0.0
this.add(okDatabaseUser, new GridBagConstraints(6, 17, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
sectionLabel = new JLabel(res.getString("MailServer"));
sectionLabel.setForeground(titledBorder.getTitleColor());
separator = new JSeparator();
this.add(sectionLabel, new GridBagConstraints(0, 17, 6, 1, 0.0, 0.0
this.add(sectionLabel, new GridBagConstraints(0, 18, 6, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 0, 0), 0, 0));
this.add(separator, new GridBagConstraints(0, 18, 7, 1, 1.0, 0.0
this.add(separator, new GridBagConstraints(0, 19, 7, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 10), 0, 0));
// Mail Server - Email
lMailServer.setToolTipText(res.getString("MailServerInfo"));
@ -371,15 +380,15 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
lAdminEMail.setText(res.getString("AdminEMail"));
fAdminEMail.setText(".");
okMailServer.setEnabled(false);
this.add(lMailServer, new GridBagConstraints(0, 19, 1, 1, 0.0, 0.0
this.add(lMailServer, new GridBagConstraints(0, 20, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
this.add(fMailServer, new GridBagConstraints(1, 19, 1, 1, 0.5, 0.0
this.add(fMailServer, new GridBagConstraints(1, 20, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 2, 0), 0, 0));
this.add(okMailServer, new GridBagConstraints(2, 19, 1, 1, 0.0, 0.0
this.add(okMailServer, new GridBagConstraints(2, 20, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 2, 5), 0, 0));
this.add(lAdminEMail, new GridBagConstraints(4, 19, 1, 1, 0.0, 0.0
this.add(lAdminEMail, new GridBagConstraints(4, 20, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0));
this.add(fAdminEMail, new GridBagConstraints(5, 19, 1, 1, 0.5, 0.0
this.add(fAdminEMail, new GridBagConstraints(5, 20, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 2, 0), 0, 0));
// Mail User = Password
@ -390,22 +399,22 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
lMailPassword.setText(res.getString("MailPassword"));
fMailPassword.setText(".");
okMailUser.setEnabled(false);
this.add(lMailUser, new GridBagConstraints(0, 20, 1, 1, 0.0, 0.0
this.add(lMailUser, new GridBagConstraints(0, 21, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fMailUser, new GridBagConstraints(1, 20, 1, 1, 0.5, 0.0
this.add(fMailUser, new GridBagConstraints(1, 21, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 5, 2, 0), 0, 0));
this.add(lMailPassword, new GridBagConstraints(4, 20, 1, 1, 0.0, 0.0
this.add(lMailPassword, new GridBagConstraints(4, 21, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
this.add(fMailPassword, new GridBagConstraints(5, 20, 1, 1, 0.5, 0.0
this.add(fMailPassword, new GridBagConstraints(5, 21, 1, 1, 0.5, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 0), 0, 0));
this.add(okMailUser, new GridBagConstraints(6, 20, 1, 1, 0.0, 0.0
this.add(okMailUser, new GridBagConstraints(6, 21, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
//grap extra space when window is maximized
JPanel filler = new JPanel();
filler.setOpaque(false);
filler.setBorder(null);
this.add(filler, new GridBagConstraints(0, 21, 1, 1, 0.0, 1.0
this.add(filler, new GridBagConstraints(0, 22, 1, 1, 0.0, 1.0
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
// End
@ -414,11 +423,11 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
bSave.setToolTipText(res.getString("SaveInfo"));
bSave.setText(res.getString("Save"));
bHelp.setToolTipText(res.getString("HelpInfo"));
this.add(bTest, new GridBagConstraints(0, 22, 1, 1, 0.0, 0.0
this.add(bTest, new GridBagConstraints(0, 23, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 10, 5), 0, 0));
this.add(bHelp, new GridBagConstraints(3, 22, 2, 1, 0.0, 0.0
this.add(bHelp, new GridBagConstraints(3, 23, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 10, 5), 0, 0));
this.add(bSave, new GridBagConstraints(5, 22, 2, 1, 0.0, 0.0
this.add(bSave, new GridBagConstraints(5, 23, 2, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(15, 5, 10, 5), 0, 0));
//
bAdempiereHome.addActionListener(this);
@ -558,6 +567,12 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
*/
private void test() throws Exception
{
cleanSignalOk ();
/*
* In order to allow the user see a refresh on the screen
* this Thread goes into sleep for 1000L milliseconds
*/
Thread.sleep(1000L);
bSave.setEnabled(false);
if (!m_data.test(this))
return;
@ -593,6 +608,32 @@ public class ConfigurationPanel extends JPanel implements ActionListener, IDBCon
cb.setBackground(Color.GREEN);
} // setOK
void cleanSignalOk (){
okJavaHome.setBackground(null);
okJavaHome.setSelected(false);
okAdempiereHome.setBackground(null);
okAdempiereHome.setSelected(false);
okKeyStore.setBackground(null);
okKeyStore.setSelected(false);
okAppsServer.setBackground(null);
okAppsServer.setSelected(false);
okWebPort.setBackground(null);
okWebPort.setSelected(false);
okSSLPort.setBackground(null);
okSSLPort.setSelected(false);
okDatabaseServer.setBackground(null);
okDatabaseServer.setSelected(false);
okDatabaseUser.setBackground(null);
okDatabaseUser.setSelected(false);
okDatabaseSystem.setBackground(null);
okDatabaseSystem.setSelected(false);
okDatabaseSQL.setBackground(null);
okDatabaseSQL.setSelected(false);
okMailServer.setBackground(null);
okMailServer.setSelected(false);
okMailUser.setBackground(null);
okMailUser.setSelected(false);
}
/**************************************************************************
* Save Settings.

View File

@ -72,6 +72,7 @@ public class SetupRes extends ListResourceBundle
{ "MailPassword", "Mail Password" },
{ "KeyStorePassword", "KeyStore Password" },
{ "KeyStorePasswordInfo", "Password for SSL Key Store" },
{ "DbExists" , "DB Already Exists" },
//
{ "JavaType", "Java VM"},
{ "JavaTypeInfo", "Java VM Vendor"},

View File

@ -73,6 +73,7 @@ public class SetupRes_es extends ListResourceBundle
{ "MailPassword", "Contrase\u00f1a Correo" },
{ "KeyStorePassword", "Contrase\u00f1a Key Store" },
{ "KeyStorePasswordInfo", "Contrase\u00f1a para SSL Key Store" },
{ "DbExists" , "Base de Datos Existe" },
//
{ "JavaType", "Java VM"},
{ "JavaTypeInfo", "Proveedor Java VM"},

View File

@ -53,6 +53,7 @@ public class ConfigurationConsole {
appServerWebPort(reader, writer);
appServerSSLPort(reader, writer);
dbExists(reader, writer);
dbType(reader, writer);
dbHostname(reader, writer);
dbPort(reader, writer);
@ -173,6 +174,7 @@ public class ConfigurationConsole {
if (error != null && error.trim().length() > 0)
{
writer.println("Database test fail: " + error);
dbExists(reader, writer);
dbType(reader, writer);
dbHostname(reader, writer);
dbPort(reader, writer);
@ -422,6 +424,20 @@ public class ConfigurationConsole {
}
}
private void dbExists(BufferedReader reader, PrintWriter writer) throws IOException {
writer.println("DB Already Exists?(Y/N) [N]: ");
String yesNo = reader.readLine();
if ((yesNo == null || yesNo.trim().length() == 0) || "n".equalsIgnoreCase(yesNo))
{
data.setDatabaseExists("No");
}
else
{
data.setDatabaseExists("Yes");
}
}
private void dbType(BufferedReader reader, PrintWriter writer) throws IOException {
String dbType = data.getDatabaseType();

View File

@ -325,7 +325,7 @@ public class ConfigOracle implements IDatabaseConfig
log.info("OK: Database Port = " + databasePort);
data.setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort));
boolean isDBExists = data.getDatabaseExists();
// JDBC Database Info
String databaseName = data.getDatabaseName(); // Service Name
String systemPassword = data.getDatabaseSystemPassword();
@ -334,7 +334,7 @@ public class ConfigOracle implements IDatabaseConfig
if (monitor != null)
monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SYSTEM_PASSWORD, "ErrorJDBC",
pass, true, error));
if (!pass)
if (!pass && !isDBExists)
return error;
//
// URL (derived) jdbc:oracle:thin:@//prod1:1521/prod1
@ -371,18 +371,21 @@ public class ConfigOracle implements IDatabaseConfig
error = "Cannot connect to User: " + databaseUser + "/" + databasePassword + " - Database may not be imported yet (OK on initial run).";
if (monitor != null)
monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "ErrorJDBC",
pass, false, error));
if (pass)
{
pass, true, error));
if (pass){
log.info("OK: Database User = " + databaseUser);
if (m_con != null)
data.setProperty(ConfigurationData.ADEMPIERE_WEBSTORES, data.getWebStores(m_con));
}else{
if (isDBExists){
return error;
}else {
log.warning(error);
}
}
else
log.warning(error);
data.setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser);
data.setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword);
data.setProperty(ConfigurationData.ADEMPIERE_DB_EXISTS,(isDBExists==true ?"Yes":"No"));
String ospath;
if (System.getProperty("os.name").startsWith("Windows"))
ospath = "windows";

View File

@ -118,11 +118,10 @@ public class ConfigPostgreSQL implements IDatabaseConfig
log.info("OK: Database Port = " + databasePort);
data.setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort));
boolean isDBExists = data.getDatabaseExists();
// JDBC Database Info
String databaseName = data.getDatabaseName(); // Service Name
String systemPassword = data.getDatabaseSystemPassword();
// URL (derived)
String urlSystem = p_db.getConnectionURL(databaseServer.getHostName(), databasePort,
p_db.getSystemDatabase(databaseName), p_db.getSystemUser());
@ -132,8 +131,9 @@ public class ConfigPostgreSQL implements IDatabaseConfig
if (monitor != null)
monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_SYSTEM_PASSWORD, "ErrorJDBC",
pass, true, error));
if (!pass)
if (!pass && !isDBExists)
return error;
log.info("OK: System Connection = " + urlSystem);
data.setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword);
@ -156,16 +156,21 @@ public class ConfigPostgreSQL implements IDatabaseConfig
error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword;
if (monitor != null)
monitor.update(new DBConfigStatus(DBConfigStatus.DATABASE_USER, "ErrorJDBC",
pass, false, error));
if (pass)
pass, true, error));
if (pass){
log.info("OK: Database User = " + databaseUser);
else
log.warning(error);
data.setProperty(ConfigurationData.ADEMPIERE_DB_URL, url);
}else{
if (isDBExists){
return error;
}else {
log.warning(error);
}
}
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);
data.setProperty(ConfigurationData.ADEMPIERE_DB_EXISTS,(isDBExists==true ?"Yes":"No"));
return null;
} // test

View File

@ -175,11 +175,16 @@ public class DB_PostgreSQL implements AdempiereDatabase
public String getConnectionURL (CConnection connection)
{
// jdbc:postgresql://hostname:portnumber/databasename?encoding=UNICODE
String urlParameters = System.getProperty("org.idempiere.postgresql.URLParameters") ;
StringBuffer sb = new StringBuffer("jdbc:postgresql:");
sb.append("//").append(connection.getDbHost())
.append(":").append(connection.getDbPort())
.append("/").append(connection.getDbName())
.append("?encoding=UNICODE");
if (urlParameters != null)
sb.append(urlParameters);
m_connection = sb.toString();
return m_connection;
} // getConnectionString
@ -195,8 +200,17 @@ public class DB_PostgreSQL implements AdempiereDatabase
public String getConnectionURL (String dbHost, int dbPort, String dbName,
String userName)
{
return "jdbc:postgresql://"
+ dbHost + ":" + dbPort + "/" + dbName;
//String ULR = "jdbc:postgresql://"+ dbHost + ":" + dbPort + "/" + dbName;
String urlParameters = System.getProperty("org.idempiere.postgresql.URLParameters") ;
StringBuffer sb = new StringBuffer("jdbc:postgresql:");
sb.append("//").append(dbHost)
.append(":").append(dbPort)
.append("/").append(dbName);
if (urlParameters != null)
sb.append("?").append(urlParameters);
return sb.toString();
} // getConnectionURL
/**