]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1892: JDBC Parameter Build Env Var (#475)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Mon, 8 Sep 2025 22:44:49 +0000 (16:44 -0600)
committerGitHub <noreply@github.com>
Mon, 8 Sep 2025 22:44:49 +0000 (16:44 -0600)
* Read from JDBC_URL_PARAMS environment variable
* Remove encoded url from build properties
* Add script to encode url parameters
* Encode jdbc params where needed
* Remove unused configuration

build.properties
build.xml
services/JaxRsServiceProvider/build.xml
services/account/client/src/test/resources/META-INF/persistence.xml

index 93874461f0581350d2f3dd256fca5f5ad1c4b8a4..ecce3d18a42106bdaa220ae9144922b7f922837e 100644 (file)
@@ -198,10 +198,11 @@ db.jdbc.default.datasource=jdbc/default
 #db.jdbc.urloptions.encoded=ssl=true&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory&amp;foo=true
 
 #
-# By default, as placeholders, we'll supply meaningless JDBC options -both encoded and non-encode forms.
+# Use the JDBC_URL_OPTS env var to set the urloptions for the jdbc connection string
+# The db.jdbc.urloptions.encoded needs to be created in each ant target which uses it by calling the
+# urlencode scriptdef. We can still reference it below as it will be added at runtime.
 #
-db.jdbc.urloptions=foo=true&bar=false
-db.jdbc.urloptions.encoded=foo=true&amp;bar=false
+db.jdbc.urloptions=${env.JDBC_URL_OPTS}
 
 #
 # JDBC urls that CollectionSpace needs to talk to the "admin" database, Nuxeo databases, and the "cspace" database (i.e., the AuthN/AuthZ database)
index c335011fb77854718312a1dfc689eb83976d4784..3cd4c4f947060fda8dcfc2d106e03c72cb1dc788 100644 (file)
--- a/build.xml
+++ b/build.xml
                <os family="windows" />
        </condition>
 
+  <scriptdef name="urlencode" language="javascript">
+    <attribute name="property"/>
+    <![CDATA[
+                       var value = self.project.getProperty(attributes.get("property"));
+      var encoded = encodeURIComponent(value);
+      self.project.setProperty(attributes.get("property") + ".encoded", encoded)
+    ]]>
+  </scriptdef>
+
        <target name="init">
                <!-- Create the time stamp -->
                <tstamp />
        </target>
 
        <!--
-               This target sends the 'create_nuxeo_db' and 'create_nuxeo_db' targets to all the Ant sub-modules/directories
-               and creates some database utility functions
+               This target calls the 'create_nuxeo_db' and 'create_cspace_db' targets and creates some database utility functions
        -->
        <target name="-create_db" depends="-validate_create_db_unix, -validate_create_db_windows">
+               <urlencode property="db.jdbc.urloptions" />
                <antcall target="create_nuxeo_db" />
                <antcall target="create_cspace_db" />
                <antcall target="create_update_userid_db_function" />
        </target>
 
        <target name="import" description="import default configuration">
+               <urlencode property="db.jdbc.urloptions" />
                <ant antfile="services/build.xml" target="import" inheritAll="false" />
        </target>
 
index dcad21410c194b1844b9c981d59d4271d4626004..c03e19ce95f1a1d7c72156f83d89580c551fc601 100644 (file)
@@ -5,11 +5,12 @@
     </description>
        <!-- set global properties for this build -->
     <property name="services.trunk" value="../.."/>
+    <import file="${services.trunk}/build.xml" />
     <!-- enviornment should be declared before reading build.properties -->
     <property environment="env" />
     <property file="${services.trunk}/build.properties" />
-       <property name="application.trunk" location="${services.trunk}/../application" />
-       <property name="cspace.tool.csmake" value="csmake" />
+    <property name="application.trunk" location="${services.trunk}/../application" />
+    <property name="cspace.tool.csmake" value="csmake" />
     <property name="mvn.opts" value="-V" />
     <property name="src" location="src"/>
 
 
     <target name="package" depends="package-unix,package-windows"
   description="Package CollectionSpace Services" />
+    <urlencode property="db.jdbc.urloptions" />
     <target name="package-unix" if="osfamily-unix">
         <exec executable="mvn" failonerror="true">
             <arg value="package" />
             <arg value="-Dmaven.test.skip=true" />
+            <arg value="-Ddb.jdbc.urloptions.encoded=${db.jdbc.urloptions.encoded}" />
             <arg value="-f" />
             <arg value="${basedir}/pom.xml" />
             <arg value="-N" />
                <delete dir="${jee.deploy.cspace}/${cspace.services.context}"/>
         <copy file="${basedir}/target/${cspace.services.war}" todir="${jee.deploy.cspace}"/>
     </target>
-       
+
        <!--
                This target attempts to generate a set of Service artifacts (Nuxeo bundles and tenant bindings) by using the
                Application layer's configuration files.
-               
+
                This target has a dependency on the Application layer's source tree.  It assumes the Application layer's src tree root
                is a directory sibling of the Source layer's source tree root.  Also, it assumes the "csmake.jar" exists in the target
                directory of the Application layer's "tomcat-main" module.
-               
+
                This target also assumes that the system environment variable 'CSPACE_JEESERVER_HOME' is set and pointing to the root
                JEE server (usually Apache Tomcat) where CollectionSpace is installed.  All generated Service artifacts wi
        -->
index 875a72f9a7a4f694b80108067f28828ac2763481..c2db6ee442735d1d2bdde07362a913b7fdc91963 100644 (file)
         <class>org.collectionspace.services.account.Status</class>
         <properties>
             <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
-
-            <!--property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
-            <property name="hibernate.max_fetch_depth" value="3"/>
-            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
-            <property name="hibernate.connection.username" value="test"/>
-            <property name="hibernate.connection.password" value="test"/>
-            <property name="hibernate.connection.url" value="${db.jdbc.cspace.url.encoded}"/-->
         </properties>
     </persistence-unit>
 </persistence>