Author: sergiykarpenko
Date: 2011-01-24 08:41:35 -0500 (Mon, 24 Jan 2011)
New Revision: 3835
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
Log:
EXOJCR-1148: DBCreator cleanup
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
---
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24
13:20:31 UTC (rev 3834)
+++
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24
13:41:35 UTC (rev 3835)
@@ -77,31 +77,16 @@
public static final String PASSWORD_TEMPLATE = "${password}";
/**
- * Driver class name.
- */
- protected final String driver;
-
- /**
* Server url.
*/
protected final String serverUrl;
/**
- * User name with administrative rights for connection to server.
+ * Connection properties.
*/
- protected final String adminName;
+ protected final Map<String, String> connectionProperties;
/**
- * User's password.
- */
- protected final String adminPwd;
-
- /**
- * Internal login connection property needed for Oracle.
- */
- protected final String internal_logon;
-
- /**
* DDL script database creation.
*/
protected final String dbScript;
@@ -117,11 +102,6 @@
protected final String dbPassword;
/**
- * Connection properties.
- */
- protected final Map<String, String> connectionProperties;
-
- /**
* DBCreator constructor.
*
* @param params
@@ -138,44 +118,38 @@
if (prop != null)
{
- this.driver = prop.getProperty(DB_DRIVER);
- if (driver == null)
+ if (prop.getProperty(DB_DRIVER) == null)
{
throw new ConfigurationException("driverClassName expected in
db-connection properties section");
}
- this.serverUrl = prop.getProperty(DB_URL);
+ serverUrl = prop.getProperty(DB_URL);
if (serverUrl == null)
{
throw new ConfigurationException("url expected in db-connection
properties section");
}
- this.adminName = prop.getProperty(DB_USERNAME);
- if (adminName == null)
+ if (prop.getProperty(DB_USERNAME) == null)
{
throw new ConfigurationException("username expected in db-connection
properties section");
}
- this.adminPwd = prop.getProperty(DB_PASSWORD);
- if (adminPwd == null)
+ if (prop.getProperty(DB_PASSWORD) == null)
{
throw new ConfigurationException("password expected in db-connection
properties section");
}
- this.internal_logon = prop.getProperty(DB_ORCL_INTERNAL_LOGON);
-
// Store all connection properties into single map
Iterator<Property> pit = prop.getPropertyIterator();
- Map<String, String> tempMap = new HashMap<String, String>();
+ connectionProperties = new HashMap<String, String>();
while (pit.hasNext())
{
Property p = pit.next();
if (!p.getName().equalsIgnoreCase(DB_URL))
{
- tempMap.put(p.getName(), p.getValue());
+ connectionProperties.put(p.getName(), p.getValue());
}
}
- connectionProperties = tempMap;
}
else
{
@@ -236,13 +210,14 @@
Connection conn = null;
try
{
- Class.forName(driver);
+ Class.forName(connectionProperties.get(DB_DRIVER));
conn = SecurityHelper.doPrivilegedSQLExceptionAction(new
PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
- return DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ return DriverManager.getConnection(serverUrl,
connectionProperties.get(DB_USERNAME),
+ connectionProperties.get(DB_PASSWORD));
}
});
}
@@ -252,7 +227,7 @@
}
catch (ClassNotFoundException e)
{
- throw new DBCreatorException("Can't load the JDBC driver " +
driver, e);
+ throw new DBCreatorException("Can't load the JDBC driver " +
connectionProperties.get(DB_DRIVER), e);
}
String dbProductName;
@@ -316,13 +291,14 @@
Connection conn = null;
try
{
- Class.forName(driver);
+ Class.forName(connectionProperties.get(DB_DRIVER));
conn = SecurityHelper.doPrivilegedSQLExceptionAction(new
PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
- return DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ return DriverManager.getConnection(serverUrl,
connectionProperties.get(DB_USERNAME),
+ connectionProperties.get(DB_PASSWORD));
}
});
}
@@ -332,7 +308,7 @@
}
catch (ClassNotFoundException e)
{
- throw new DBCreatorException("Can't load the JDBC driver " +
driver, e);
+ throw new DBCreatorException("Can't load the JDBC driver " +
connectionProperties.get(DB_DRIVER), e);
}
String dbProductName;
Show replies by date