You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/03/04 16:29:53 UTC
svn commit: r1078003 - in /incubator/lcf/trunk: CHANGES.txt
framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
Author: kwright
Date: Fri Mar 4 15:29:53 2011
New Revision: 1078003
URL: http://svn.apache.org/viewvc?rev=1078003&view=rev
Log:
Fix for CONNECTORS-159.
Modified:
incubator/lcf/trunk/CHANGES.txt
incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1078003&r1=1078002&r2=1078003&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Fri Mar 4 15:29:53 2011
@@ -3,6 +3,9 @@ $Id$
================== 0.2-dev ==================
+CONNECTORS-159: Add support for external PostgreSQL server
+(Erlend GarĂ¥sen, Karl Wright)
+
CONNECTORS-165: Upgrade to jetty 6.1.26, plus patches, which is what
Solr is using.
(Robert Muir, Karl Wright)
Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java?rev=1078003&r1=1078002&r2=1078003&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java (original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java Fri Mar 4 15:29:53 2011
@@ -27,7 +27,14 @@ public class DBInterfacePostgreSQL exten
{
public static final String _rcsid = "@(#)$Id: DBInterfacePostgreSQL.java 999670 2010-09-21 22:18:19Z kwright $";
- private static final String _url = "jdbc:postgresql://localhost/";
+ /** PostgreSQL host name property */
+ public static final String postgresqlHostnameProperty = "org.apache.manifoldcf.postgresql.hostname";
+ /** PostgreSQL port property */
+ public static final String postgresqlPortProperty = "org.apache.manifoldcf.postgresql.port";
+ /** PostgreSQL ssl property */
+ public static final String postgresqlSslProperty = "org.apache.manifoldcf.postgresql.ssl";
+
+ private static final String _defaultUrl = "jdbc:postgresql://localhost/";
private static final String _driver = "org.postgresql.Driver";
/** A lock manager handle. */
@@ -47,10 +54,32 @@ public class DBInterfacePostgreSQL exten
public DBInterfacePostgreSQL(IThreadContext tc, String databaseName, String userName, String password)
throws ManifoldCFException
{
- super(tc,_url+databaseName,_driver,databaseName,userName,password);
+ super(tc,getJdbcUrl(databaseName),_driver,databaseName,userName,password);
cacheKey = CacheKeyFactory.makeDatabaseKey(this.databaseName);
lockManager = LockManagerFactory.make(tc);
}
+
+ private static String getJdbcUrl(final String databaseName)
+ {
+ String jdbcUrl = _defaultUrl + databaseName;
+ final String hostname = ManifoldCF.getProperty(postgresqlHostnameProperty);
+ final String ssl = ManifoldCF.getProperty(postgresqlSslProperty);
+ final String port = ManifoldCF.getProperty(postgresqlPortProperty);
+ if (hostname != null && hostname.length() > 0)
+ {
+ jdbcUrl = "jdbc:postgresql://" + hostname;
+ if (port != null && port.length() > 0)
+ {
+ jdbcUrl += ":" + port;
+ }
+ jdbcUrl += "/" + databaseName;
+ if (ssl != null && ssl.equals("true"))
+ {
+ jdbcUrl += "?ssl=true";
+ }
+ }
+ return jdbcUrl;
+ }
/** Initialize. This method is called once per JVM instance, in order to set up
* database communication.
@@ -508,7 +537,7 @@ public class DBInterfacePostgreSQL exten
throws ManifoldCFException
{
// Create a connection to the master database, using the credentials supplied
- Database masterDatabase = new Database(context,_url+"template1",_driver,"template1",adminUserName,adminPassword);
+ Database masterDatabase = new Database(context,getJdbcUrl("template1"),_driver,"template1",adminUserName,adminPassword);
try
{
// Create user
@@ -562,7 +591,7 @@ public class DBInterfacePostgreSQL exten
throws ManifoldCFException
{
// Create a connection to the master database, using the credentials supplied
- Database masterDatabase = new Database(context,_url+"template1",_driver,"template1",adminUserName,adminPassword);
+ Database masterDatabase = new Database(context,getJdbcUrl("template1"),_driver,"template1",adminUserName,adminPassword);
try
{
// Drop database