From 0df3f2bf374688e5a4d1f3a00b45fc4c70afa1ec Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Thu, 9 Oct 2014 14:17:39 -0700 Subject: [PATCH] CSPACE-6405: For the v4.x code base, add support for JDBC options. See CSPACE-6404. --- 3rdparty/nuxeo/build.xml | 154 +++++++++--------- .../5.5-HF07/config/proto-repo-config.xml | 8 +- build.properties | 37 ++++- installer/build.xml | 4 +- .../main/resources/META-INF/persistence.xml | 2 +- .../src/main/webapp/META-INF/context.xml | 8 +- services/account/client/build.xml | 2 +- .../test/resources/META-INF/persistence.xml | 2 +- services/account/pstore/build.xml | 2 +- services/authorization-mgt/import/build.xml | 2 +- .../applicationContext-authorization.xml | 2 +- .../services/common/ServiceMain.java | 35 ++-- 12 files changed, 145 insertions(+), 113 deletions(-) diff --git a/3rdparty/nuxeo/build.xml b/3rdparty/nuxeo/build.xml index c02d9b675..71eb3207d 100644 --- a/3rdparty/nuxeo/build.xml +++ b/3rdparty/nuxeo/build.xml @@ -1,164 +1,158 @@ - - - collectionspace nuxeo - + collectionspace nuxeo - - - + + + - + - + - + - + - + - + description="Package CollectionSpace Services"/> - - - - - - + + + + + + - - - - - - - - + + + + + + + + - + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - + - - + + - - - - + + + + - + - - + + - - - - + + + + + description="deploy nuxeo server libs to ${jee.server.cspace}"> - + - + - - - - - - - - - + + + + + + + + + + - - + - + - - - - + diff --git a/3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/proto-repo-config.xml b/3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/proto-repo-config.xml index 5e9274776..fa925a646 100644 --- a/3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/proto-repo-config.xml +++ b/3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/proto-repo-config.xml @@ -29,12 +29,10 @@ @XA_DATASOURCE@ - - - @DB_URL@ @DB_SERVER_HOSTNAME@ - - + + @DB_JDBC_OPTIONS@ + @DB_PORT@ @NUXEO_USER@ @NUXEO_PW@ diff --git a/build.properties b/build.properties index 176cf6a10..56e3e6187 100644 --- a/build.properties +++ b/build.properties @@ -140,7 +140,38 @@ db.host=localhost db.jdbc.baseurl=jdbc:${db}://${db.host}:${db.port} # -# JDBC URL's. The csadmin URL is needed to authenticate with the PostGreSQL server because an existing database must be supplied during authentication. +# JDBC options that can be added to the database URL. We need to supply an "encoded" version +# of the options for cases where the URL is processed inside of XML scripts/files # -db.jdbc.csadmin.url=${db.jdbc.baseurl}/${db.csadmin.name} -db.jdbc.cspace.url=${db.jdbc.baseurl}/${db.cspace.name} + +# Use the following JDBC options to enable CSpace to establish SSL +# connections with the database server. +# +# ssl=true ;means we can talk SSL to the database server +# sslfactory ;set this to the SSL factory class. The default is to perform validation. Use NonValidatingFactory class to skip validation +# foo=true ;an extra "throw way" options seems to be needed to prevent parsing errors for some tools/code. + +# +# Here is an example of how to set the JDBC options for connecting to an SSL enabled +# PostgreSQL server. +# +#db.jdbc.urloptions=ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&foo=true +#db.jdbc.urloptions.encoded=ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&foo=true + +# +# By default, as placeholders, we'll supply meaningless JDBC options -both encoded and non-encode forms. +# +db.jdbc.urloptions=foo=true&bar=false +db.jdbc.urloptions.encoded=foo=true&bar=false + +# +# JDBC urls that CollectionSpace needs to talk to the "admin" database, Nuxeo databases, and the "cspace" database (i.e., the AuthN/AuthZ database) +# +db.jdbc.csadmin.url=${db.jdbc.baseurl}/postgres?${db.jdbc.urloptions} +db.jdbc.csadmin.url.encoded=${db.jdbc.baseurl}/postgres?${db.jdbc.urloptions.encoded} + +db.jdbc.nuxeo.url=${db.jdbc.baseurl}/${DatabaseName}?${db.jdbc.urloptions} +db.jdbc.nuxeo.url.encoded=${db.jdbc.baseurl}/${DatabaseName}?${db.jdbc.urloptions.encoded} + +db.jdbc.cspace.url=${db.jdbc.baseurl}/cspace?${db.jdbc.urloptions} +db.jdbc.cspace.url.encoded=${db.jdbc.baseurl}/cspace?${db.jdbc.urloptions.encoded} \ No newline at end of file diff --git a/installer/build.xml b/installer/build.xml index 87efe6251..20ac2d6f8 100644 --- a/installer/build.xml +++ b/installer/build.xml @@ -59,7 +59,7 @@ - + diff --git a/services/JaxRsServiceProvider/src/main/webapp/META-INF/context.xml b/services/JaxRsServiceProvider/src/main/webapp/META-INF/context.xml index 60608988b..39201643a 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/META-INF/context.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/META-INF/context.xml @@ -69,7 +69,7 @@ username="${db.cspace.user}" password="${db.cspace.user.password}" driverClassName="${db.jdbc.driver.class}" - url="${db.jdbc.cspace.url}" + url="${db.jdbc.cspace.url.encoded}" maxActive="8" maxIdle="4" testWhileIdle="true" @@ -82,7 +82,7 @@ username="${db.nuxeo.user}" password="${db.nuxeo.user.password}" driverClassName="${db.jdbc.driver.class}" - url="jdbc:${db}://${db.host}:${db.port}/${DatabaseName}" + url="${db.jdbc.nuxeo.url.encoded}" maxActive="8" maxIdle="4" testWhileIdle="true" @@ -95,7 +95,7 @@ username="${db.csadmin.user}" password="${db.csadmin.user.password}" driverClassName="${db.jdbc.driver.class}" - url="${db.jdbc.csadmin.url}" + url="${db.jdbc.csadmin.url.encoded}" maxActive="8" maxIdle="4" testWhileIdle="true" @@ -108,7 +108,7 @@ username="${db.reader.user}" password="${db.reader.user.password}" driverClassName="${db.jdbc.driver.class}" - url="jdbc:${db}://${db.host}:${db.port}/${DatabaseName}" + url="${db.jdbc.nuxeo.url.encoded}" maxActive="8" maxIdle="4" testWhileIdle="true" diff --git a/services/account/client/build.xml b/services/account/client/build.xml index 83b2f3df9..914ced664 100644 --- a/services/account/client/build.xml +++ b/services/account/client/build.xml @@ -111,7 +111,7 @@ - + diff --git a/services/account/client/src/test/resources/META-INF/persistence.xml b/services/account/client/src/test/resources/META-INF/persistence.xml index 8c4188508..875a72f9a 100644 --- a/services/account/client/src/test/resources/META-INF/persistence.xml +++ b/services/account/client/src/test/resources/META-INF/persistence.xml @@ -16,7 +16,7 @@ - + diff --git a/services/account/pstore/build.xml b/services/account/pstore/build.xml index 01288538f..09106c56f 100644 --- a/services/account/pstore/build.xml +++ b/services/account/pstore/build.xml @@ -113,7 +113,7 @@ - + diff --git a/services/authorization-mgt/import/build.xml b/services/authorization-mgt/import/build.xml index 3acf32ec0..c3b7594bd 100644 --- a/services/authorization-mgt/import/build.xml +++ b/services/authorization-mgt/import/build.xml @@ -138,7 +138,7 @@ - + diff --git a/services/authorization/service/src/main/resources/applicationContext-authorization.xml b/services/authorization/service/src/main/resources/applicationContext-authorization.xml index 866d555cc..d92c1735a 100644 --- a/services/authorization/service/src/main/resources/applicationContext-authorization.xml +++ b/services/authorization/service/src/main/resources/applicationContext-authorization.xml @@ -43,7 +43,7 @@ - + diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index c8f8bb472..d08e8231a 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -916,35 +916,44 @@ public class ServiceMain { String cspaceInstanceId, String binaryStorePath) { String databaseName = JDBCTools.getDatabaseName(repositoryName, cspaceInstanceId); - repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, - "/component", "name", String.format("config:%s-repository", repositoryName)); + repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, "/component", "name", + String.format("config:%s-repository", repositoryName)); + // Text substitutions within first extension point, "repository" repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, - REPOSITORY_EXTENSION_POINT_XPATH + "/repository", "name", repositoryName); + REPOSITORY_EXTENSION_POINT_XPATH + "/repository", "name", + repositoryName); + repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, - REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository", "name", repositoryName); + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository", "name", + repositoryName); + repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/binaryStore", "path", Tools.isBlank(binaryStorePath) ? repositoryName : binaryStorePath); // Can be either partial or full path. Partial path will be relative to Nuxeo's data directory - String url = XmlTools.getElementValue(repoConfigDoc, - REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='URL']"); - if (! Tools.isBlank(url)) { - repoConfigDoc = XmlTools.setElementValue(repoConfigDoc, - REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='URL']", - url + databaseName); - } + + /* Create the JDBC url options if any exist */ + String jdbcOptions = XmlTools.getElementValue(repoConfigDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='JDBCOptions']"); + jdbcOptions = Tools.isBlank(jdbcOptions) ? "" : "?" + jdbcOptions; + repoConfigDoc = XmlTools.setElementValue(repoConfigDoc, REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='DatabaseName']", - databaseName); + databaseName + jdbcOptions); + // Text substitutions within second extension point, "repositories" repoConfigDoc = XmlTools.setElementValue(repoConfigDoc, REPOSITORIES_EXTENSION_POINT_XPATH + "/documentation", String.format("The %s repository", repositoryName)); + repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, - REPOSITORIES_EXTENSION_POINT_XPATH + "/repository", "name", repositoryName); + REPOSITORIES_EXTENSION_POINT_XPATH + "/repository", "name", + repositoryName); + repoConfigDoc = XmlTools.setAttributeValue(repoConfigDoc, REPOSITORIES_EXTENSION_POINT_XPATH + "/repository", "label", String.format("%s Repository", repositoryName)); + return repoConfigDoc; } -- 2.47.3