]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6168: Refactoring hard-coded cspace and nuxeo database names to be configurable.
authorRichard Millet <remillet@berkeley.edu>
Thu, 6 Mar 2014 15:52:30 +0000 (07:52 -0800)
committerRichard Millet <remillet@berkeley.edu>
Thu, 6 Mar 2014 15:52:30 +0000 (07:52 -0800)
51 files changed:
3rdparty/nuxeo/build.xml
3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/default-repo-config.xml
3rdparty/nuxeo/nuxeo-server/5.5-HF07/config/lifesci_domain-repo-config.xml
build.properties
build.xml
installer/build.xml
services/JaxRsServiceProvider/src/main/resources/META-INF/persistence.xml
services/JaxRsServiceProvider/src/main/webapp/META-INF/context.xml
services/account/client/build.xml
services/account/client/src/test/resources/hibernate.cfg.xml
services/account/pstore/build.xml
services/account/pstore/src/main/resources/db/mysql/account.sql [deleted file]
services/account/pstore/src/main/resources/db/mysql/account_index.sql [deleted file]
services/account/pstore/src/main/resources/db/mysql/test_account.sql [deleted file]
services/account/pstore/src/test/resources/hibernate.cfg.xml
services/authentication/client/build.xml
services/authentication/client/src/test/resources/hibernate.cfg.xml
services/authentication/jaxb/src/test/resources/hibernate.cfg.xml
services/authentication/pstore/build.xml
services/authentication/pstore/src/main/resources/db/mysql/authentication.sql [deleted file]
services/authentication/pstore/src/main/resources/db/mysql/authentication_index.sql [deleted file]
services/authentication/pstore/src/main/resources/db/mysql/test_authentication.sql [deleted file]
services/authentication/pstore/src/test/resources/hibernate.cfg.xml
services/authorization-mgt/import/build.xml
services/authorization-mgt/import/src/main/resources/META-INF/persistence.xml
services/authorization-mgt/import/src/main/resources/applicationContext-authorization-test.xml
services/authorization-mgt/import/src/main/resources/hibernate.cfg.xml
services/authorization/pstore/build.xml
services/authorization/pstore/src/main/resources/db/mysql/acl.sql [deleted file]
services/authorization/pstore/src/main/resources/db/mysql/authorization.sql [deleted file]
services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql [deleted file]
services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql [deleted file]
services/authorization/pstore/src/test/resources/hibernate.cfg.xml
services/authorization/service/src/main/resources/applicationContext-authorization.xml
services/collectionobject/service/pom.xml
services/common/build.xml
services/common/src/main/cspace/config/services/resources/db/mysql/.gitignore [deleted file]
services/common/src/main/cspace/config/services/service-config.xml
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java
services/common/src/main/java/org/collectionspace/services/common/authorization_mgt/AuthorizationCommon.java
services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java
services/common/src/main/resources/db/mysql/create_id_generators_table.sql [deleted file]
services/common/src/main/resources/db/mysql/load_id_generators.sql [deleted file]
services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java
services/config/src/main/resources/service-config.xsd
services/security/client/build.xml
services/security/client/src/test/resources/hibernate.cfg.xml
src/main/resources/db/mysql/init_cspace_db.sql [deleted file]
src/main/resources/db/mysql/init_nuxeo_db.sql [deleted file]
src/main/resources/db/postgresql/init_cspace_db.sql
src/main/resources/db/postgresql/init_nuxeo_db.sql

index 9cbec3722d3706a3e875c816035e09158fa1d482..d96505b2066f2a9ebf53cceebd38bc894c44c6e0 100644 (file)
             <fileset dir="${basedir}/nuxeo-server/${nuxeo.release}/config"/>\r
             <filterset>\r
                 <filter token="DB" value="${db}" />\r
-                               <filter token="DB_URL" value="jdbc:${db}://${db.host}:${db.port}/nuxeo"/>\r
+                               <filter token="DB_NUXEO_NAME" value="${db.nuxeo.name}" />\r
+                               <filter token="DB_URL" value="jdbc:${db}://${db.host}:${db.port}/${db.nuxeo.name}"/>\r
                <filter token="DB_SERVER_HOSTNAME" value="${db.host}"/>\r
                                <filter token="XA_DATASOURCE" value="${db.xaDataSource}" />\r
                 <filter token="NUXEO_USER" value="${db.nuxeo.user}" />\r
index 58f420c599c4c6ce62f8c9dca9a944f44e9adc92..dcf0b8f11f54ed60e9cb660549ff16741348ab7c 100644 (file)
@@ -13,7 +13,7 @@
                                <xa-datasource>@XA_DATASOURCE@</xa-datasource>                          
                                <property name="URL">@DB_URL@</property>
                                <property name="ServerName">@DB_SERVER_HOSTNAME@</property>                             
-                               <property name="DatabaseName">nuxeo</property>
+                               <property name="DatabaseName">@DB_NUXEO_NAME@</property>
                                <property name="User">@NUXEO_USER@</property>
                                <property name="Password">@NUXEO_PW@</property>
 
index 1e09a526f99d2aef142ae4295928d3ff0efd3fd6..592f48478665825c72beb84157bc6dc2ee66036c 100644 (file)
        <extension target="org.nuxeo.ecm.core.api.repository.RepositoryManager"
                point="repositories">
                <documentation>The lifesci_domain repository</documentation>
-               <repository name="lifesci_domain" label="Default Repository" />
+               <repository name="lifesci_domain" label="lifesci_domain Repository" />
        </extension>
 </component>
index 40c368b3106f0453ff73c5ab9c1eb8c0236221dd..ca2e57d5b185fe4b47bcb7ecc4c34820fa75c333 100644 (file)
@@ -1,6 +1,6 @@
 host=127.0.0.1\r
 #cspace\r
-cspace.instance.id=T1650\r
+cspace.instance.id=_trs80\r
 release.version=4.1\r
 cspace.release=${release.version}-SNAPSHOT\r
 cspace.services.release=cspace-services-${cspace.release}\r
@@ -115,17 +115,27 @@ hibernate.dialect=${db.dialect}
 \r
 #database common settings\r
 db.script.dir=${jee.server.cspace}/cspace/services/db/${db}\r
-db.user=${env.DB_USER}\r
-db.user.password=${env.DB_PASSWORD}\r
-db.nuxeo.user=nuxeo\r
-db.nuxeo.user.password=${env.DB_PASSWORD_NUXEO}\r
-db.cspace.user=cspace\r
-db.cspace.user.password=${env.DB_PASSWORD_CSPACE}\r
+\r
+db.csadmin.name=postgres\r
+db.csadmin.user=csadmin\r
+db.csadmin.user.password=${env.DB_CSADMIN_PASSWORD}\r
+\r
+db.nuxeo.name=nuxeo${cspace.instance.id}\r
+db.nuxeo.user=${db.nuxeo.name}\r
+db.nuxeo.user.password=${env.DB_NUXEO_PASSWORD}\r
+\r
+db.cspace.name=cspace${cspace.instance.id}\r
+db.cspace.user=${db.cspace.name}\r
+db.cspace.user.password=${env.DB_CSPACE_PASSWORD}\r
+\r
+db.reader.user=reader${cspace.instance.id}\r
+db.reader.user.password=${env.DB_READER_PASSWORD}\r
+\r
 db.host=localhost\r
 db.jdbc.baseurl=jdbc:${db}://${db.host}:${db.port}\r
 \r
 #\r
 # JDBC URL's.  The csadmin URL is needed to authenticate with the PostGreSQL server because an existing database must be supplied during authentication.\r
 #\r
-db.jdbc.csadmin.url=${db.jdbc.baseurl}/postgres\r
-db.jdbc.cspace.url=${db.jdbc.baseurl}/cspace\r
+db.jdbc.csadmin.url=${db.jdbc.baseurl}/${db.csadmin.name}\r
+db.jdbc.cspace.url=${db.jdbc.baseurl}/${db.cspace.name}\r
index 915ed94c9773df733b2c2ef62455f14e30e0a744..6408aab2a37ec7566443f97d02b1a697808ead14 100644 (file)
--- a/build.xml
+++ b/build.xml
             description="create nuxeo database">\r
                <sql driver="${db.jdbc.driver.class}"\r
              url="${db.jdbc.csadmin.url}"\r
-             userid="${db.user}"\r
-             password="${db.user.password}"\r
+             userid="${db.csadmin.user}"\r
+             password="${db.csadmin.user.password}"\r
                                                 autocommit="true"\r
              src="${db.script.dir}/init_nuxeo_db.sql"\r
              >\r
                description="create cspace database">\r
                <sql driver="${db.jdbc.driver.class}"\r
              url="${db.jdbc.csadmin.url}"\r
-             userid="${db.user}"\r
-             password="${db.user.password}"\r
+             userid="${db.csadmin.user}"\r
+             password="${db.csadmin.user.password}"\r
                                                 autocommit="true"\r
              src="${db.script.dir}/init_cspace_db.sql"\r
              >\r
        <target name="checkvars">\r
                <fail unless="env.CSPACE_JEESERVER_HOME" \r
                                                        message="Required environment variable CSPACE_JEESERVER_HOME has not been set."/>\r
-               <fail unless="env.DB_PASSWORD_CSPACE" \r
-                                                       message="Required environment variable DB_PASSWORD_CSPACE has not been set."/>\r
-               <fail unless="env.DB_PASSWORD_NUXEO" \r
-                                                       message="Required environment variable DB_PASSWORD_NUXEO has not been set."/>\r
-               <fail unless="env.DB_PASSWORD" \r
-                                                       message="Required environment variable DB_PASSWORD has not been set."/>\r
+               <fail unless="env.DB_CSPACE_PASSWORD" \r
+                                                       message="Required environment variable DB_CSPACE_PASSWORD has not been set."/>\r
+               <fail unless="env.DB_NUXEO_PASSWORD" \r
+                                                       message="Required environment variable DB_NUXEO_PASSWORD has not been set."/>\r
+               <fail unless="env.DB_READER_PASSWORD"\r
+                                                       message="Required environment variable DB_READER_PASSWORD has not been set."/>\r
+               <fail unless="env.DB_CSADMIN_PASSWORD" \r
+                                                       message="Required environment variable DB_CSADMIN_PASSWORD has not been set."/>\r
        </target>\r
 \r
        <target name="setup_initdb.sql" description="copy init_db scripts, replacing keywords">\r
                <copy todir="${jee.server.cspace}/cspace/services/db">\r
                        <fileset dir="${src}/main/resources/db"/>\r
                        <filterset>\r
-                               <!-- Note: double-subs from ${db.xyz.password} fail -->\r
+                               <filter token="DB_CSADMIN_NAME" value="${db.csadmin.name}" />\r
+                               <filter token="DB_CSADMIN_USER" value="${db.csadmin.user}" />\r
+                               <filter token="DB_CSADMIN_PASSWORD" value="${env.DB_CSADMIN_PASSWORD}" /> <!-- Note: double-subs from ${db.xyz.password} fail -->\r
+\r
+                               <filter token="DB_CSPACE_NAME" value="${db.cspace.name}" />\r
                                <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+                               <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- Note: double-subs from ${db.xyz.password} fail -->\r
+                               \r
+                               <filter token="DB_NUXEO_NAME" value="${db.nuxeo.name}" />\r
                                <filter token="DB_NUXEO_USER" value="${db.nuxeo.user}" />\r
-                               <filter token="DB_CSPACE_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" />\r
-                               <filter token="DB_NUXEO_PASSWORD" value="${env.DB_PASSWORD_NUXEO}" />\r
-                       </filterset>\r
+                               <filter token="DB_NUXEO_PASSWORD" value="${env.DB_NUXEO_PASSWORD}" /> <!-- Note: double-subs from ${db.xyz.password} fail -->\r
+\r
+                               <filter token="DB_READER_USER" value="${db.reader.user}" />\r
+                               <filter token="DB_READER_PASSWORD" value="${env.DB_READER_PASSWORD}" /> <!-- Note: double-subs from ${db.xyz.password} fail -->\r
+       </filterset>\r
                </copy>\r
        </target>\r
 \r
index b04c1c49d14c421c60b1c94c50bd33a84cf8de40..87efe6251c64b1d7d0897799c8cf0386c27f9caa 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="trunk-install" default="package" basedir=".">\r
     <description>\r
         collectionspace services\r
@@ -61,8 +60,8 @@
                                                        description="create nuxeo database">\r
                        <sql driver="${db.jdbc.driver.class}"\r
                                                         url="${db.jdbc.baseurl}"\r
-                                                        userid="${db.user}"\r
-                                                        password="${db.user.password}"\r
+                                                        userid="${db.csadmin.user}"\r
+                                                        password="${db.csadmin.user.password}"\r
                                                         autocommit="true"\r
                                                         src="${db.script.dir}/init_nuxeo_db.sql"\r
                                                         >\r
@@ -77,8 +76,8 @@
                        description="create cspace database">\r
                        <sql driver="${db.jdbc.driver.class}"\r
                                                         url="${db.jdbc.baseurl}"\r
-                                                        userid="${db.user}"\r
-                                                        password="${db.user.password}"\r
+                                                        userid="${db.csadmin.user}"\r
+                                                        password="${db.csadmin.user.password}"\r
                                                         autocommit="true"\r
                                                         src="${db.script.dir}/init_cspace_db.sql"\r
                                                         >\r
index f536675702f63b3c7b55e7ffb9a977afcd88c03a..4edec1614e318c7c5f33d259ea8662d550f9cbd7 100644 (file)
@@ -22,9 +22,9 @@
             <property name="hibernate.max_fetch_depth" value="3"/>\r
                        <!-- Until our JNDI issue with Nuxeo is resolved, we have to use these JDBC properties rather than a datasource -->\r
                        <property name="hibernate.connection.driver_class" value="${db.jdbc.driver.class}"/>\r
-                       <property name="hibernate.connection.username" value="${db.user}"/>\r
-                       <property name="hibernate.connection.password" value="${db.user.password}"/>\r
-                       <property name="hibernate.connection.url" value="jdbc:${db}://${db.host}:${db.port}/cspace"/>\r
+                       <property name="hibernate.connection.username" value="${db.cspace.user}"/>\r
+                       <property name="hibernate.connection.password" value="${db.cspace.user.password}"/>\r
+                       <property name="hibernate.connection.url" value="jdbc:${db}://${db.host}:${db.port}/${db.cspace.name}"/>\r
             <!--property name="hibernate.hbm2ddl.auto" value="create-drop"/-->\r
         </properties>\r
 \r
index 1755aaf484acaead4473607e5a171466a052786d..60608988be21e4554d3eab90190b254fb46836ab 100644 (file)
@@ -66,8 +66,8 @@
        <Resource name="jdbc/CspaceDS"
                auth="Container"
                type="javax.sql.DataSource"
-               username="${db.user}"
-               password="${db.user.password}"
+               username="${db.cspace.user}"
+               password="${db.cspace.user.password}"
                driverClassName="${db.jdbc.driver.class}"
                url="${db.jdbc.cspace.url}"
                maxActive="8"
                validationQuery="SELECT 1"
                logAbandoned="true"/>
 
-       <Resource name="jdbc/NuxeoMgrDS"
+       <Resource name="jdbc/CsadminDS"
                auth="Container"
                type="javax.sql.DataSource"
-               username="${db.user}"
-               password="${db.user.password}"
+               username="${db.csadmin.user}"
+               password="${db.csadmin.user.password}"
                driverClassName="${db.jdbc.driver.class}"
                url="${db.jdbc.csadmin.url}"
                maxActive="8"
   <Resource name="jdbc/NuxeoReaderDS"
                auth="Container"
                type="javax.sql.DataSource"
-               username="reader"
-               password="read"
+               username="${db.reader.user}"
+               password="${db.reader.user.password}"
                driverClassName="${db.jdbc.driver.class}"
                url="jdbc:${db}://${db.host}:${db.port}/${DatabaseName}"
                maxActive="8"
index a4a727db18c9a7e14ff6bd856a357c16990489bd..83b2f3df9979769985f89cb16c242b2238141b21 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="account.client" default="package" basedir=".">\r
     <description>\r
         collectionspace account service\r
@@ -23,7 +22,6 @@
         <tstamp/>\r
     </target>\r
 \r
-\r
     <target name="package" depends="package-unix,package-windows"\r
             description="Package CollectionSpace Services" />\r
     <target name="package-unix" if="osfamily-unix">\r
         </exec>\r
     </target>\r
 \r
-\r
     <target name="setup_hibernate.cfg" description="replace property keywords in hibernate.cfg.xml">\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index 869f3107a99080c716f0a848257cf7ca071230a3..01288538f25c38fb7b078c0c3f1ad2bcd0991d89 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="account.pstore" default="package" basedir=".">\r
     <description>\r
         collectionspace account service\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" />\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
                 <pathelement path="${db.driver.jar}"/>\r
             </classpath>\r
                                        </sql>\r
-                               <!-- No longer used.\r
-        <sql driver="com.mysql.jdbc.Driver"\r
-             url="jdbc:mysql://${db.host}:${db.port}/cspace"\r
-             userid="${db.user}"\r
-             password="${db.user.password}"\r
-             src="${db.script.dir}/test_account.sql"\r
-             >\r
-            <classpath>\r
-                <pathelement path="${db.driver.jar}"/>\r
-            </classpath>\r
-                                       </sql> -->\r
     </target>\r
        \r
        <!-- We are copying only the scripts that are committed to the source tree.  We're *not* copying the ones that\r
diff --git a/services/account/pstore/src/main/resources/db/mysql/account.sql b/services/account/pstore/src/main/resources/db/mysql/account.sql
deleted file mode 100644 (file)
index b66c094..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-alter table accounts_tenants drop foreign key FKFDA649B05A9CEEB5;
-drop table if exists accounts_common;
-drop table if exists accounts_tenants;
-drop table if exists tenants;
-create table accounts_common (csid varchar(128) not null, created_at datetime not null, email varchar(255) not null, metadata_protection varchar(255), mobile varchar(255), person_ref_name varchar(255), phone varchar(255), roles_protection varchar(255), screen_name varchar(128) not null, status varchar(15) not null, updated_at datetime, userid varchar(128) not null, primary key (csid));
-create table accounts_tenants (HJID bigint not null auto_increment, tenant_id varchar(128) not null, TENANTS_ACCOUNTSCOMMON_CSID varchar(128), primary key (HJID));
-create table tenants (id varchar(128) not null, created_at datetime not null, name varchar(255) not null, disabled tinyint(1) not null, updated_at datetime, primary key (id));
-alter table accounts_tenants add index FKFDA649B05A9CEEB5 (TENANTS_ACCOUNTSCOMMON_CSID), add constraint FKFDA649B05A9CEEB5 foreign key (TENANTS_ACCOUNTSCOMMON_CSID) references accounts_common (csid);
diff --git a/services/account/pstore/src/main/resources/db/mysql/account_index.sql b/services/account/pstore/src/main/resources/db/mysql/account_index.sql
deleted file mode 100644 (file)
index 0eace4e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
---
--- Copyright 20010 University of California at Berkeley
--- Licensed under the Educational Community License (ECL), Version 2.0.
--- You may not use this file except in compliance with this License.
---
--- use cspace;
-CREATE INDEX index_userid ON accounts_common (userid);
-CREATE INDEX index_screen_name ON accounts_common (screen_name);
-CREATE INDEX index_email ON accounts_common (email);
-CREATE INDEX index_person_ref_name ON accounts_common (person_ref_name);
-CREATE INDEX index_update_at ON accounts_common (updated_at);
-CREATE INDEX index_status ON accounts_common (status);
diff --git a/services/account/pstore/src/main/resources/db/mysql/test_account.sql b/services/account/pstore/src/main/resources/db/mysql/test_account.sql
deleted file mode 100644 (file)
index 5d80213..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
---
--- Copyright 2009 University of California at Berkeley
--- Licensed under the Educational Community License (ECL), Version 2.0.
--- You may not use this file except in compliance with this License.
---
-use cspace;
-
--- Tenants
--- default cspace --
--- ONLY Needed for the hack below.
--- INSERT INTO `cspace`.`tenants` (`id`, `name`, `created_at`) VALUES  ('1','collectionspace.org', now());
-
--- Accounts
--- default bootstrap user required to run ImportAuthZ (to bootstrap Spring) --
--- INSERT INTO `cspace`.`accounts_common` (`csid`, `email`, `phone`, `mobile`, `userid`, `status`, `screen_name`, `created_at`) VALUES  ('Bootstrapping-Account-DO-NOT-DELETE','bootstrap@collectionspace.org',NULL,NULL,'SPRING_ADMIN','ACTIVE','SPRING_ADMIN', now());
-
--- Association of accounts with tenants
--- INSERT INTO `cspace`.`accounts_tenants` (`TENANTS_ACCOUNTSCOMMON_CSID`, `tenant_id`) VALUES ('Bootstrapping-Account-DO-NOT-DELETE', '1');
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index 49747bc931d208aecbedf259c71450f884888a9a..557933f52e2d9fd215615810f883a9158d8dcabc 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="authentication.client" default="package" basedir=".">\r
     <description>\r
         collectionspace authentication service\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index 422b7a607b33f09c224247084bb73e40777a6d2d..d416bb08af358a7200e38a66f040d2e807d2b03e 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index 96ffb6a8174d8e37dfd7018c5a06c16f7e1d0918..13a5ff5f571108b70d8bbdff3030391b621eeced 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="authentication.pstore" default="package" basedir=".">\r
     <description>\r
         collectionspace authentication service\r
@@ -23,7 +22,6 @@
         <tstamp/>\r
     </target>\r
 \r
-\r
     <target name="package" depends="package-unix,package-windows"\r
             description="Package CollectionSpace Services" />\r
     <target name="package-unix" if="osfamily-unix">\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
diff --git a/services/authentication/pstore/src/main/resources/db/mysql/authentication.sql b/services/authentication/pstore/src/main/resources/db/mysql/authentication.sql
deleted file mode 100644 (file)
index 558f1f3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-drop table if exists users;
-create table users (username varchar(128) not null, created_at datetime not null, passwd varchar(128) not null, updated_at datetime, primary key (username));
diff --git a/services/authentication/pstore/src/main/resources/db/mysql/authentication_index.sql b/services/authentication/pstore/src/main/resources/db/mysql/authentication_index.sql
deleted file mode 100644 (file)
index be70890..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
---
--- Copyright 20010 University of California at Berkeley
--- Licensed under the Educational Community License (ECL), Version 2.0.
--- You may not use this file except in compliance with this License.
---
-use cspace;
-
-
diff --git a/services/authentication/pstore/src/main/resources/db/mysql/test_authentication.sql b/services/authentication/pstore/src/main/resources/db/mysql/test_authentication.sql
deleted file mode 100644 (file)
index 8814ef3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
---\r
--- Copyright 2009 University of California at Berkeley\r
--- Licensed under the Educational Community License (ECL), Version 2.0.\r
--- You may not use this file except in compliance with this License.\r
---\r
-use cspace;\r
-\r
--- default bootstrap user required to run ImportAuthZ (to bootstrap Spring) --\r
--- insert into `users` (`username`,`passwd`, `created_at`) VALUES ('SPRING_ADMIN','MzwE3RUaKmgxwDnLmmUd8pGYvooE4WzoYdS2o0oRyVQ=', now());\r
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index d342d8ec36171621798fc39e2d3a81274fb1c0c3..3acf32ec0ae4860dd2df04f5c23150b5fb67c034 100644 (file)
@@ -22,7 +22,6 @@
         <tstamp/>\r
     </target>\r
 \r
-\r
     <target name="package" depends="package-unix,package-windows"\r
             description="Package CollectionSpace Services" />\r
     <target name="package-unix" if="osfamily-unix">\r
         </exec>\r
     </target>\r
 \r
-\r
     <target name="setup_hibernate.cfg" description="replace property keywords in hibernate.cfg.xml" depends="install">\r
         <property name="src.hibernate.cfg" value="${basedir}/src/main/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/classes/hibernate.cfg.xml"/>\r
         <property name="dest.appContext.cfg" value="${basedir}/target/classes/applicationContext-authorization-test.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
         <delete file="${dest.appContext.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.j2ee.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <filter token="CLASS_ID_QUERY" value="${db.spring.acl.classIdentityQuery}" />\r
         <filter token="SID_ID_QUERY" value="${db.spring.acl.sidIdentityQuery}" />\r
index 52fe747e8647b69fe4eafed0b4873db127cb1b4e..b694ab8554b9b700919adde8a87ab1274cf91162 100644 (file)
@@ -9,13 +9,6 @@
         <class>org.collectionspace.services.authorization.AccountRoleRel</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="jdbc:mysql://${db.host}:3306/cspace"/-->
         </properties>
     </persistence-unit>
 </persistence>
index 50b63fc88172acb1fb957e029172087e78a6f31b..dad3b3b0f64d0ee1c2d7a336b416d869614102fe 100644 (file)
@@ -37,9 +37,9 @@
 
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
         <property name="driverClassName" value="@DB_DRIVER_CLASS@"/>
-        <property name="url" value="@DB_URL@"/>
-        <property name="username" value="@DB_USER@"/>
-        <property name="password" value="@DB_PASSWORD@"/>
+        <property name="url" value="@DB_CSPACE_URL@"/>
+        <property name="username" value="@DB_CSPACE_USER@"/>
+        <property name="password" value="@DB_CSPACE_PASSWORD@"/>
     </bean>
 
     <bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
@@ -80,7 +80,6 @@
         </constructor-arg>
     </bean>
 
-
     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="dataSource"/>
     </bean>
@@ -91,6 +90,6 @@
         <property name="providerAclService" ref="aclService"/>
         <property name="providerPermissionEvaluator" ref="permissionEvaluator"/>
         <property name="txManager" ref="transactionManager"/>
-                         <property name="providerAclCache" ref="aclCache"/>
+               <property name="providerAclCache" ref="aclCache"/>
      </bean>
 </beans>
index cb1f64509f1e398b8354f472408686908ccd8365..0d9143787c435cfacac6b6f09a178bab993eeeab 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index e9f47d52a4948febd24f05917bde8a34c86fe31b..7be651fc91b8d95ad0b347baee7800865cb0e9af 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="authorization.pstore" default="package" basedir=".">\r
     <description>\r
         collectionspace authorization service\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/acl.sql b/services/authorization/pstore/src/main/resources/db/mysql/acl.sql
deleted file mode 100644 (file)
index c84810e..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
---
--- Copyright 2010 University of California at Berkeley
--- Licensed under the Educational Community License (ECL), Version 2.0.
--- You may not use this file except in compliance with this License.
---
-
--- use cspace;
-drop table if exists `acl_entry`;
-drop table if exists `acl_object_identity`;
-drop table if exists `acl_sid`;
-drop table if exists `acl_class`;
-
---
--- Table structure for table `acl_class`
---
-
-CREATE TABLE `acl_class` (
-  `id` bigint(20) NOT NULL auto_increment,
-  `class` varchar(100) NOT NULL,
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `unique_uk_2` (`class`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-
---
--- Dumping data for table `acl_class`
---
-
-
---
--- Table structure for table `acl_sid`
---
-
-CREATE TABLE `acl_sid` (
-  `id` bigint(20) NOT NULL auto_increment,
-  `principal` tinyint(1) NOT NULL,
-  `sid` varchar(100) NOT NULL,
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `unique_uk_1` (`principal`,`sid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Dumping data for table `acl_sid`
---
-
---
--- Table structure for table `acl_entry`
---
-
-CREATE TABLE `acl_entry` (
-  `id` bigint(20) NOT NULL auto_increment,
-  `acl_object_identity` bigint(20) NOT NULL,
-  `ace_order` int(11) NOT NULL,
-  `sid` bigint(20) NOT NULL,
-  `mask` int(11) NOT NULL,
-  `granting` tinyint(1) NOT NULL,
-  `audit_success` tinyint(1) NOT NULL,
-  `audit_failure` tinyint(1) NOT NULL,
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `unique_uk_4` (`acl_object_identity`,`ace_order`),
-  KEY `sid` (`sid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-
-
-
---
--- Dumping data for table `acl_entry`
---
-
-
---
--- Table structure for table `acl_object_identity`
---
-
-CREATE TABLE `acl_object_identity` (
-  `id` bigint(20) NOT NULL auto_increment,
-  `object_id_class` bigint(20) NOT NULL,
-  `object_id_identity` bigint(20) NOT NULL,
-  `parent_object` bigint(20) default NULL,
-  `owner_sid` bigint(20) default NULL,
-  `entries_inheriting` tinyint(1) NOT NULL,
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `unique_uk_3` (`object_id_class`,`object_id_identity`),
-  KEY `owner_sid` (`owner_sid`),
-  KEY `parent_object` (`parent_object`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-
-
---
--- Dumping data for table `acl_object_identity`
---
-
---
--- Constraints for table `acl_entry`
---
-ALTER TABLE `acl_entry`
-  ADD CONSTRAINT `acl_entry_ibfk_1` FOREIGN KEY (`sid`) REFERENCES `acl_sid` (`id`),
-  ADD CONSTRAINT `acl_entry_ibfk_2` FOREIGN KEY (`acl_object_identity`) REFERENCES `acl_object_identity` (`id`);
-
-
---
--- Constraints for table `acl_object_identity`
---
-ALTER TABLE `acl_object_identity`
-  ADD CONSTRAINT `acl_object_identity_ibfk_1` FOREIGN KEY (`owner_sid`) REFERENCES `acl_sid` (`id`),
-  ADD CONSTRAINT `acl_object_identity_ibfk_2` FOREIGN KEY (`object_id_class`) REFERENCES `acl_class` (`id`),
-  ADD CONSTRAINT `acl_object_identity_ibfk_3` FOREIGN KEY (`parent_object`) REFERENCES `acl_object_identity` (`id`);
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/authorization.sql b/services/authorization/pstore/src/main/resources/db/mysql/authorization.sql
deleted file mode 100644 (file)
index f887892..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-alter table permissions_actions drop foreign key FK85F82042E2DC84FD;
-drop table if exists accounts_roles;
-drop table if exists permissions;
-drop table if exists permissions_actions;
-drop table if exists permissions_roles;
-drop table if exists roles;
-create table accounts_roles (HJID bigint not null auto_increment, account_id varchar(128) not null, created_at datetime not null, role_id varchar(128) not null, role_name varchar(255), screen_name varchar(255), user_id varchar(128) not null, primary key (HJID), unique (account_id, role_id));
-create table permissions (csid varchar(128) not null, action_group varchar(128), attribute_name varchar(128), created_at datetime not null, description varchar(255), effect varchar(32) not null, resource_name varchar(128) not null, tenant_id varchar(128) not null, updated_at datetime, primary key (csid));
-create table permissions_actions (HJID bigint not null auto_increment, name varchar(128) not null, objectIdentity varchar(128) not null, objectIdentityResource varchar(128) not null, ACTION__PERMISSION_CSID varchar(128), primary key (HJID));
-create table permissions_roles (HJID bigint not null auto_increment, actionGroup varchar(255), created_at datetime not null, permission_id varchar(128) not null, permission_resource varchar(255), role_id varchar(128) not null, role_name varchar(255), primary key (HJID), unique (permission_id, role_id));
-create table roles (csid varchar(128) not null, created_at datetime not null, description varchar(255), displayname varchar(200) not null, rolegroup varchar(255), rolename varchar(200) not null, tenant_id varchar(128) not null, metadata_protection varchar(255), perms_protection varchar(255), updated_at datetime, primary key (csid), unique (rolename, tenant_id), unique (displayname, tenant_id));
-alter table permissions_actions add index FK85F82042E2DC84FD (ACTION__PERMISSION_CSID), add constraint FK85F82042E2DC84FD foreign key (ACTION__PERMISSION_CSID) references permissions (csid);
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql b/services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
deleted file mode 100644 (file)
index 3c05b7d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
---
--- Copyright 2010 University of California at Berkeley
--- Licensed under the Educational Community License (ECL), Version 2.0.
--- You may not use this file except in compliance with this License.
---
--- use cspace;
-CREATE INDEX index_rolename ON roles (rolename);
-CREATE INDEX index_rolegroup ON roles (rolegroup);
-CREATE INDEX index_tenant_id ON roles (tenant_id);
-
-CREATE INDEX index_user_id ON accounts_roles (user_id);
-CREATE INDEX index_account_id ON accounts_roles (account_id);
-CREATE INDEX index_role_id ON accounts_roles (role_id);
-
-CREATE INDEX index_permission_id ON permissions_roles (permission_id);
-CREATE INDEX index_role_id ON permissions_roles (role_id);
-
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql b/services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql
deleted file mode 100644 (file)
index 4ac057b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
---\r
--- Copyright 2009 University of California at Berkeley\r
--- Licensed under the Educational Community License (ECL), Version 2.0.\r
--- You may not use this file except in compliance with this License.\r
---\r
-use cspace;\r
-\r
--- insert into `roles` (`csid`, `rolename`, `displayName`, `rolegroup`, `created_at`, `tenant_id`) values ('-1', 'ROLE_SPRING_ADMIN', 'SPRING_ADMIN', 'Spring Security Administrator', now(), '0');\r
--- insert into `roles` (`csid`, `rolename`, `displayName`, `rolegroup`, `created_at`, `tenant_id`) values ('0', 'ROLE_ADMINISTRATOR', 'ADMINISTRATOR', 'CollectionSpace Administrator', now(), '0');\r
-\r
--- for default bootstrap user required to run ImportAuthZ (to bootstrap Spring) --\r
--- insert into `accounts_roles`(`account_id`, `user_id`, `role_id`, `role_name`, `created_at`) values ('Bootstrapping-Account-DO-NOT-DELETE', 'test', '-1', 'ROLE_SPRING_ADMIN', now());\r
--- insert into `accounts_roles`(`account_id`, `user_id`, `role_id`, `role_name`, `created_at`) values ('Bootstrapping-Account-DO-NOT-DELETE', 'test', '0', 'ROLE_ADMINISTRATOR', now());\r
-\r
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
index a88d2d5d4ae35e8cf2ab6cb60e28a8b75cf929d2..866d555cc7c67e62e41024cd76744dc522a29a2d 100644 (file)
@@ -43,9 +43,9 @@
     
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
         <property name="driverClassName" value="${db.jdbc.driver.class}"/>
-        <property name="url" value="jdbc:${db}://${db.host}:${db.port}/cspace"/>
-        <property name="username" value="${db.user}"/>
-        <property name="password" value="${db.user.password}"/>
+        <property name="url" value="jdbc:${db}://${db.host}:${db.port}/${db.cspace.name}"/>
+        <property name="username" value="${db.cspace.user}"/>
+        <property name="password" value="${db.cspace.user.password}"/>
     </bean>    
 
     <bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
index 3972789aa77ec2881513bb59d097ec9846940e69..c91c8c637586aa290d2aaf910215e30fa5c04c1d 100644 (file)
     <build>\r
         <finalName>collectionspace-services-collectionobject</finalName>\r
         <plugins>\r
+               <plugin>\r
+            <groupId>com.qmino</groupId>\r
+            <artifactId>miredot-maven-plugin</artifactId>\r
+            <version>1.3.1</version>\r
+            <executions>\r
+               <execution>\r
+                  <goals>\r
+                     <goal>restdoc</goal>\r
+                  </goals>\r
+               </execution>\r
+            </executions>\r
+            <configuration>\r
+                               <licence>\r
+                                       UHJvamVjdHxvcmcuY29sbGVjdGlvbnNwYWNlLnNlcnZpY2VzLm9yZy5jb2xsZWN0aW9uc3BhY2Uuc2VydmljZXMuY29sbGVjdGlvbm9iamVjdC5zZXJ2aWNlfDIwMTktMDItMjh8dHJ1ZSNNQ3dDRkdHK29EM2hWTVRyckIveDVaWExNcWRBNWhyL0FoUXo2bkVKV1k1NjdabnFBelh6UFdiOW1iRnVIdz09\r
+                               </licence>                <!-- insert other configuration here (optional) -->\r
+            </configuration>\r
+         </plugin>\r
         </plugins>\r
     </build>\r
+    \r
+    <pluginRepositories>\r
+      <pluginRepository>\r
+         <id>miredot</id>\r
+         <name>MireDot Releases</name>\r
+         <url>http://nexus.qmino.com/content/repositories/miredot</url>\r
+      </pluginRepository>\r
+   </pluginRepositories>\r
+    \r
 </project>\r
 \r
index ab68debecf2fad3206d312b4673cc82b024ef39b..826de10ba08b3810dbe256c7dd6983fa6b3bfab3 100644 (file)
             description="deploy tenant configuration">
         <copy todir="${jee.server.cspace}/cspace/config/services">
             <fileset dir="${basedir}/src/main/cspace/config/services"/>
+                       <filterset>
+                               <filter token="CSPACE_INSTANCE_ID" value="${cspace.instance.id}" />
+                               <filter token="DB_CSADMIN_NAME" value="${db.csadmin.name}" />
+                               <filter token="DB_NUXEO_NAME" value="${db.nuxeo.name}" />
+                               <filter token="DB_CSPACE_NAME" value="${db.cspace.name}" />
+                       </filterset>
         </copy>
     </target>
-       
 
     <target name="deploy" depends="install"
             description="deploy common elements in ${jee.server.cspace}">
diff --git a/services/common/src/main/cspace/config/services/resources/db/mysql/.gitignore b/services/common/src/main/cspace/config/services/resources/db/mysql/.gitignore
deleted file mode 100644 (file)
index e69de29..0000000
index dd9bb6ed8d47a7ed163a900ac28934d8ff5a67ac..871817417d408f52a110914af4be6fd7594e0b57 100644 (file)
                      xmlns:types='http://collectionspace.org/services/config/types'
                      xsi:schemaLocation='http://collectionspace.org/services/config ../resources/common.xsd'>
 
+       <cspace-instance-id>@CSPACE_INSTANCE_ID@</cspace-instance-id>
+       <db-csadmin-name>@DB_CSADMIN_NAME@</db-csadmin-name>
+       <db-nuxeo-name>@DB_NUXEO_NAME@</db-nuxeo-name>
+       <db-cspace-name>@DB_CSPACE_NAME@</db-cspace-name>
        <use-app-generated-tenant-bindings>true</use-app-generated-tenant-bindings>
+    
     <!-- name of the repository client is referred in each service binding -->
     <repository-client name="nuxeo-java" default="true">
         <!-- ip of network interface to which Nuxeo server is listening on -->
@@ -31,5 +36,4 @@
         </properties>
     </repository-client>
 
-
 </svc:service-config>
index cd0ec5bd63c76cb6ed2b3f8ae5700bf94d7e884f..bc965f27c77226eb02250bfdf898e7df36ead121 100644 (file)
@@ -6,8 +6,6 @@ package org.collectionspace.services.common;
 import java.io.File;\r
 import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.sql.Connection;\r
 import java.sql.PreparedStatement;\r
@@ -16,12 +14,10 @@ import java.sql.SQLException;
 import java.sql.Statement;\r
 import java.util.*;\r
 \r
-import javax.naming.NamingException;\r
 import javax.servlet.ServletContext;\r
 import javax.sql.DataSource;\r
 \r
 import org.collectionspace.authentication.AuthN;\r
-\r
 import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;\r
 import org.collectionspace.services.common.config.ConfigReader;\r
 import org.collectionspace.services.common.config.ConfigUtils;\r
@@ -42,9 +38,7 @@ import org.collectionspace.services.config.types.PropertyType;
 import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded;\r
 import org.collectionspace.services.nuxeo.client.java.TenantRepository;\r
 import org.jboss.resteasy.spi.ResteasyProviderFactory;\r
-\r
 import org.apache.tomcat.dbcp.dbcp.BasicDataSource;\r
-\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -61,27 +55,27 @@ public class ServiceMain {
      */\r
     private static volatile ServiceMain instance = null;\r
     private static volatile boolean initFailed = false;\r
+\r
+    private static final String SERVER_HOME_PROPERTY = "catalina.home";\r
+       private static final boolean USE_APP_GENERATED_CONFIG = true;\r
+       \r
+       private static ServletContext servletContext = null;\r
     \r
-    private NuxeoConnectorEmbedded nuxeoConnector;\r
-    private static ServletContext servletContext = null;\r
+       private NuxeoConnectorEmbedded nuxeoConnector;\r
     private String serverRootDir = null;\r
     private ServicesConfigReaderImpl servicesConfigReader;\r
     private TenantBindingConfigReaderImpl tenantBindingConfigReader;\r
     private UriTemplateRegistry uriTemplateRegistry = new UriTemplateRegistry();\r
     \r
-    private static final String SERVER_HOME_PROPERTY = "catalina.home";\r
-       private static final boolean USE_APP_GENERATED_CONFIG = true;\r
     \r
     private ServiceMain() {\r
        //empty\r
     }\r
     \r
     /*\r
-     * FIXME: REM - This method is no longer necessary and can should be removed.\r
      * \r
      * Set this singletons ServletContext without any call to initialize\r
      */\r
-    @Deprecated\r
     private static void setServletContext(ServletContext servletContext) {\r
                if (servletContext != null) {\r
                synchronized (ServiceMain.class) {\r
@@ -89,13 +83,17 @@ public class ServiceMain {
                }\r
                }\r
     }\r
-    \r
+        \r
+    public String getCspaceDatabaseName() {\r
+       return getServiceConfig().getDbCspaceName();\r
+    }\r
+        \r
     public boolean inServletContext() {\r
        return ServiceMain.servletContext != null;\r
     }\r
     \r
     public static ServiceMain getInstance(ServletContext servletContext) {\r
-       ServiceMain.servletContext = servletContext;\r
+       setServletContext(servletContext);\r
        return ServiceMain.getInstance();\r
     }\r
     \r
@@ -108,11 +106,11 @@ public class ServiceMain {
         if (instance == null && initFailed == false) {\r
             synchronized (ServiceMain.class) {\r
                 if (instance == null && initFailed == false) {\r
-                    ServiceMain temp = new ServiceMain();\r
+                    ServiceMain newInstance = new ServiceMain();\r
                     try {\r
                        //assume the worse\r
                        initFailed = true;\r
-                        temp.initialize();\r
+                       newInstance.initialize();\r
                        //celebrate success\r
                         initFailed = false;\r
                     } catch (Exception e) {\r
@@ -123,7 +121,7 @@ public class ServiceMain {
                             throw new RuntimeException(e);\r
                         }\r
                     }\r
-                    instance = temp;\r
+                    instance = newInstance;\r
                 }\r
             }\r
         }\r
@@ -136,28 +134,23 @@ public class ServiceMain {
     }\r
 \r
     private void initialize() throws Exception {\r
-       if (logger.isTraceEnabled() == true)            {\r
-               System.out.print("About to initialize ServiceMain singleton - Pausing 5 seconds for you to attached the debugger");\r
-               long startTime, currentTime;\r
-               currentTime = startTime = System.currentTimeMillis();\r
-               long stopTime = startTime + 5 * 1000; //5 seconds\r
-               do {\r
-                       if (currentTime % 1000 == 0) {\r
-                               System.out.print(".");\r
-                       }\r
-                       currentTime = System.currentTimeMillis();\r
-               } while (currentTime < stopTime);\r
-                       \r
-               System.out.println();\r
-               System.out.println("Resuming cspace services initialization.");\r
-       }\r
-       \r
+       // set our root directory\r
        setServerRootDir();\r
-        readConfig();\r
-       setDataSources();\r
+       \r
+       // read in and set our Services config\r
+       readAndSetServicesConfig();\r
+       \r
+       // Set our AuthN's datasource to for the cspaceDataSource\r
+       AuthN.setDataSource(JDBCTools.getDataSource(JDBCTools.CSPACE_DATASOURCE_NAME));\r
+       \r
+       // Please document this step\r
         propagateConfiguredProperties();\r
+        \r
+        // Create each tenant's Nuxeo database\r
+       createNuxeoDatabases();\r
+\r
         //\r
-        // Start up and initialize our embedded Nuxeo server instance\r
+        // Start up and initialize our embedded Nuxeo instance.\r
         //\r
         if (getClientType().equals(ClientType.JAVA)) {\r
             nuxeoConnector = NuxeoConnectorEmbedded.getInstance();\r
@@ -174,12 +167,17 @@ public class ServiceMain {
         //\r
         // Create all the default user accounts and permissions\r
         //\r
-        try {\r
-               AuthorizationCommon.createDefaultWorkflowPermissions(tenantBindingConfigReader);                \r
-               AuthorizationCommon.createDefaultAccounts(tenantBindingConfigReader);     \r
-        } catch(Throwable e) {         \r
-               logger.error("Default accounts and permissions setup failed with exception(s): " + e.getLocalizedMessage(), e);\r
-        }        \r
+               try {\r
+                       AuthorizationCommon.createDefaultWorkflowPermissions(tenantBindingConfigReader);\r
+                       String cspaceDatabaseName = getCspaceDatabaseName();\r
+                       DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(JDBCTools.CSPACE_DATASOURCE_NAME, cspaceDatabaseName);\r
+                       AuthorizationCommon.createDefaultAccounts(tenantBindingConfigReader, databaseProductType,\r
+                                       cspaceDatabaseName);\r
+               } catch (Exception e) {\r
+                       logger.error("Default accounts and permissions setup failed with exception(s): " +\r
+                                       e.getLocalizedMessage(), e);\r
+                       throw e;\r
+               }\r
         \r
         /*\r
          * This might be useful for something, but the reader grants are better handled in the ReportPostInitHandler.\r
@@ -207,7 +205,7 @@ public class ServiceMain {
         }\r
     }\r
 \r
-    private void readConfig() throws Exception {\r
+    private void readAndSetServicesConfig() throws Exception {\r
         //read service config\r
         servicesConfigReader = new ServicesConfigReaderImpl(getServerRootDir());\r
         servicesConfigReader.read(USE_APP_GENERATED_CONFIG);\r
@@ -377,59 +375,52 @@ public class ServiceMain {
     \r
     public InputStream getResourceAsStream(String resourceName) throws FileNotFoundException {\r
        InputStream result = new FileInputStream(new File(getServerResourcesPath() + resourceName));\r
+       return result;\r
+    }    \r
+    \r
+    public String getCspaceInstanceId() {\r
+       String result = getServiceConfig().getCspaceInstanceId();\r
+       \r
+       if (result == null || result.trim().isEmpty()) {\r
+               result = ""; //empty string\r
+       }\r
+       \r
        return result;\r
     }\r
-\r
     /*\r
-     * Save a copy of the DataSource instances that exist in our initial JNDI context.  For some reason, after starting up\r
-     * our instance of embedded Nuxeo, we can find our datasources.  Therefore, we need to preserve the datasources in these\r
-     * static members.\r
+     * Look through the tenant bindings and create the required Nuxeo databases -each tenant can declare\r
+     * their own Nuxeo repository/database.\r
+        * Get the NuxeoDS info and create the necessary databases.\r
+        * Consider the tenant bindings to find and get the data sources for each tenant.\r
+        * There may be only one, one per tenant, or something in between.\r
+     * \r
      */\r
-    private void setDataSources() throws NamingException, Exception {\r
+    private void createNuxeoDatabases() throws Exception {\r
        final String DB_EXISTS_QUERY_PSQL = \r
                        "SELECT 1 AS result FROM pg_database WHERE datname=?";\r
        final String DB_EXISTS_QUERY_MYSQL = \r
                        "SELECT 1 AS result FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME=?";\r
-       //\r
-       // As a side-effect of calling JDBCTools.getDataSource(...), the DataSource instance will be\r
-       // cached in a static hash map of the JDBCTools class.  This will speed up lookups as well as protect our\r
-       // code from JNDI lookup problems -for example, if the JNDI context gets stepped on or corrupted.\r
-       //\r
-       DataSource cspaceDataSource = JDBCTools.getDataSource(JDBCTools.CSPACE_DATASOURCE_NAME);\r
+               \r
        DataSource nuxeoDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_DATASOURCE_NAME);\r
-       DataSource nuxeoMgrDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_MANAGER_DATASOURCE_NAME);\r
-       DataSource nuxeoReaderDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_READER_DATASOURCE_NAME);\r
-       \r
-       // We need to fetch the user name and password from the nuxeoDataSource, to do grants below\r
-       org.apache.tomcat.dbcp.dbcp.BasicDataSource tomcatDataSource =\r
-                       (org.apache.tomcat.dbcp.dbcp.BasicDataSource)nuxeoDataSource;\r
-       // Get the template URL value from the JNDI datasource and substitute the databaseName\r
+               BasicDataSource tomcatDataSource = (BasicDataSource)nuxeoDataSource;\r
        String nuxeoUser = tomcatDataSource.getUsername();\r
        String nuxeoPW = tomcatDataSource.getPassword();\r
+\r
        // Get reader data source, if any\r
+       DataSource nuxeoReaderDataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_READER_DATASOURCE_NAME);\r
        String readerUser = null;\r
        String readerPW = null;\r
-       if(nuxeoReaderDataSource!= null) {\r
-               tomcatDataSource =\r
-                               (org.apache.tomcat.dbcp.dbcp.BasicDataSource)nuxeoReaderDataSource;\r
+       if (nuxeoReaderDataSource!= null) {\r
+               tomcatDataSource = (BasicDataSource)nuxeoReaderDataSource;\r
                // Get the template URL value from the JNDI datasource and substitute the databaseName\r
                readerUser = tomcatDataSource.getUsername();\r
                readerPW = tomcatDataSource.getPassword();\r
        }\r
        \r
-       //\r
-       // Set our AuthN's datasource to be the cspaceDataSource\r
-       //\r
-       AuthN.setDataSource(cspaceDataSource);\r
-\r
-       // Get the NuxeoDS info and create the necessary databases.\r
-       // Consider the tenant bindings to find and get the data sources for each tenant.\r
-       // There may be only one, one per tenant, or something in between.\r
-       DatabaseProductType dbType = JDBCTools.getDatabaseProductType(\r
-                       JDBCTools.CSPACE_DATASOURCE_NAME,\r
-                       JDBCTools.DEFAULT_CSPACE_DATABASE_NAME); // only returns PG or MYSQL\r
-       String dbExistsQuery = (dbType==DatabaseProductType.POSTGRESQL)?\r
-                                                               DB_EXISTS_QUERY_PSQL : DB_EXISTS_QUERY_MYSQL;\r
+       DatabaseProductType dbType = JDBCTools.getDatabaseProductType(JDBCTools.CSADMIN_DATASOURCE_NAME,\r
+                       getServiceConfig().getDbCsadminName());\r
+       String dbExistsQuery = (dbType == DatabaseProductType.POSTGRESQL) ? DB_EXISTS_QUERY_PSQL :\r
+               DB_EXISTS_QUERY_MYSQL;\r
 \r
        Hashtable<String, TenantBindingType> tenantBindings =\r
                        tenantBindingConfigReader.getTenantBindings();\r
@@ -437,185 +428,182 @@ public class ServiceMain {
        PreparedStatement pstmt = null;\r
        Statement stmt = null;\r
                Connection conn = null;\r
-               \r
-       try {\r
-               conn = nuxeoMgrDataSource.getConnection();\r
-                       // First check and create the roles as needed. (nuxeo and reader)\r
-\r
-               \r
-               pstmt = conn.prepareStatement(dbExistsQuery); // create a statement\r
+       \r
+               try {\r
+                       DataSource csadminDataSource = JDBCTools.getDataSource(JDBCTools.CSADMIN_DATASOURCE_NAME);\r
+                       conn = csadminDataSource.getConnection();\r
+                       pstmt = conn.prepareStatement(dbExistsQuery); // create a statement\r
                        stmt = conn.createStatement();\r
-                       \r
-               for (TenantBindingType tenantBinding : tenantBindings.values()) {\r
-                       String tId = tenantBinding.getId();\r
-                       String tName = tenantBinding.getName();\r
-                       List<RepositoryDomainType> repoDomainList = tenantBinding.getRepositoryDomain();\r
-                       for (RepositoryDomainType repoDomain : repoDomainList) {\r
-                               String repoDomainName = repoDomain.getName();\r
-                               String dbName = JDBCTools.getDatabaseName(repoDomain.getRepositoryName());\r
-                               if(nuxeoDBsChecked.contains(dbName)) {\r
-                                       if (logger.isDebugEnabled()) {\r
-                                               logger.debug("Another user of db: "+dbName+": Repo: "+repoDomainName+" and tenant: "\r
-                                                               +tName+" (id:"+tId+")");\r
-                                       }\r
-                               } else {\r
-                                       if (logger.isDebugEnabled()) {\r
-                                               logger.debug("Need to prepare db: "+dbName+" for Repo: "+repoDomainName+" and tenant: "\r
-                                                               +tName+" (id:"+tId+")");\r
-                                       }\r
-\r
-                                       pstmt.setString(1, dbName);                     // set dbName param\r
-                               ResultSet rs = pstmt.executeQuery();\r
-                               // extract data from the ResultSet\r
-                               boolean dbExists = rs.next(); \r
-                               rs.close();\r
-                               if(dbExists) {\r
-                                               if (logger.isDebugEnabled()) {\r
-                                                       logger.debug("Database: "+dbName+" already exists.");\r
-                                               }\r
-                               } else {\r
-                                       // Create the user as needed\r
-                                       createUserIfNotExists(conn, dbType, nuxeoUser, nuxeoPW);\r
-                                       if(readerUser!=null) {\r
-                                               createUserIfNotExists(conn, dbType, readerUser, readerPW);\r
-                                       }\r
-                                       // Create the database\r
-                                       createDatabaseWithRights(conn, dbType, dbName, nuxeoUser, nuxeoPW, readerUser, readerPW);\r
-                               }\r
-                                       nuxeoDBsChecked.add(dbName);\r
-                               }\r
-                       } // Loop on repos for tenant\r
-               } // Loop on tenants\r
-       } catch(SQLException se) {\r
-               //Handle errors for JDBC\r
-               se.printStackTrace();\r
-       } catch(Exception e) {\r
-               //Handle errors for Class.forName\r
-               e.printStackTrace();\r
-       } finally {   //close resources\r
+\r
+                       // First check and create the roles as needed. (nuxeo and reader)\r
+                       for (TenantBindingType tenantBinding : tenantBindings.values()) {\r
+                               String tId = tenantBinding.getId();\r
+                               String tName = tenantBinding.getName();\r
+                               List<RepositoryDomainType> repoDomainList = tenantBinding.getRepositoryDomain();\r
+                               for (RepositoryDomainType repoDomain : repoDomainList) {\r
+                                       String repoDomainName = repoDomain.getName();\r
+                                       String dbName = JDBCTools.getDatabaseName(repoDomain.getRepositoryName(), getCspaceInstanceId());\r
+                                       if (nuxeoDBsChecked.contains(dbName)) {\r
+                                               if (logger.isDebugEnabled()) {\r
+                                                       logger.debug("Another user of db: " + dbName + ": Repo: " + repoDomainName\r
+                                                                       + " and tenant: " + tName + " (id:" + tId + ")");\r
+                                               }\r
+                                       } else {\r
+                                               if (logger.isDebugEnabled()) {\r
+                                                       logger.debug("Need to prepare db: " + dbName + " for Repo: " + repoDomainName\r
+                                                                       + " and tenant: " + tName + " (id:" + tId + ")");\r
+                                               }\r
+\r
+                                               pstmt.setString(1, dbName); // set dbName param\r
+                                               ResultSet rs = pstmt.executeQuery();\r
+                                               // extract data from the ResultSet\r
+                                               boolean dbExists = rs.next();\r
+                                               rs.close();\r
+                                               if (dbExists) {\r
+                                                       if (logger.isDebugEnabled()) {\r
+                                                               logger.debug("Database: " + dbName + " already exists.");\r
+                                                       }\r
+                                               } else {\r
+                                                       // Create the user as needed\r
+                                                       createUserIfNotExists(conn, dbType, nuxeoUser, nuxeoPW);\r
+                                                       if (readerUser != null) {\r
+                                                               createUserIfNotExists(conn, dbType, readerUser, readerPW);\r
+                                                       }\r
+                                                       // Create the database\r
+                                                       createDatabaseWithRights(conn, dbType, dbName, nuxeoUser, nuxeoPW, readerUser, readerPW);\r
+                                               }\r
+                                               nuxeoDBsChecked.add(dbName);\r
+                                       }\r
+                               } // Loop on repos for tenant\r
+                       } // Loop on tenants\r
+               } finally {   //close resources\r
                try {\r
-                       if(stmt!=null) {\r
+                       if (stmt != null) {\r
                                stmt.close();\r
                        }\r
-               } catch(SQLException se2) {\r
-                       // nothing we can do\r
-               }\r
-               try{\r
-                       if(conn!=null) {\r
+                       if (conn != null) {\r
                                conn.close();\r
                        }\r
-               }catch(SQLException se){\r
+               } catch(SQLException se) {\r
                        se.printStackTrace();\r
                }\r
        }\r
+       \r
     }\r
     \r
-    private void createUserIfNotExists(Connection conn, DatabaseProductType dbType,\r
-               String username, String userPW) throws Exception {\r
-       PreparedStatement pstmt = null;\r
-       Statement stmt = null;\r
-       final String USER_EXISTS_QUERY_PSQL = \r
-                       "SELECT 1 AS result FROM pg_roles WHERE rolname=?";\r
-       String userExistsQuery;\r
-       if(dbType==DatabaseProductType.POSTGRESQL) {\r
-               userExistsQuery = USER_EXISTS_QUERY_PSQL;\r
-       } else {\r
-               throw new UnsupportedOperationException("CreateUserIfNotExists only supports PSQL - MySQL NYI!");\r
-       }\r
-       try {\r
-               pstmt = conn.prepareStatement(userExistsQuery); // create a statement\r
-               pstmt.setString(1, username);                   // set dbName param\r
-               ResultSet rs = pstmt.executeQuery();\r
-               // extract data from the ResultSet\r
-               boolean userExists = rs.next();\r
-               rs.close();\r
-               if(userExists) {\r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("User: "+username+" already exists.");\r
-                       }\r
-               } else {\r
-                       stmt = conn.createStatement();\r
-                       String sql = "CREATE ROLE "+username+" WITH PASSWORD '"+userPW+"' LOGIN";\r
-                       stmt.executeUpdate(sql);\r
-                       // Really should do the grants as well. \r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("Created Users: '"+username+"' and 'reader'");\r
-                       }\r
-               }\r
-       } catch(Exception e) {\r
-               logger.error("createUserIfNotExists failed on exception: " + e.getLocalizedMessage());\r
-               throw e;        // propagate\r
-       } finally {   //close resources\r
-               try {\r
-                       if(pstmt!=null) {\r
-                               pstmt.close();\r
-                       }\r
-                       if(stmt!=null) {\r
-                               stmt.close();\r
-                       }\r
-               } catch(SQLException se) {\r
-                       // nothing we can do\r
-               }\r
-       }\r
-    }\r
+       private void createUserIfNotExists(Connection conn, DatabaseProductType dbType, String username, String userPW)\r
+                       throws Exception {\r
+               PreparedStatement pstmt = null;\r
+               Statement stmt = null;\r
+               final String USER_EXISTS_QUERY_PSQL = "SELECT 1 AS result FROM pg_roles WHERE rolname=?";\r
+               String userExistsQuery;\r
+               \r
+               if (dbType == DatabaseProductType.POSTGRESQL) {\r
+                       userExistsQuery = USER_EXISTS_QUERY_PSQL;\r
+               } else {\r
+                       throw new UnsupportedOperationException("CreateUserIfNotExists only supports PSQL - MySQL NYI!");\r
+               }\r
+               \r
+               try {\r
+                       pstmt = conn.prepareStatement(userExistsQuery); // create a\r
+                                                                                                                       // statement\r
+                       pstmt.setString(1, username); // set dbName param\r
+                       ResultSet rs = pstmt.executeQuery();\r
+                       // extract data from the ResultSet\r
+                       boolean userExists = rs.next();\r
+                       rs.close();\r
+                       if (userExists) {\r
+                               if (logger.isDebugEnabled()) {\r
+                                       logger.debug("User: " + username + " already exists.");\r
+                               }\r
+                       } else {\r
+                               stmt = conn.createStatement();\r
+                               String sql = "CREATE ROLE " + username + " WITH PASSWORD '" + userPW + "' LOGIN";\r
+                               stmt.executeUpdate(sql);\r
+                               // Really should do the grants as well.\r
+                               if (logger.isDebugEnabled()) {\r
+                                       logger.debug("Created Users: '" + username + "' and 'reader'");\r
+                               }\r
+                       }\r
+               } catch (Exception e) {\r
+                       logger.error("createUserIfNotExists failed on exception: " + e.getLocalizedMessage());\r
+                       throw e; // propagate\r
+               } finally { // close resources\r
+                       try {\r
+                               if (pstmt != null) {\r
+                                       pstmt.close();\r
+                               }\r
+                               if (stmt != null) {\r
+                                       stmt.close();\r
+                               }\r
+                       } catch (SQLException se) {\r
+                               // nothing we can do\r
+                       }\r
+               }\r
+       }\r
     \r
-    private void createDatabaseWithRights(Connection conn, DatabaseProductType dbType, String dbName,\r
-               String ownerName, String ownerPW, String readerName, String readerPW) throws Exception {\r
-       Statement stmt = null;\r
-       try {\r
+       private void createDatabaseWithRights(Connection conn, DatabaseProductType dbType, String dbName, String ownerName,\r
+                       String ownerPW, String readerName, String readerPW) throws Exception {\r
+               Statement stmt = null;\r
+               try {\r
                        stmt = conn.createStatement();\r
-               if(dbType==DatabaseProductType.POSTGRESQL) {\r
-                       // Postgres does not need passwords.\r
-                       String sql = "CREATE DATABASE "+dbName+" ENCODING 'UTF8' OWNER "+ownerName;\r
-                       stmt.executeUpdate(sql);\r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("Created db: '"+dbName+"' with owner: '"+ownerName+"'");\r
-                       }\r
-                       if(readerName!= null) {\r
-                               sql = "GRANT CONNECT ON DATABASE "+dbName+" TO "+readerName;\r
-                               stmt.executeUpdate(sql);\r
-                               if (logger.isDebugEnabled()) {\r
-                                       logger.debug(" Granted connect rights on: '"+dbName+"' to reader: '"+readerName+"'");\r
-                               }\r
-                       }\r
-                       // Note that select rights for reader must be granted after Nuxeo startup.\r
-               } else if(dbType==DatabaseProductType.MYSQL) {\r
-                       String sql = "CREATE database "+dbName+" DEFAULT CHARACTER SET utf8";\r
-                       stmt.executeUpdate(sql);\r
-                       sql = "GRANT ALL PRIVILEGES ON "+dbName+".* TO '"+ownerName+"'@'localhost' IDENTIFIED BY '"\r
-                                       +ownerPW+"' WITH GRANT OPTION";\r
-                       stmt.executeUpdate(sql);\r
-                       if (logger.isDebugEnabled()) {\r
-                               logger.debug("Created db: '"+dbName+"' with owner: '"+ownerName+"'");\r
-                       }\r
-                       if(readerName!= null) {\r
-                               sql = "GRANT SELECT ON "+dbName+".* TO '"+readerName+"'@'localhost' IDENTIFIED BY '"\r
-                                               +readerPW+"' WITH GRANT OPTION";\r
-                               stmt.executeUpdate(sql);\r
-                               if (logger.isDebugEnabled()) {\r
-                                       logger.debug(" Granted SELECT rights on: '"+dbName+"' to reader: '"+readerName+"'");\r
-                               }\r
-                       }\r
-               } else {\r
-                       throw new UnsupportedOperationException("createDatabaseWithRights only supports PSQL - MySQL NYI!");\r
-               }\r
-       } catch(Exception e) {\r
-               logger.error("createDatabaseWithRights failed on exception: " + e.getLocalizedMessage());\r
-               throw e;        // propagate\r
-       } finally {   //close resources\r
-               try {\r
-                       if(stmt!=null) {\r
-                               stmt.close();\r
-                       }\r
-               } catch(SQLException se) {\r
-                       // nothing we can do\r
-               }\r
-       }\r
+                       if (dbType == DatabaseProductType.POSTGRESQL) {\r
+                               // Postgres does not need passwords.\r
+                               String sql = "CREATE DATABASE " + dbName + " ENCODING 'UTF8' OWNER " + ownerName;\r
+                               stmt.executeUpdate(sql);\r
+                               if (logger.isDebugEnabled()) {\r
+                                       logger.debug("Created db: '" + dbName + "' with owner: '" + ownerName + "'");\r
+                               }\r
+                               if (readerName != null) {\r
+                                       sql = "GRANT CONNECT ON DATABASE " + dbName + " TO " + readerName;\r
+                                       stmt.executeUpdate(sql);\r
+                                       if (logger.isDebugEnabled()) {\r
+                                               logger.debug(" Granted connect rights on: '" + dbName + "' to reader: '" + readerName + "'");\r
+                                       }\r
+                               }\r
+                               // Note that select rights for reader must be granted after\r
+                               // Nuxeo startup.\r
+                       } else if (dbType == DatabaseProductType.MYSQL) {\r
+                               String sql = "CREATE database " + dbName + " DEFAULT CHARACTER SET utf8";\r
+                               stmt.executeUpdate(sql);\r
+                               sql = "GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + ownerName + "'@'localhost' IDENTIFIED BY '"\r
+                                               + ownerPW + "' WITH GRANT OPTION";\r
+                               stmt.executeUpdate(sql);\r
+                               if (logger.isDebugEnabled()) {\r
+                                       logger.debug("Created db: '" + dbName + "' with owner: '" + ownerName + "'");\r
+                               }\r
+                               if (readerName != null) {\r
+                                       sql = "GRANT SELECT ON " + dbName + ".* TO '" + readerName + "'@'localhost' IDENTIFIED BY '"\r
+                                                       + readerPW + "' WITH GRANT OPTION";\r
+                                       stmt.executeUpdate(sql);\r
+                                       if (logger.isDebugEnabled()) {\r
+                                               logger.debug(" Granted SELECT rights on: '" + dbName + "' to reader: '" + readerName + "'");\r
+                                       }\r
+                               }\r
+                       } else {\r
+                               throw new UnsupportedOperationException("createDatabaseWithRights only supports PSQL - MySQL NYI!");\r
+                       }\r
+               } catch (Exception e) {\r
+                       logger.error("createDatabaseWithRights failed on exception: " + e.getLocalizedMessage());\r
+                       throw e; // propagate\r
+               } finally { // close resources\r
+                       try {\r
+                               if (stmt != null) {\r
+                                       stmt.close();\r
+                               }\r
+                       } catch (SQLException se) {\r
+                               se.printStackTrace();\r
+                       }\r
+               }\r
 \r
-    }\r
+       }\r
     \r
     /*\r
      * This might be useful for something, but the reader grants are better handled in the ReportPostInitHandler.\r
+     * \r
+     * \r
+     */\r
+/*     \r
     private void handlePostNuxeoInitDBTasks() throws Exception {\r
        Statement stmt = null;\r
                Connection conn = null;\r
@@ -662,16 +650,15 @@ public class ServiceMain {
        }\r
 \r
     }\r
-     */\r
+*/\r
     \r
     private void setServerRootDir() {\r
         serverRootDir = System.getProperty(SERVER_HOME_PROPERTY);\r
         if (serverRootDir == null) {\r
             serverRootDir = "."; //assume server is started from server root, e.g. server/cspace\r
-            logger.warn("System property '" +\r
-                       SERVER_HOME_PROPERTY + "' was not set.  Using \"" +\r
-                       serverRootDir +\r
-                       "\" instead.");\r
+            String msg = String.format("System property '%s' was not set.  Using '%s' instead.",\r
+                       SERVER_HOME_PROPERTY, serverRootDir);\r
+            logger.warn(msg);\r
         }\r
     }\r
 \r
@@ -735,6 +722,4 @@ public class ServiceMain {
         }\r
         return uriTemplateRegistry;\r
     }\r
-\r
-\r
 }\r
index 2905214a7f8e013a5ac4bf539626948cb460da33..26518fb0823ddf817ec6da38cd3c37ae7aa4c1cd 100644 (file)
@@ -231,9 +231,9 @@ public class AuthorizationCommon {
         }\r
     }\r
     \r
-    private static Connection getConnection() throws NamingException, SQLException {\r
+    private static Connection getConnection(String databaseName) throws NamingException, SQLException {\r
         return JDBCTools.getConnection(JDBCTools.CSPACE_DATASOURCE_NAME,\r
-                       JDBCTools.DEFAULT_CSPACE_DATABASE_NAME);\r
+                       databaseName);\r
     }\r
     \r
     /*\r
@@ -915,11 +915,15 @@ public class AuthorizationCommon {
        }\r
     }\r
     \r
-    public static void createDefaultAccounts(TenantBindingConfigReaderImpl tenantBindingConfigReader) {\r
+    public static void createDefaultAccounts(\r
+               TenantBindingConfigReaderImpl tenantBindingConfigReader,\r
+               DatabaseProductType databaseProductType,\r
+               String cspaceDatabaseName) throws Exception {\r
        if (logger.isDebugEnabled()) {\r
                logger.debug("ServiceMain.createDefaultAccounts starting...");\r
        }\r
        \r
+       String cspaceDbName = tenantBindingConfigReader.getRepositoryDomain(null).getStorageName();\r
         Hashtable<String, String> tenantInfo = getTenantNamesFromConfig(tenantBindingConfigReader);\r
         \r
         Connection conn = null;\r
@@ -930,9 +934,7 @@ public class AuthorizationCommon {
         // and we're not touching that, so we could safely toss the \r
         // accounts, users, account-tenants, account-roles, and start over.\r
         try {\r
-               DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(JDBCTools.CSPACE_DATASOURCE_NAME,\r
-                       JDBCTools.DEFAULT_CSPACE_DATABASE_NAME);\r
-               conn = getConnection();\r
+               conn = getConnection(cspaceDatabaseName);\r
                ArrayList<String> existingTenants = compileExistingTenants(conn, tenantInfo);\r
                \r
                // Note that this only creates tenants not marked as "createDisabled"\r
@@ -967,42 +969,19 @@ public class AuthorizationCommon {
                                        TENANT_MANAGER_USER, AuthN.TENANT_MANAGER_ACCT_ID, \r
                                        tenantManagerRoleCSID, ROLE_ALL_TENANTS_MANAGER);\r
                }\r
-        } catch (RuntimeException rte) {\r
-               if (logger.isDebugEnabled()) {\r
-                       logger.debug("Exception in createDefaultAccounts: "+\r
-                                               rte.getLocalizedMessage());\r
-                       logger.debug(rte.getStackTrace().toString());\r
-               }\r
-            throw rte;\r
-        } catch (SQLException sqle) {\r
-            // SQLExceptions can be chained. We have at least one exception, so\r
-            // set up a loop to make sure we let the user know about all of them\r
-            // if there happens to be more than one.\r
-               if (logger.isDebugEnabled()) {\r
-                       SQLException tempException = sqle;\r
-                       while (null != tempException) {\r
-                               logger.debug("SQL Exception: " + sqle.getLocalizedMessage());\r
-                               tempException = tempException.getNextException();\r
-                       }\r
-                       logger.debug(sqle.getStackTrace().toString());\r
-               }\r
-            throw new RuntimeException("SQL problem in createDefaultAccounts: ", sqle);\r
         } catch (Exception e) {\r
-               if (logger.isDebugEnabled()) {\r
-                       logger.debug("Exception in createDefaultAccounts: "+\r
-                                               e.getLocalizedMessage());\r
-               }\r
-        } finally {\r
-               try {\r
-               if(conn!=null)\r
-                    conn.close();\r
-            } catch (SQLException sqle) {\r
-               if (logger.isDebugEnabled()) {\r
-                               logger.debug("SQL Exception closing statement/connection: "\r
-                                               + sqle.getLocalizedMessage());\r
-               }\r
-               }\r
-        }      \r
+                       logger.debug("Exception in createDefaultAccounts: " + e.getLocalizedMessage());\r
+               throw e;\r
+               } finally {\r
+                       try {\r
+                               if (conn != null)\r
+                                       conn.close();\r
+                       } catch (SQLException sqle) {\r
+                               if (logger.isDebugEnabled()) {\r
+                                       logger.debug("SQL Exception closing statement/connection: " + sqle.getLocalizedMessage());\r
+                               }\r
+                       }\r
+               }       \r
     }\r
     \r
     private static String getDefaultAdminRole(String tenantId) {\r
index c9c6f89e48e256471f1252a5e11ef37756c64fcc..5470435f72afd686bd6117116424d193bd3ba840 100644 (file)
@@ -17,9 +17,9 @@
  */\r
 package org.collectionspace.services.common.storage;\r
 \r
+import org.collectionspace.services.common.ServiceMain;\r
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.config.ConfigUtils;\r
-import org.collectionspace.services.config.tenant.TenantBindingType;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -27,6 +27,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;\r
 import javax.naming.NamingException;\r
 import javax.sql.DataSource;\r
+\r
 import java.sql.DatabaseMetaData;\r
 import java.sql.Connection;\r
 import java.sql.DriverManager;\r
@@ -38,10 +39,13 @@ import java.sql.Statement;
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.List;\r
+\r
 import javax.sql.rowset.CachedRowSet;\r
 import javax.sql.rowset.RowSetFactory;\r
 import javax.sql.rowset.RowSetProvider;\r
 \r
+import org.apache.tomcat.dbcp.dbcp.BasicDataSource;\r
+\r
 /**\r
  * User: laramie\r
  * $LastChangedRevision:  $\r
@@ -52,10 +56,10 @@ public class JDBCTools {
     public static String CSPACE_DATASOURCE_NAME = "CspaceDS";\r
     public static String NUXEO_DATASOURCE_NAME = "NuxeoDS";\r
     // Default database names\r
-    public static String DEFAULT_CSPACE_DATABASE_NAME = ConfigUtils.DEFAULT_CSPACE_DATABASE_NAME;\r
+//    public static String DEFAULT_CSPACE_DATABASE_NAME = ConfigUtils.DEFAULT_CSPACE_DATABASE_NAME;\r
     public static String DEFAULT_NUXEO_REPOSITORY_NAME = ConfigUtils.DEFAULT_NUXEO_REPOSITORY_NAME;\r
     public static String DEFAULT_NUXEO_DATABASE_NAME = ConfigUtils.DEFAULT_NUXEO_DATABASE_NAME;\r
-    public static String NUXEO_MANAGER_DATASOURCE_NAME = "NuxeoMgrDS";\r
+    public static String CSADMIN_DATASOURCE_NAME = "CsadminDS";\r
     public static String NUXEO_READER_DATASOURCE_NAME = "NuxeoReaderDS";\r
     public static String NUXEO_USER_NAME = "nuxeo";\r
     public static String SQL_WILDCARD = "%";\r
@@ -70,6 +74,11 @@ public class JDBCTools {
        private static final CharSequence URL_DATABASE_NAME = "${DatabaseName}";\r
     private static String JDBC_URL_DATABASE_SEPARATOR = "\\/";\r
         \r
+       //\r
+       // As a side-effect of calling JDBCTools.getDataSource(...), the DataSource instance will be\r
+       // cached in a static hash map of the JDBCTools class.  This will speed up lookups as well as protect our\r
+       // code from JNDI lookup problems -for example, if the JNDI context gets stepped on or corrupted.\r
+       //    \r
     public static DataSource getDataSource(String dataSourceName) throws NamingException {\r
        DataSource result = null;\r
        \r
@@ -142,8 +151,7 @@ public class JDBCTools {
         */\r
        Connection conn = null;\r
        synchronized (JDBCTools.class) {\r
-               org.apache.tomcat.dbcp.dbcp.BasicDataSource dataSource = \r
-                               (org.apache.tomcat.dbcp.dbcp.BasicDataSource)getDataSource(dataSourceName);\r
+               BasicDataSource dataSource = (BasicDataSource)getDataSource(dataSourceName);\r
                // Get the template URL value from the JNDI datasource and substitute the databaseName\r
                String urlTemplate = dataSource.getUrl();\r
                String databaseName = getDatabaseName(repositoryName);\r
@@ -412,20 +420,31 @@ public class JDBCTools {
         return result;\r
     }\r
     \r
-    /*\r
-     * By convention, the repository name and database name are the same.  However, this\r
-     * call encapulates that convention and allows overrides.\r
-     */\r
-    public static String getDatabaseName(String repoName) {\r
+    public static String getDatabaseName(String repoName, String cspaceInstanceId) {\r
        String result = repoName;\r
        \r
-       if (result.equalsIgnoreCase(DEFAULT_NUXEO_REPOSITORY_NAME) == true) {\r
+       //\r
+       // Insert code here if you want to map the repo name to a database name -otherwise\r
+       // we'll assume they are the same thing.\r
+       //\r
+       if (repoName.equalsIgnoreCase(DEFAULT_NUXEO_REPOSITORY_NAME)) {\r
                result = DEFAULT_NUXEO_DATABASE_NAME;\r
        }\r
        \r
+       result = result + cspaceInstanceId;\r
+       \r
        return result;\r
     }\r
     \r
+    /*\r
+     * By convention, the repository name and database name are the same.  However, this\r
+     * call encapulates that convention and allows overrides.\r
+     */\r
+    public static String getDatabaseName(String repoName) {\r
+       String cspaceInstanceId = ServiceMain.getInstance().getCspaceInstanceId();\r
+       return getDatabaseName(repoName, cspaceInstanceId);\r
+    }\r
+    \r
     /**\r
      * Returns the catalog/database name for an open JDBC connection.\r
      * \r
diff --git a/services/common/src/main/resources/db/mysql/create_id_generators_table.sql b/services/common/src/main/resources/db/mysql/create_id_generators_table.sql
deleted file mode 100644 (file)
index 2273e2f..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*     
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright Â© 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- */
-
-/*
- * create_id_generators_table.sql
- *
- * Creates the "id_generators" table, used by the ID Service,
- * and sets the access permissions of that table.
- *
- * $LastChangedRevision$
- * $LastChangedDate$
- */
-
--- DROP TABLE IF EXISTS `id_generators`;
-
-CREATE TABLE IF NOT EXISTS `id_generators` (
-  `csid`                varchar(80) PRIMARY KEY,
-  `displayname`         varchar(80),
-  `description`         varchar(500),
-  `priority`            smallint(1) DEFAULT 9 NOT NULL,
-  `id_generator_state`  varchar(8000) NOT NULL,
-  `last_generated_id`   varchar(255),
-  `modified`            timestamp NOT NULL
-                        default CURRENT_TIMESTAMP
-                        on update CURRENT_TIMESTAMP,
-  INDEX `csid_index` (`csid`)
-) ENGINE=InnoDB;
-
-
-SHOW WARNINGS;
diff --git a/services/common/src/main/resources/db/mysql/load_id_generators.sql b/services/common/src/main/resources/db/mysql/load_id_generators.sql
deleted file mode 100644 (file)
index 0a7bc83..0000000
+++ /dev/null
@@ -1,640 +0,0 @@
-/*     
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright Â© 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- */
-
-/*
- * load_id_generators_table.sql
- *
- * Loads a default set of data into the "id_generators" table,
- * used by the ID Service.
- *
- * $LastChangedRevision$
- * $LastChangedDate$
- */
-
-/*
- * Note: in the priority column, values range from  '1' (highest)
- * to '9' (lowest).
- */
-
-/*
- * NOTE: In the id_generator_state column, for numeric sequence parts
- * whose first generated value should start at the initial value
- * (such as '1'), enter '-1' for the <currentValue>
- *
- * Otherwise, the first generated value will be the next value
- * in the sequence after the initial value (e.g. '2', if the
- * initial value is '1').
- */
-
--- ACCESSION_LOT_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('1a67470b-19b1-4ae3-88d4-2a0aa936270e',
-     'Accession Activity Number',
-     'Identifies accession activities, in which a lot of
-one or more collection objects is acquired by the institution.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- ACCESSION_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('9dd92952-c384-44dc-a736-95e435c1759c',
-     'Accession Number',
-     'Identifies individual collection objects formally
-acquired by the institution. Used for collection objects
-without parts.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- ARCHIVES_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('70586d30-9dca-4a07-a3a2-1976fe898028',
-     'Archives Number',
-     'Identifies archives-related accession activities,
-in which a lot of one or more collection objects is formally
-acquired for the archives.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>AR</initialValue>
-      <currentValue>AR</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- EVALUATION_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('d2d80822-25c7-4c7c-a105-fc40cdb0c50f',
-     'Evaluation Number',
-     'Identifies evaluation-related intake activities,
-in which a lot of one or more collection objects is formally
-acquired for evaluation.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>EV</initialValue>
-      <currentValue>EV</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- INTAKE_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('8088cfa5-c743-4824-bb4d-fb11b12847f7',
-     'Intake Number',
-     'Identifies intake activities, in which a lot of one
-or more collection objects enters the institution.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-   <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>IN</initialValue>
-      <currentValue>IN</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- INTAKE_OBJECT_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('a91db555-5c53-4996-9918-6712351397a0',
-     'Intake Object Number',
-     'Identifies individual collection objects that enter
-the institution through intake activities, before they are 
-either returned to their owner or formally acquired.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>IN</initialValue>
-      <currentValue>IN</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- INVENTORY_NUMBER
-
-INSERT IGNORE INTO id_generators
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('6d472be6-2534-47f3-a3f1-3f160e7a9303',
-     'Inventory Number',
-     'Unambiguously identifies a location associated with an inventory event.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>INV</initialValue>
-      <currentValue>INV</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- LIBRARY_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('80fedaf6-1647-4f30-9f53-a75a3cac2ffd',
-     'Library Number',
-     'Identifies library-related accession activities,
-in which a lot of one or more collection objects is
-formally acquired for the library.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-   <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>LIB</initialValue>
-      <currentValue>LIB</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- LOANS_IN_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('ed87e7c6-0678-4f42-9d33-f671835586ef',
-     'Loan In Number',
-     'Identifies activities in which collection objects are
-received on loan.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>LI</initialValue>
-      <currentValue>LI</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- LOANS_OUT_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('4b984865-f93d-4481-b874-3dba863ec589',
-     'Loan Out Number',
-     'Identifies activities in which collection objects are
-loaned out of the institution.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>LO</initialValue>
-      <currentValue>LO</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- LOCATION_NUMBER
-
-INSERT IGNORE INTO id_generators
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('1fc5e383-0786-4126-9a3c-ec7df4517ee3',
-     'Location Number',
-     'Unambiguously identifies a general location, not associated with an
-inventory or movement event.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>LOC</initialValue>
-      <currentValue>LOC</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- MEDIA_RESOURCE_IDENTIFICATION_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('cd91d8b8-f346-4925-a425-93e02bd1c5c9',
-     'Media Resource Identification Number',
-     'Unambiguously identifies a media resource within a given context.
-Recommended best practice is to identify the resource by means of a string
-conforming to a formal identification system.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>MR</initialValue>
-      <currentValue>MR</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- MOVEMENT_REFERENCE_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('49ca9d8d-7136-47ff-a70e-4a47b9038b70',
-     'Movement Reference Number',
-     'Identifies a movement of a collection object or a group of collection objects.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>MV</initialValue>
-      <currentValue>MV</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- OBJECT_EXIT_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('d4eea707-d473-4367-853a-728fbcd9be17',
-     'Object Exit Number',
-     'Identifies an exit from the museum of collection objects, via
-transfer or destruction, and the deaccessioning of those objects
-from the museum\'s collections.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>EX</initialValue>
-      <currentValue>EX</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- STUDY_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('0518132e-dd8c-4773-8fa9-07c9af4444ee',
-     'Study Number',
-     'Identifies study-related intake activities,
-in which a lot of one or more collection objects is
-formally acquired for study.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-   <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>ST</initialValue>
-      <currentValue>ST</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- TRANSFER_OF_TITLE_NUMBER
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES
-    ('c597a209-5954-4fa6-bf3f-f83c1a0ad586',
-     'Transfer of Title Number',
-     'Identifies the transfer of title for one or more collection objects
-to a receiving institution.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>TT</initialValue>
-      <currentValue>TT</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.YearIDGeneratorPart>
-      <currentValue></currentValue>
-    </org.collectionspace.services.id.YearIDGeneratorPart>
-    <org.collectionspace.services.id.StringIDGeneratorPart>
-      <initialValue>.</initialValue>
-      <currentValue>.</currentValue>
-    </org.collectionspace.services.id.StringIDGeneratorPart>
-    <org.collectionspace.services.id.NumericIDGeneratorPart>
-      <maxLength>6</maxLength>
-      <initialValue>1</initialValue>
-      <currentValue>-1</currentValue>
-    </org.collectionspace.services.id.NumericIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
--- UUID
-
-/*
- * Note: these are Type 4 UUIDs, whose generation is based on
- * random and pseudo-random parts.
- */
-
-INSERT IGNORE INTO `id_generators`
-    (csid, displayname, description, priority, last_generated_id, id_generator_state)
-  VALUES 
-    ('1fa40353-05b8-4ae6-82a6-44a18b4f3c12',
-     'UUID',
-     'Universally unique identifiers (UUIDs), which may be
-used for CollectionSpace IDs (CSIDs) and any other relevant
-purposes.',
-     '9',
-     '',
-'<org.collectionspace.services.id.SettableIDGenerator>
-  <parts>
-    <org.collectionspace.services.id.UUIDGeneratorPart>
-    </org.collectionspace.services.id.UUIDGeneratorPart>
-  </parts>
-</org.collectionspace.services.id.SettableIDGenerator>');
-
-SHOW WARNINGS;
index 64fe13655408362389f79b023364bd5a894db7b6..00f142a9ad87e271327cc9ca76dfce793d396d21 100644 (file)
@@ -12,7 +12,7 @@ public class ConfigUtils {
     final static Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
     
     // Default database names
-    public static String DEFAULT_CSPACE_DATABASE_NAME = "cspace";
+//    public static String DEFAULT_CSPACE_DATABASE_NAME = "cspace";
     public static String DEFAULT_NUXEO_REPOSITORY_NAME = "default";
     public static String DEFAULT_NUXEO_DATABASE_NAME = "nuxeo";
     
index cda398ffb60b63d488f9d2dc30d5a7db529d9051..0f57a48c5e253ca02e226def5cc7d4c68a3e1886 100644 (file)
         <xs:complexType>
             <xs:sequence>
                <xs:element name="use-app-generated-tenant-bindings" type="xs:boolean" minOccurs="0"  maxOccurs="1"/>
+               <xs:element name="cspace-instance-id" type="xs:string" default="" minOccurs="0"  maxOccurs="1"/>
+               <xs:element name="db-csadmin-name" type="xs:string" minOccurs="1"  maxOccurs="1"/>
+               <xs:element name="db-cspace-name" type="xs:string" minOccurs="1"  maxOccurs="1"/>
+               <xs:element name="db-nuxeo-name" type="xs:string" minOccurs="1"  maxOccurs="1"/>
                 <!-- assumption: there is only one type of repository client used  -->
                 <xs:element name="repository-client" type="RepositoryClientConfigType" minOccurs="1"  maxOccurs="1"/>
                 <xs:element name="repository-workspace" type="RepositoryWorkspaceType" minOccurs="0"  maxOccurs="1" />
index 39e35812a0fe323be0460252da36bee045afc762..45a73990dacecd9a9ed4022b5f0d3ba748408d73 100644 (file)
@@ -1,4 +1,3 @@
-\r
 <project name="security.client" default="package" basedir=".">\r
     <description>\r
         collectionspace security service\r
         <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
         <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
         <delete file="${dest.hibernate.cfg}" verbose="true" />\r
-        <filter token="DB_URL" value="${db.jdbc.cspace.url}" />\r
+        <filter token="DB_CSPACE_URL" value="${db.jdbc.cspace.url}" />\r
         <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
-        <filter token="DB_USER" value="${db.cspace.user}" /> <!-- double-sub from ${db.user} fails -->\r
-        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
+        <filter token="DB_CSPACE_USER" value="${db.cspace.user}" />\r
+        <filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" /> <!-- double-sub from ${db.cspace.user.password} fails -->\r
         <filter token="DB_DIALECT" value="${db.dialect}" />\r
         <copy todir="${basedir}/target/test-classes" filtering="true">\r
             <fileset dir="${basedir}/src/test/resources">\r
index 8296399cf33de770654f4940a04619ad72791eaf..eb577d2288530b858d59fadf06905fb12da5c7d4 100644 (file)
           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.url">@DB_CSPACE_URL@</property>
         <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
-        <property name="connection.username">@DB_USER@</property>
-        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="connection.username">@DB_CSPACE_USER@</property>
+        <property name="connection.password">@DB_CSPACE_PASSWORD@</property>
         <property name="dialect">@DB_DIALECT@</property>
         <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
         <property name="current_session_context_class">thread</property>
diff --git a/src/main/resources/db/mysql/init_cspace_db.sql b/src/main/resources/db/mysql/init_cspace_db.sql
deleted file mode 100644 (file)
index 7d4cb29..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---
--- delete all users
---
--- DELETE FROM mysql.user WHERE NOT (host="localhost" and user="root");
--- FLUSH PRIVILEGES;
-
---
--- delete anonymous access
---
-DELETE FROM mysql.user WHERE User = '';
-FLUSH PRIVILEGES;
-
---
--- recreate cspace database
---
-DROP database IF EXISTS cspace;
-CREATE database cspace DEFAULT CHARACTER SET utf8;
-
---
--- grant privileges to users on cspace database
---
-GRANT ALL PRIVILEGES ON cspace.* TO '@DB_CSPACE_USER@'@'localhost' IDENTIFIED BY '@DB_CSPACE_PASSWORD@' WITH GRANT OPTION;
-FLUSH PRIVILEGES;
-
diff --git a/src/main/resources/db/mysql/init_nuxeo_db.sql b/src/main/resources/db/mysql/init_nuxeo_db.sql
deleted file mode 100644 (file)
index 9e36793..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
---
--- recreate nuxeo database
---
-DROP database IF EXISTS nuxeo;
-
--- All the rest of what is commented out below is now handled at startup
--- by the services web-app
-
--- CREATE database nuxeo DEFAULT CHARACTER SET utf8;
-
-
---
--- grant privileges to users on nuxeo database
---
--- GRANT ALL PRIVILEGES ON nuxeo.* TO '@DB_NUXEO_USER@'@'localhost' IDENTIFIED BY '@DB_NUXEO_PASSWORD@' WITH GRANT OPTION;
---
--- Grant privileges to read-only user on Nuxeo, for reporting. 
---
--- GRANT SELECT ON nuxeo.* TO 'reader'@'localhost' IDENTIFIED BY 'read';
---
--- Grant privileges to remote read-only users on Nuxeo, for reporting. 
--- These should be changed to reflect your domain. Avoid specifying
--- 'reader'@'%' (while simple and flexible, this is a potential security hole).
---
--- GRANT SELECT ON nuxeo.* TO 'reader'@'%.berkeley.edu' IDENTIFIED BY 'read';
--- GRANT SELECT ON nuxeo.* TO 'reader'@'%.movingimage.us' IDENTIFIED BY 'read';
-
-FLUSH PRIVILEGES;
-
index 2bd020948e0163380fc6d6e6da911c2787328157..41df9d11ba11ad30f74f1befb479bce92d39b878 100644 (file)
@@ -1,11 +1,11 @@
 -- drop all the objects before dropping roles
-DROP database IF EXISTS cspace;
+DROP database IF EXISTS @DB_CSPACE_NAME@;
 
-DROP USER IF EXISTS cspace;
+DROP USER IF EXISTS @DB_CSPACE_USER@;
 
 CREATE ROLE @DB_CSPACE_USER@ WITH PASSWORD '@DB_CSPACE_PASSWORD@' LOGIN;
 
 --
 -- recreate cspace database
 --
-CREATE DATABASE cspace ENCODING 'UTF8' OWNER @DB_CSPACE_USER@;
+CREATE DATABASE @DB_CSPACE_NAME@ ENCODING 'UTF8' OWNER @DB_CSPACE_USER@;
index 7120ad23b0bc0661813708aa7680a50d6e1b8e09..21eddbdbb387cbbb80655835e234e435cf7d9740 100644 (file)
@@ -1,9 +1,9 @@
 -- drop all the objects before dropping roles
-DROP database IF EXISTS nuxeo;
+DROP database IF EXISTS @DB_NUXEO_NAME@;
 DROP database IF EXISTS lifesci_domain;
 
-DROP USER IF EXISTS nuxeo;
-DROP USER IF EXISTS reader;
+DROP USER IF EXISTS @DB_NUXEO_USER@;
+DROP USER IF EXISTS @DB_READER_USER@;
 
 -- All the rest of what is commented out below is now handled at startup
 -- by the services web-app