]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6964: Resolved issue where the Ant target 'create_db' would not first remove...
authorremillet <remillet@yahoo.com>
Fri, 24 Jun 2016 20:52:09 +0000 (13:52 -0700)
committerremillet <remillet@yahoo.com>
Fri, 24 Jun 2016 20:52:09 +0000 (13:52 -0700)
build.xml
services/account/pstore/build.xml
services/authorization/pstore/build.xml
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java
services/report/3rdparty/build.xml

index ecfffb7fc90c7503b2614fadef1ef9b7d85c7234..0a126777daf97b78b8d1222c47b3ae12c2ecc48c 100644 (file)
--- a/build.xml
+++ b/build.xml
        </target>
 
        <target name="setup_initdb.sql" description="copy init_db scripts, replacing keywords">
+               <copy todir="${jee.server.cspace}/cspace/services/db/postgresql">
+                       <fileset dir="${jee.server.cspace}/cspace/services/db/postgresql" includes="init_cspace_db.sql, init_nuxeo_db.sql">
+                               <present targetdir="${src}/main/resources/db/postgresql" />
+                       </fileset>
+                       <globmapper from="*" to="*.bak" />
+               </copy>
                <copy todir="${jee.server.cspace}/cspace/services/db">
                        <fileset dir="${src}/main/resources/db" />
                        <filterset>
        <target name="undeploy" description="undeploy services from ${jee.server.cspace}">
                <ant antfile="services/build.xml" target="undeploy" inheritAll="false" />
                <ant antfile="3rdparty/build.xml" target="undeploy" inheritAll="false" />
-               <delete failonerror="false" dir="${jee.server.cspace}/cspace/services" />
+
+               <delete failonerror="false" dir="${jee.server.cspace}/cspace/services/config" />
+               <delete failonerror="false" dir="${jee.server.cspace}/cspace/services/scripts" />
+               <delete failonerror="false" dir="${jee.server.cspace}/cspace/services/db/jdbc_drivers" />
                <delete failonerror="false" dir="${jee.server.cspace}/cspace/config/services" />
+
                <!-- Delete mysql-ds.xml to clean up pre-1.8 bundles -->
                <delete failonerror="false" file="${jee.deploy.cspace}/mysql-ds.xml" />
                <delete failonerror="false" file="${jee.deploy.cspace}/jee-ds.xml" />
index 04588bc42151994c3e143ce3346e38fd36fcd64f..cf8313e84e82f8dda0d2376574a7dc7af84c412f 100644 (file)
                 <pathelement path="${db.driver.jar}"/>
             </classpath>
         </sql>
-                                               <sql driver="${db.jdbc.driver.class}"
+               <sql driver="${db.jdbc.driver.class}"
              url="${db.jdbc.cspace.url}"
              userid="${db.cspace.user}"
              password="${db.cspace.user.password}"
             <classpath>
                 <pathelement path="${db.driver.jar}"/>
             </classpath>
-                                       </sql>
+               </sql>
     </target>
        
        <!-- We are copying only the scripts that are committed to the source tree.  We're *not* copying the ones that
index 807f256865491958f0294699e2f37a6805b2299e..80598bd40595f396d35b1c09d6b9773aeb90f9bb 100644 (file)
             depends="check.db.scripts.deploy.dir" if="${db.scripts.deploy.dir.exists}">
         <delete>
             <fileset dir="${db.scripts.deploy.dir}"
-                     includes="**authorization**.sql"/>
+                     includes="**auth**.sql, acl.sql"/>
         </delete>
     </target>
 
index ed70792398abc9bbadf55483f7e0ef93feb0ccee..6100e1cee21a55e67f32db6c4e22c282d4497a5e 100644 (file)
@@ -1163,79 +1163,91 @@ public class ServiceMain {
      * 
      * @param dbInitializationScriptFilePath
      * @param dbsCheckedOrCreated 
+     * @throws Exception 
      */
-    private void updateInitializationScript(String dbInitializationScriptFilePath,
-            HashSet<String> dbsCheckedOrCreated, String[] dataSourceNames) {
-        // Get the current copy of the Nuxeo databases initialization script file,
-        // if that file exists, and read all of its lines except for those which
-        // drop databases.
-        List<String> lines = null;
-        // "If the given string" for the pathname provided here "is the empty string, then the
-        // result is the empty abstract pathname," according to Oracle's Javadoc for File.
-        // An empty path string might be provided here if a call to get the database product name failed earlier.
-        File nuxeoDatabasesInitScriptFile = new File(dbInitializationScriptFilePath);
-        try {
-            if (! nuxeoDatabasesInitScriptFile.canRead()) {
-                String msg = String.format("Could not find and/or read the Nuxeo databases initialization script file '%s'",
-                        nuxeoDatabasesInitScriptFile.getCanonicalPath());
-                logger.warn(msg);
-            } else {
-                // Note: Exceptions are written only to the console, not thrown, by
-                // the readFileAsLines() method in the common-api package.
-                lines = FileTools.readFileAsLines(dbInitializationScriptFilePath);
-                Iterator<String> linesIterator = lines.iterator();
-                String currentLine;
-                while (linesIterator.hasNext()) {
-                    currentLine = linesIterator.next();
-                    // Elide all existing DROP DATABASE statements.
-                    if (currentLine.toLowerCase().contains(DROP_DATABASE_SQL_CMD.toLowerCase())) {
-                        linesIterator.remove();
-                    }
-                    // Elide a comment pertaining to the existing
-                    // DROP DATABASE statements.
-                    if (currentLine.toLowerCase().contains(DROP_OBJECTS_SQL_COMMENT.toLowerCase())) {
-                        linesIterator.remove();
-                    }
-                    // Elide all existing DROP USER statements.
-                    if (currentLine.toLowerCase().contains(DROP_USER_SQL_CMD.toLowerCase())) {
-                        linesIterator.remove();
-                    }
-                }
-            }
-            List<String> replacementLines = new ArrayList<String>();
-            // Add back the comment elided above
-            replacementLines.add(DROP_OBJECTS_SQL_COMMENT);
-            // Add new DROP DATABASE lines for every Nuxeo-managed database.
-            for (String dbName : dbsCheckedOrCreated) {
-              if (Tools.notBlank(dbName)) {
-                  replacementLines.add(String.format(DROP_DATABASE_IF_EXISTS_SQL_CMD, dbName));
-              }
-            }
-            // Add new DROP USER commands for every provided datasource.
-            String username;
-            for (String dataSourceName : dataSourceNames) {
-                username = getBasicDataSourceUsername(dataSourceName);
-                if (Tools.notBlank(username)) {
-                    replacementLines.add(String.format(DROP_USER_IF_EXISTS_SQL_CMD, username));
-                }
-            }
-            // Now append all existing lines from that file, except for
-            // any lines that were elided above.
-            if (lines != null && ! lines.isEmpty()) {
-                replacementLines.addAll(lines);
-            }
-            if (! nuxeoDatabasesInitScriptFile.canWrite()) {
-                String msg = String.format("Could not find and/or write the Nuxeo databases initialization script file '%s'",
-                        nuxeoDatabasesInitScriptFile.getCanonicalPath());
-                logger.warn(msg);
-            } else {
-                // Note: Exceptions are written only to the console, not thrown, by
-                // the writeFileFromLines() method in the common-api package.
-                FileTools.writeFileFromLines(dbInitializationScriptFilePath, replacementLines);
-            }
-        } catch (Exception e) {
+    private void updateInitializationScript(String dbInitializationScriptFilePath, HashSet<String> dbsCheckedOrCreated,
+                       String[] dataSourceNames) throws Exception {
+       //
+       // Get the current copy of the Nuxeo databases initialization script
+               // file and read all of its lines except for those which DROP databases.
+               //
+       File nuxeoDatabasesInitScriptFile = new File(dbInitializationScriptFilePath);
+               List<String> lines = null;
+               try {
+                       if (!nuxeoDatabasesInitScriptFile.canRead()) {
+                               String msg = String.format("Could not find and/or read the Nuxeo databases initialization script file '%s'",
+                                               nuxeoDatabasesInitScriptFile.getCanonicalPath());
+                               logger.warn(msg);
+                       } else {
+                               //
+                               // Make a backup of the existing file
+                               String destFileName = String.format("%s.%s.bak", dbInitializationScriptFilePath, System.currentTimeMillis());
+                               if (FileTools.copyFile(dbInitializationScriptFilePath, destFileName, false) == false) {
+                                       throw new Exception("Could not backup existing database initialization script.");
+                               }
 
-        }
+                               //
+                               // Process the existing lines
+                               lines = FileTools.readFileAsLines(dbInitializationScriptFilePath);
+                               Iterator<String> linesIterator = lines.iterator();
+                               String currentLine;
+                               while (linesIterator.hasNext()) {
+                                       currentLine = linesIterator.next();
+                                       // Elide all existing DROP DATABASE statements.
+                                       if (currentLine.toLowerCase().contains(DROP_DATABASE_SQL_CMD.toLowerCase())) {
+                                               linesIterator.remove();
+                                       }
+                                       // Elide a comment pertaining to the existing
+                                       // DROP DATABASE statements.
+                                       if (currentLine.toLowerCase().contains(DROP_OBJECTS_SQL_COMMENT.toLowerCase())) {
+                                               linesIterator.remove();
+                                       }
+                                       // Elide all existing DROP USER statements.
+                                       if (currentLine.toLowerCase().contains(DROP_USER_SQL_CMD.toLowerCase())) {
+                                               linesIterator.remove();
+                                       }
+                               }
+                       }
+                       
+                       // Add back the comment elided above
+                       List<String> replacementLines = new ArrayList<String>();
+                       replacementLines.add(DROP_OBJECTS_SQL_COMMENT);
+                       // Add new DROP DATABASE lines for every Nuxeo-managed database.
+                       for (String dbName : dbsCheckedOrCreated) {
+                               if (Tools.notBlank(dbName)) {
+                                       replacementLines.add(String.format(DROP_DATABASE_IF_EXISTS_SQL_CMD, dbName));
+                               }
+                       }
+                       
+                       // Add new DROP USER commands for every provided datasource.
+                       String username;
+                       for (String dataSourceName : dataSourceNames) {
+                               username = getBasicDataSourceUsername(dataSourceName);
+                               if (Tools.notBlank(username)) {
+                                       replacementLines.add(String.format(DROP_USER_IF_EXISTS_SQL_CMD, username));
+                               }
+                       }
+                       
+                       // Now append all existing lines from that file, except for
+                       // any lines that were elided above.
+                       if (lines != null && !lines.isEmpty()) {
+                               replacementLines.addAll(lines);
+                       }
+                       
+                       if (!nuxeoDatabasesInitScriptFile.canWrite()) {
+                               String msg = String.format(
+                                               "Could not find and/or write the Nuxeo databases initialization script file '%s'",
+                                               nuxeoDatabasesInitScriptFile.getCanonicalPath());
+                               logger.warn(msg);
+                       } else {
+                               // Note: Exceptions are written only to the console, not thrown, by
+                               // the writeFileFromLines() method in the common-api package.
+                               FileTools.writeFileFromLines(dbInitializationScriptFilePath, replacementLines);
+                       }
+               } catch (Exception e) {
+                       logger.error("Could not update database initialization script.", e);
+                       throw e;
+               }
 
-    }
+       }
 }
index 51fe14bfbf1c8dc341747a117e260ae27385f218..b3aa25830efc578eb49f990b2a91d2b9c9cc5961 100644 (file)
       description="Undeploy report files">
     </target>
     
+       <!-- Removes only the source reports that originated from the source directory.  Ones added
+               manually remain.
+       -->
     <target name="undeploy_source_report_files"
       description="Undeploy source (.jrxml) report files">
       <delete failonerror="false">
-        <fileset dir="${jee.server.cspace}/cspace/reports" includes="*.jrxml"/>
+        <fileset dir="${jee.server.cspace}/cspace/reports" includes="*.jrxml">
+                       <present targetdir="${basedir}/jasper-cs-report/src/main/resources" />
+               </fileset>
       </delete>
     </target>
     
       -->
     </target>
 
-    <target name="undeploy" depends="undeploy_compiled_report_files"
+    <target name="undeploy" depends="undeploy_report_files"
       description="Undeploy report-related artifacts">
         <ant antfile="nuxeo-platform-cs-report/build.xml" target="undeploy" inheritall="false"/>
     </target>