]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2903, CSPACE-2421. Added support for postgresql, cleaned up configuration...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Thu, 16 Jun 2011 20:33:49 +0000 (20:33 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Thu, 16 Jun 2011 20:33:49 +0000 (20:33 +0000)
48 files changed:
build.properties
build.xml
pom.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch.xml
services/JaxRsServiceProvider/pom.xml
services/JaxRsServiceProvider/src/main/resources/META-INF/persistence.xml
services/account/client/pom.xml
services/account/pstore/pom.xml
services/account/pstore/src/main/resources/db/mysql/account_index.sql
services/account/pstore/src/main/resources/db/postgresql/README.txt [new file with mode: 0644]
services/account/pstore/src/main/resources/db/postgresql/account.sql [new file with mode: 0644]
services/account/pstore/src/main/resources/db/postgresql/account_index.sql [new file with mode: 0644]
services/authentication/pstore/build.xml
services/authentication/pstore/pom.xml
services/authentication/pstore/src/main/resources/db/postgresql/README.txt [new file with mode: 0644]
services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql [new file with mode: 0644]
services/authority/pom.xml
services/authorization-mgt/client/pom.xml
services/authorization-mgt/import/build.xml
services/authorization-mgt/import/pom.xml
services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java
services/authorization-mgt/import/src/main/resources/applicationContext-authorization-test.xml
services/authorization/pstore/pom.xml
services/authorization/pstore/src/main/resources/db/mysql/acl.sql
services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
services/authorization/pstore/src/main/resources/db/postgresql/README.txt [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/postgresql/acl.sql [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/postgresql/authorization.sql [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/postgresql/authorization_index.sql [new file with mode: 0644]
services/authorization/service/pom.xml
services/authorization/service/src/main/resources/applicationContext-authorization.xml
services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java
services/common/pom.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java
services/common/src/main/java/org/collectionspace/services/common/init/AddIndices.java
services/common/src/main/java/org/collectionspace/services/common/init/ModifyFieldDatatypes.java
services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java
services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java
services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageUtils.java
services/id/service/build.xml
services/id/service/src/main/java/org/collectionspace/services/id/IDServiceJdbcImpl.java
services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql
services/id/service/src/main/resources/db/mysql/load_id_generators.sql
services/id/service/src/main/resources/db/postgresql/create_id_generators_table.sql
services/id/service/src/main/resources/db/postgresql/load_id_generators.sql
services/pom.xml
src/main/resources/db/postgresql/init_db.sql

index 7dd8d18a30d644b40d3a7aafe1c6749017e34155..dd351fab518737c8507eb8925d7839e04bd5b406 100644 (file)
@@ -76,6 +76,8 @@ db.jdbc.driver.class=com.mysql.jdbc.Driver
 db.dialect=org.hibernate.dialect.MySQLDialect\r
 db.typemapping=mySQL\r
 db.exceptionsorter=org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter\r
+db.spring.acl.classIdentityQuery=SELECT @@IDENTITY\r
+db.spring.acl.sidIdentityQuery=SELECT @@IDENTITY\r
 \r
 #For postgresql, uncomment this, and comment out mysql section\r
 #db.port=5432\r
@@ -83,7 +85,11 @@ db.exceptionsorter=org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
 #db.jdbc.driver.class=org.postgresql.Driver\r
 #db.dialect=org.hibernate.dialect.PostgreSQLDialect\r
 #db.typemapping=PostgreSQL 8.0\r
-#db.exceptionsorter=org.jboss.resource.adapter.jdbc.vendor.PostgreSQLExceptionSorter\r
+# Should be org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter\r
+# but current JBoss does not seem to include it...\r
+#db.exceptionsorter= \r
+#db.spring.acl.classIdentityQuery=select currval(pg_get_serial_sequence('acl_class', 'id'))\r
+#db.spring.acl.sidIdentityQuery=select currval(pg_get_serial_sequence('acl_sid', 'id'))\r
 \r
 \r
 #database common settings\r
index eb311ae2405be6549ae0a7d5bf568aa8a48bfc03..e46dc2a38cebedd54cda692e237c078b013fa119 100644 (file)
--- a/build.xml
+++ b/build.xml
              url="${db.jdbc.baseurl}"\r
              userid="${db.user}"\r
              password="${db.user.password}"\r
+                                                autocommit="true"\r
              src="${db.script.dir}/init_db.sql"\r
              >\r
             <classpath>\r
diff --git a/pom.xml b/pom.xml
index fc4c1bf10f3884784e8bec4a4fcc1c7406aec23a..60aff6b918b2fa8b733d024ce0b371fbfaaf7f80 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                 <enabled>false</enabled>\r
             </snapshots>\r
         </pluginRepository>\r
+        <pluginRepository>\r
+            <id>repo1</id>\r
+            <name>Maven repo1</name>\r
+            <url>http://repo1.maven.org/maven2</url>\r
+            <snapshots>\r
+                <enabled>false</enabled>\r
+            </snapshots>\r
+        </pluginRepository>\r
         <pluginRepository>\r
             <id>maven repo</id>\r
             <name>maven repo</name>\r
index 383c08d6bcfc2b1fa9fb74123349bf1e73b180d7..0cc39a587f24495e9c7cf6d7de3e9f453bbc6a32 100644 (file)
@@ -3,7 +3,6 @@
        <auths>\r
                <!-- IMPORTANT: THESE ARE STICKY :: THEY STICK AROUND UNTIL RESET, IN EXEC ORDER OF THIS FILE. -->\r
                <auth ID="admin@core.collectionspace.org">YWRtaW5AY29yZS5jb2xsZWN0aW9uc3BhY2Uub3JnOkFkbWluaXN0cmF0b3I=</auth>\r
-               <auth ID="testAdministator">YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y</auth>\r
        </auths>\r
        <testGroup ID="testSingle" autoDeletePOSTS="true">\r
                <test ID="createCollObj1" auth="test">\r
index 6b09ab5bb1721bf5a4069b9a24e93efc6521d136..f0ac40123858f6c9c2cad7a3f4d8ff1a300fb911 100644 (file)
     <build>\r
         <finalName>cspace-services</finalName>\r
         <defaultGoal>package</defaultGoal>\r
+                                       <filters>\r
+                                               <filter>../../build.properties</filter>\r
+                                       </filters>\r
+                                       <resources>\r
+                                               <resource>\r
+                                                       <directory>src/main/resources</directory>\r
+                                                       <filtering>true</filtering>\r
+                                               </resource>\r
+                                       </resources>\r
         <plugins>\r
             <plugin>\r
                 <groupId>org.codehaus.mojo</groupId>\r
                     </files>\r
                 </configuration>\r
             </plugin>\r
-            <plugin>\r
+                                               <plugin>\r
+                                                       <groupId>org.apache.maven.plugins</groupId>\r
+                                                       <artifactId>maven-resources-plugin</artifactId>\r
+                                                       <version>2.5</version>\r
+                                                       <executions>\r
+                                                               <execution>\r
+                                                                       <phase>process-resources</phase>\r
+                                                                       <goals>\r
+                                                                               <goal>resources</goal>\r
+                                                                       </goals>\r
+                                                               </execution>\r
+                                                       </executions>\r
+                                               </plugin>\r
+             <plugin>\r
                 <groupId>org.codehaus.cargo</groupId>\r
                 <artifactId>cargo-maven2-plugin</artifactId>\r
                 <version>0.3</version>\r
index 2ae9d411d846070cdaf5352d0bcfe8b34469ad69..9bed0370d3a30b2458c2731a990fad455fa14381 100644 (file)
@@ -15,7 +15,7 @@
         <class>org.collectionspace.services.authorization.Role</class>
         <class>org.collectionspace.services.authorization.AccountRoleRel</class>
         <properties>
-            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
+                                       <property name="hibernate.dialect" value="${db.dialect}"/>
             <property name="hibernate.max_fetch_depth" value="3"/>
             <!--property name="hibernate.hbm2ddl.auto" value="create-drop"/-->
         </properties>
index 458162e5f78dc844294900467d45a5cb9b1196cf..ab3d51b2b4cd1e03d0c3ace7c617a7d4ccc3cb5b 100644 (file)
             <artifactId>mysql-connector-java</artifactId>\r
             <scope>test</scope>\r
         </dependency>\r
-        <!-- <dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
+            <scope>test</scope>\r
+                               </dependency>\r
+         <!-- <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.client</artifactId>\r
             <version>${project.version}</version>\r
index d3707f35da70914820dc9941bd580e5ddd020f16..54047f333d12969adb6074c295bcf48d8893d20e 100644 (file)
@@ -15,7 +15,7 @@
 \r
     <properties>\r
         <sql.file>account.sql</sql.file>\r
-        <sql.dir>${basedir}/src/main/resources/db/mysql</sql.dir>\r
+                               <sql.dir>${basedir}/src/main/resources/db</sql.dir>\r
     </properties>\r
 \r
     <dependencies>\r
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
         </dependency>\r
-        <!-- CollectionSpace dependencies -->\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
+                               </dependency>\r
+         <!-- CollectionSpace dependencies -->\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.account.jaxb</artifactId>\r
             <id>ddl</id>\r
             <build>\r
                 <plugins>\r
+                                                                               <plugin>\r
+                                                                                       <groupId>org.codehaus.mojo</groupId>\r
+                                                                                       <artifactId>properties-maven-plugin</artifactId>\r
+                                                                                       <version>1.0-alpha-2</version>\r
+                                                                                       <executions>\r
+                                                                                               <execution>\r
+                                                                                                       <phase>initialize</phase>\r
+                                                                                                       <goals>\r
+                                                                                                               <goal>read-project-properties</goal>\r
+                                                                                                       </goals>\r
+                                                                                                       <configuration>\r
+                                                                                                               <files>\r
+                                                                                                                       <file>${basedir}/../../../build.properties</file>\r
+                                                                                                               </files>\r
+                                                                                                       </configuration>\r
+                                                                                               </execution>\r
+                                                                                       </executions>\r
+                                                                               </plugin>\r
                     <plugin>\r
                         <groupId>org.codehaus.mojo</groupId>\r
                         <artifactId>hibernate3-maven-plugin</artifactId>\r
                             <dependency>\r
                                 <groupId>mysql</groupId>\r
                                 <artifactId>mysql-connector-java</artifactId>\r
-                                <version>5.1.5</version>\r
+                                                                                                                               <version>5.1.5</version>\r
                             </dependency>\r
+                                                                                                               <dependency>\r
+                                                                                                                               <groupId>postgresql</groupId>\r
+                                                                                                                               <artifactId>postgresql</artifactId>\r
+                                                                                                                               <version>8.4-702.jdbc4</version>\r
+                                                                                                               </dependency>\r
                         </dependencies>\r
                     </plugin>\r
                     <plugin>\r
                                 <phase>process-test-resources</phase>\r
                                 <configuration>\r
                                     <tasks>\r
-                                        <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${sql.file}"/>\r
+                                                                                                                                                       <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${db}/${sql.file}"/>\r
                                     </tasks>\r
                                 </configuration>\r
                                 <goals>\r
index 0b9a66ec456a4406e3e2a340624492e20481e3bb..0eace4edc33cef5d8b860b4145669b9de9245a6d 100644 (file)
@@ -3,7 +3,7 @@
 -- Licensed under the Educational Community License (ECL), Version 2.0.
 -- You may not use this file except in compliance with this License.
 --
-use cspace;
+-- 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);
diff --git a/services/account/pstore/src/main/resources/db/postgresql/README.txt b/services/account/pstore/src/main/resources/db/postgresql/README.txt
new file mode 100644 (file)
index 0000000..b591433
--- /dev/null
@@ -0,0 +1,32 @@
+The file account.sql is basically generated by the gen_ddl ant target.\r
+However, you must modify the result of that to make the \r
+\r
+  DROP TABLE \r
+\r
+statements be \r
+  \r
+  DROP TABLE IF EXISTS table CASCADE \r
+\r
+This ensures that first time setup does not fail, and that later invocations\r
+can deal with dependencies.\r
+\r
+You must also make the\r
+\r
+  DROP SEQUENCE \r
+\r
+statements be \r
+\r
+  DROP SEQUENCE IF EXISTS\r
+\r
+for similar reasons.\r
+\r
+You must also remove (comment out) the statement (which is superfluous with the CASCADE above):\r
+\r
+  alter table permissions_actions drop constraint FKFDA649B05A9CEEB5;\r
+\r
+When using the account_tenants table on insert, you have to specify "nextval('hibernate_sequence')" \r
+as the value for the HJID column. \r
+\r
+Note that because of the way gen_ddl does its work per-sub-project, there is a single shared\r
+sequence for both this and the authorization.sql script. This should be okay, even if it does\r
+create gaps in what would be a nice sequence for each table.\r
diff --git a/services/account/pstore/src/main/resources/db/postgresql/account.sql b/services/account/pstore/src/main/resources/db/postgresql/account.sql
new file mode 100644 (file)
index 0000000..2a7fa29
--- /dev/null
@@ -0,0 +1,10 @@
+-- alter table accounts_tenants drop constraint FKFDA649B05A9CEEB5;
+DROP TABLE IF EXISTS accounts_common CASCADE;
+DROP TABLE IF EXISTS accounts_tenants CASCADE;
+DROP TABLE IF EXISTS tenants CASCADE;
+DROP SEQUENCE IF EXISTS hibernate_sequence;
+create table accounts_common (csid varchar(128) not null, created_at timestamp not null, email varchar(255) not null, mobile varchar(255), person_ref_name varchar(255), phone varchar(255), screen_name varchar(128) not null, status varchar(15) not null, updated_at timestamp, userid varchar(128) not null, primary key (csid));
+create table accounts_tenants (HJID int8 not null, tenant_id varchar(128) not null, TENANTS_ACCOUNTSCOMMON_CSID varchar(128), primary key (HJID));
+create table tenants (id varchar(128) not null, created_at timestamp not null, name varchar(255) not null, updated_at timestamp, primary key (id));
+alter table accounts_tenants add constraint FKFDA649B05A9CEEB5 foreign key (TENANTS_ACCOUNTSCOMMON_CSID) references accounts_common;
+create sequence hibernate_sequence;
diff --git a/services/account/pstore/src/main/resources/db/postgresql/account_index.sql b/services/account/pstore/src/main/resources/db/postgresql/account_index.sql
new file mode 100644 (file)
index 0000000..0eace4e
--- /dev/null
@@ -0,0 +1,12 @@
+--
+-- 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);
index dda450f8353c3d3c43d7e834b80ffcb495255506..267d70d46946c6f0f8999a37fec42707fcd01650 100644 (file)
                 <pathelement path="${db.driver.jar}"/>\r
             </classpath>\r
         </sql>\r
+                               <!-- No longer used\r
                                <sql driver="${db.jdbc.driver.class}"\r
              url="${db.jdbc.cspace.url}"\r
              userid="${db.cspace.user}"\r
                 <pathelement path="${db.driver.jar}"/>\r
             </classpath>\r
         </sql>\r
-                               <!-- No longer used\r
                                <sql driver="${db.jdbc.driver.class}"\r
              url="${db.jdbc.cspace.url}"\r
              userid="${db.cspace.user}"\r
index 9a1ff8a58c8a005a7df680c8ef8cb94cbf8f9790..c98dab1d0deb67dac8feca465d5b50672c608072 100644 (file)
@@ -16,7 +16,7 @@
 \r
     <properties>\r
         <sql.file>authentication.sql</sql.file>\r
-        <sql.dir>${basedir}/src/main/resources/db/mysql</sql.dir>\r
+        <sql.dir>${basedir}/src/main/resources/db</sql.dir>\r
     </properties>\r
 \r
     <dependencies>\r
         <dependency>\r
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
+        </dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
         </dependency>\r
         <!-- CollectionSpace -->\r
         <dependency>\r
             <id>ddl</id>\r
             <build>\r
                 <plugins>\r
-                    <plugin>\r
+                                                                               <plugin>\r
+                                                                                       <groupId>org.codehaus.mojo</groupId>\r
+                                                                                       <artifactId>properties-maven-plugin</artifactId>\r
+                                                                                       <version>1.0-alpha-2</version>\r
+                                                                                       <executions>\r
+                                                                                               <execution>\r
+                                                                                                       <phase>initialize</phase>\r
+                                                                                                       <goals>\r
+                                                                                                               <goal>read-project-properties</goal>\r
+                                                                                                       </goals>\r
+                                                                                                       <configuration>\r
+                                                                                                               <files>\r
+                                                                                                                       <file>${basedir}/../../../build.properties</file>\r
+                                                                                                               </files>\r
+                                                                                                       </configuration>\r
+                                                                                               </execution>\r
+                                                                                       </executions>\r
+                                                                               </plugin>\r
+                     <plugin>\r
                         <groupId>org.codehaus.mojo</groupId>\r
                         <artifactId>hibernate3-maven-plugin</artifactId>\r
                         <version>2.2</version>\r
                             <dependency>\r
                                 <groupId>mysql</groupId>\r
                                 <artifactId>mysql-connector-java</artifactId>\r
-                                <version>5.1.5</version>\r
+                                                                                                                               <!-- <version>5.1.5</version> -->\r
                             </dependency>\r
-                        </dependencies>\r
+                                                                                                               <dependency>\r
+                                                                                                                               <groupId>postgresql</groupId>\r
+                                                                                                                               <artifactId>postgresql</artifactId>\r
+                                                                                                                               <!-- <version>8.4-702.jdbc4</version> -->\r
+                                                                                                               </dependency>\r
+                         </dependencies>\r
                     </plugin>\r
                     <plugin>\r
                         <artifactId>maven-antrun-plugin</artifactId>\r
                                 <phase>process-test-resources</phase>\r
                                 <configuration>\r
                                     <tasks>\r
-                                        <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${sql.file}"/>\r
+                                        <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${db}/${sql.file}"/>\r
                                     </tasks>\r
                                 </configuration>\r
                                 <goals>\r
diff --git a/services/authentication/pstore/src/main/resources/db/postgresql/README.txt b/services/authentication/pstore/src/main/resources/db/postgresql/README.txt
new file mode 100644 (file)
index 0000000..4967d1a
--- /dev/null
@@ -0,0 +1,11 @@
+The file authentication.sql is basically generated by the gen_ddl ant target.\r
+\r
+However, you must modify the result of that to make the \r
+\r
+  DROP TABLE \r
+\r
+statements be \r
+  \r
+  DROP TABLE IF EXISTS table \r
+\r
+This ensures that first time setup does not fail.\r
diff --git a/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql b/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql
new file mode 100644 (file)
index 0000000..7aff0f0
--- /dev/null
@@ -0,0 +1,2 @@
+DROP TABLE IF EXISTS users;
+create table users (username varchar(128) not null, created_at timestamp not null, passwd varchar(128) not null, updated_at timestamp, primary key (username));
index e50ee41ef02369ddd9aece73a6245133cda0f199..07e93d7dd37a46b64d106f4d1ee2c9a5c4f3fcf7 100644 (file)
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
         </dependency>\r
-        <dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
+                               </dependency>\r
+         <dependency>\r
             <groupId>javax.persistence</groupId>\r
             <artifactId>persistence-api</artifactId>\r
         </dependency>\r
index a7ea28dae27448b12ff93bd64ab5c587fd54f12e..b3ca631af8afd22b67c41f16679ea65f2e709151 100644 (file)
             <artifactId>mysql-connector-java</artifactId>\r
             <scope>test</scope>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>postgresql</groupId>\r
+            <artifactId>postgresql</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
     </dependencies>\r
 \r
     <build>\r
index f328d3d413f5c22733cf260b012d9df8265299bc..03eb51d47e3f4391a52e5e4ad1a4d3fc53dbe74b 100644 (file)
         <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.jboss.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
         <copy tofile="${dest.hibernate.cfg}" file="${src.hibernate.cfg}" filtering="true"/>\r
         <copy tofile="${dest.appContext.cfg}" file="${src.appContext.cfg}" filtering="true"/>\r
     </target>\r
index ccbc9679c36caf5daedaa2ae520ac31e01f731c3..f6206d5f2cdd53410c1d9cff4e813349f6184039 100644 (file)
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
         </dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
+                               </dependency>\r
         <dependency>\r
             <groupId>ch.elca.el4j.modules</groupId>\r
             <artifactId>module-xml_merge-common</artifactId>\r
 \r
     <build>\r
         <finalName>cspace-services-authorization-mgt-import</finalName>\r
+                               <filters>\r
+                                       <filter>../../../build.properties</filter>\r
+                               </filters>\r
+                               <resources>\r
+                                       <resource>\r
+                                               <directory>src/main/resources</directory>\r
+                                               <filtering>true</filtering>\r
+                                       </resource>\r
+                               </resources>\r
         <plugins>\r
+                                       <plugin>\r
+                                               <groupId>org.apache.maven.plugins</groupId>\r
+                                               <artifactId>maven-resources-plugin</artifactId>\r
+                                               <version>2.5</version>\r
+                                               <executions>\r
+                                                       <execution>\r
+                                                               <phase>process-resources</phase>\r
+                                                               <goals>\r
+                                                                       <goal>resources</goal>\r
+                                                               </goals>\r
+                                                       </execution>\r
+                                               </executions>\r
+                                       </plugin>\r
             <plugin>\r
                 <groupId>org.codehaus.mojo</groupId>\r
                 <artifactId>exec-maven-plugin</artifactId>\r
                         <argument>-p</argument>\r
                         <argument>does_not_matter</argument>\r
                         <argument>-b</argument>\r
+                                                                                               <!-- This should be (Needs testing):\r
+                                                                                               <argument>${jboss.server.cspace}</argument>\r
+                                                                                               -->\r
                         <argument>${basedir}/../../common/src/main</argument>\r
                         <argument>-edir</argument>\r
                         <argument>${basedir}/target</argument>\r
                     <dependency>\r
                         <groupId>mysql</groupId>\r
                         <artifactId>mysql-connector-java</artifactId>\r
-                        <version>5.1.5</version>\r
+                                                                                               <version>5.1.5</version>\r
                     </dependency>\r
+                                                                               <dependency>\r
+                                                                                               <groupId>postgresql</groupId>\r
+                                                                                               <artifactId>postgresql</artifactId>\r
+                                                                                               <version>8.4-702.jdbc4</version>\r
+                                                                               </dependency>\r
                 </dependencies>\r
             </plugin>\r
         </plugins>\r
index c203f80df16fd4f99fb91f846060f6da59f43121..aa974c52ceaaf9c5492d16cb764fdb333c97c9cd 100644 (file)
@@ -366,8 +366,8 @@ public class AuthorizationGen {
                    rv.setRoleId(role.getCsid());
                    roleValues.add(rv);
                } else {
-                       if (logger.isDebugEnabled() == true) {
-                               logger.debug("Role and Permission tenant ID did not match."); //FIXME: REM - Remove this debug statement.
+                       if (logger.isTraceEnabled() == true) {
+                               logger.trace("Role and Permission tenant ID did not match."); //FIXME: REM - Remove this debug statement.
                        }
                }
         }
index f394cefdca93fd7419ae25dd3b7a96f682f52d1b..7818a18101c0c2b4fe565a89bd6a4712d94192f7 100644 (file)
@@ -31,9 +31,9 @@
         <constructor-arg ref="dataSource"/>
         <constructor-arg ref="lookupStrategy"/>
         <constructor-arg ref="aclCache"/>
-        <property name="classIdentityQuery" value="SELECT @@IDENTITY"/>
-        <property name="sidIdentityQuery" value="SELECT @@IDENTITY"/>
-    </bean>
+        <property name="classIdentityQuery" value="@CLASS_ID_QUERY@"/>
+        <property name="sidIdentityQuery" value="@SID_ID_QUERY@"/>
+     </bean>
 
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
         <property name="driverClassName" value="@DB_DRIVER_CLASS@"/>
index d63b73452ada7a1a90ab810186b8996f6819877f..31fa27fb4755949ed6945a99b157b6fa55161667 100644 (file)
@@ -13,7 +13,7 @@
     <name>services.authorization.pstore</name>\r
     <properties>\r
         <sql.file>authorization.sql</sql.file>\r
-        <sql.dir>${basedir}/src/main/resources/db/mysql</sql.dir>\r
+        <sql.dir>${basedir}/src/main/resources/db</sql.dir>\r
     </properties>\r
     <dependencies>\r
         <dependency>\r
         <dependency>\r
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
+        </dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
         </dependency>\r
     </dependencies>\r
 \r
             <id>ddl</id>\r
             <build>\r
                 <plugins>\r
-                    <plugin>\r
+                                                                               <plugin>\r
+                                                                                       <groupId>org.codehaus.mojo</groupId>\r
+                                                                                       <artifactId>properties-maven-plugin</artifactId>\r
+                                                                                       <version>1.0-alpha-2</version>\r
+                                                                                       <executions>\r
+                                                                                               <execution>\r
+                                                                                                       <phase>initialize</phase>\r
+                                                                                                       <goals>\r
+                                                                                                               <goal>read-project-properties</goal>\r
+                                                                                                       </goals>\r
+                                                                                                       <configuration>\r
+                                                                                                               <files>\r
+                                                                                                                       <file>${basedir}/../../../build.properties</file>\r
+                                                                                                               </files>\r
+                                                                                                       </configuration>\r
+                                                                                               </execution>\r
+                                                                                       </executions>\r
+                                                                               </plugin>\r
+                     <plugin>\r
                         <groupId>org.codehaus.mojo</groupId>\r
                         <artifactId>hibernate3-maven-plugin</artifactId>\r
                         <version>2.2</version>\r
                             <dependency>\r
                                 <groupId>mysql</groupId>\r
                                 <artifactId>mysql-connector-java</artifactId>\r
-                                <version>5.1.5</version>\r
+                                                                                                                               <!-- <version>5.1.5</version> -->\r
                             </dependency>\r
-                        </dependencies>\r
+                                                                                                               <dependency>\r
+                                                                                                                               <groupId>postgresql</groupId>\r
+                                                                                                                               <artifactId>postgresql</artifactId>\r
+                                                                                                                               <!-- <version>8.4-702.jdbc4</version> -->\r
+                                                                                                               </dependency>\r
+                         </dependencies>\r
                     </plugin>\r
                     <plugin>\r
                         <artifactId>maven-antrun-plugin</artifactId>\r
                                 <phase>process-test-resources</phase>\r
                                 <configuration>\r
                                     <tasks>\r
-                                        <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${sql.file}" />\r
+                                                                                                                                                       <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${db}/${sql.file}"/>\r
                                     </tasks>\r
                                 </configuration>\r
                                 <goals>\r
index a3a07cd16d74ae20952326d2b484bae82501636d..c84810e794a3d888bee88a89ae9633fbeb852e67 100644 (file)
@@ -4,7 +4,7 @@
 -- You may not use this file except in compliance with this License.
 --
 
-use cspace;
+-- use cspace;
 drop table if exists `acl_entry`;
 drop table if exists `acl_object_identity`;
 drop table if exists `acl_sid`;
@@ -14,7 +14,7 @@ drop table if exists `acl_class`;
 -- Table structure for table `acl_class`
 --
 
-CREATE TABLE IF NOT EXISTS `acl_class` (
+CREATE TABLE `acl_class` (
   `id` bigint(20) NOT NULL auto_increment,
   `class` varchar(100) NOT NULL,
   PRIMARY KEY  (`id`),
@@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS `acl_class` (
 -- Table structure for table `acl_sid`
 --
 
-CREATE TABLE IF NOT EXISTS `acl_sid` (
+CREATE TABLE `acl_sid` (
   `id` bigint(20) NOT NULL auto_increment,
   `principal` tinyint(1) NOT NULL,
   `sid` varchar(100) NOT NULL,
@@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `acl_sid` (
 -- Table structure for table `acl_entry`
 --
 
-CREATE TABLE IF NOT EXISTS `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,
@@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `acl_entry` (
 -- Table structure for table `acl_object_identity`
 --
 
-CREATE TABLE IF NOT EXISTS `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,
index 7f5fdd70e3c6273a20aa5d8cd9ba985246aa582c..3c05b7dec3c4a0bc34f2e22e18102a528b846789 100644 (file)
@@ -3,7 +3,7 @@
 -- Licensed under the Educational Community License (ECL), Version 2.0.
 -- You may not use this file except in compliance with this License.
 --
-use cspace;
+-- 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);
diff --git a/services/authorization/pstore/src/main/resources/db/postgresql/README.txt b/services/authorization/pstore/src/main/resources/db/postgresql/README.txt
new file mode 100644 (file)
index 0000000..b9cf6f8
--- /dev/null
@@ -0,0 +1,32 @@
+The file authorization.sql is basically generated by the gen_ddl ant target.\r
+However, you must modify the result of that to make the \r
+\r
+  DROP TABLE \r
+\r
+statements be \r
+  \r
+  DROP TABLE IF EXISTS table CASCADE \r
+\r
+This ensures that first time setup does not fail, and that later invocations\r
+can deal with dependencies.\r
+\r
+You must also make the\r
+\r
+  DROP SEQUENCE \r
+\r
+statements be \r
+\r
+  DROP SEQUENCE IF EXISTS\r
+\r
+for similar reasons.\r
+\r
+You must also remove (comment out) the statement (which is superfluous with the CASCADE above):\r
+\r
+  alter table permissions_actions drop constraint FK85F82042E2DC84FD;\r
+\r
+When using the account_tenants table on insert, you have to specify "nextval('hibernate_sequence')" \r
+as the value for the HJID column. \r
+\r
+Note that because of the way gen_ddl does its work per-sub-project, there is a single shared\r
+sequence for both this and the authorization.sql script. This should be okay, even if it does\r
+create gaps in what would be a nice sequence for each table.\r
diff --git a/services/authorization/pstore/src/main/resources/db/postgresql/acl.sql b/services/authorization/pstore/src/main/resources/db/postgresql/acl.sql
new file mode 100644 (file)
index 0000000..41f9276
--- /dev/null
@@ -0,0 +1,66 @@
+--
+-- 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 bigserial not null primary key,
+  class varchar(100) not null,
+  constraint unique_uk_2 unique(class)
+);
+
+
+--
+-- Table structure for table acl_sid
+--
+CREATE TABLE acl_sid(
+  id bigserial not null primary key,
+  principal boolean not null,
+  sid varchar(100) not null,
+  constraint unique_uk_1 unique(sid,principal)
+);
+
+--
+-- Table structure for table acl_object_identity
+--
+CREATE TABLE acl_object_identity(
+  id bigserial primary key,
+  object_id_class bigint not null,
+  object_id_identity bigint not null,
+  parent_object bigint,
+  owner_sid bigint,
+  entries_inheriting boolean not null,
+  constraint unique_uk_3 unique(object_id_class,object_id_identity),
+  constraint acl_obj_id_ibfk_1 foreign key(parent_object) references acl_object_identity(id),
+  constraint acl_obj_id_ibfk_2 foreign key(object_id_class) references acl_class(id),
+  constraint acl_obj_id_ibfk_3 foreign key(owner_sid) references acl_sid(id)
+);
+
+--
+-- Table structure for table acl_entry
+--
+CREATE TABLE acl_entry(
+  id bigserial primary key,
+  acl_object_identity bigint not null,
+  ace_order int not null,
+  sid bigint not null,
+  mask integer not null,
+  granting boolean not null,
+  audit_success boolean not null,
+  audit_failure boolean not null,
+  constraint unique_uk_4 unique(acl_object_identity,ace_order),
+  constraint acl_entry_ibfk_1 foreign key(acl_object_identity)
+      references acl_object_identity(id),
+  constraint acl_entry_ibfk_2 foreign key(sid) references acl_sid(id)
+);
+
diff --git a/services/authorization/pstore/src/main/resources/db/postgresql/authorization.sql b/services/authorization/pstore/src/main/resources/db/postgresql/authorization.sql
new file mode 100644 (file)
index 0000000..cdde3c9
--- /dev/null
@@ -0,0 +1,14 @@
+-- alter table permissions_actions drop constraint FK85F82042E2DC84FD;
+DROP TABLE IF EXISTS accounts_roles CASCADE;
+DROP TABLE IF EXISTS permissions CASCADE;
+DROP TABLE IF EXISTS permissions_actions CASCADE;
+DROP TABLE IF EXISTS permissions_roles CASCADE;
+DROP TABLE IF EXISTS roles CASCADE;
+DROP SEQUENCE IF EXISTS hibernate_sequence;
+create table accounts_roles (HJID int8 not null, account_id varchar(128) not null, created_at timestamp 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 timestamp not null, description varchar(255), effect varchar(32) not null, resource_name varchar(128) not null, tenant_id varchar(128) not null, updated_at timestamp, primary key (csid));
+create table permissions_actions (HJID int8 not null, name varchar(128) not null, objectIdentity varchar(128) not null, objectIdentityResource varchar(128) not null, ACTIONS_PERMISSION_CSID varchar(128), primary key (HJID));
+create table permissions_roles (HJID int8 not null, actionGroup varchar(255), created_at timestamp 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 timestamp not null, description varchar(255), displayname varchar(200) not null, rolegroup varchar(255), rolename varchar(200) not null, tenant_id varchar(128) not null, updated_at timestamp, primary key (csid), unique (rolename, tenant_id), unique (displayname, tenant_id));
+alter table permissions_actions add constraint FK85F82042E2DC84FD foreign key (ACTIONS_PERMISSION_CSID) references permissions;
+create sequence hibernate_sequence;
diff --git a/services/authorization/pstore/src/main/resources/db/postgresql/authorization_index.sql b/services/authorization/pstore/src/main/resources/db/postgresql/authorization_index.sql
new file mode 100644 (file)
index 0000000..63b46ef
--- /dev/null
@@ -0,0 +1,17 @@
+--
+-- 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_acct_role_id ON accounts_roles (role_id);
+
+CREATE INDEX index_permission_id ON permissions_roles (permission_id);
+CREATE INDEX index_perm_role_id ON permissions_roles (role_id);
+
index 0d51c7db4fd88be58c59ec175a6985e0d91d5117..4e9b9b116849eac35a3b290d544eb0196531955a 100644 (file)
             <artifactId>mysql-connector-java</artifactId>
             <scope>test</scope>
         </dependency>
+                               <dependency>
+                                               <groupId>postgresql</groupId>
+                                               <artifactId>postgresql</artifactId>
+            <scope>test</scope>
+                               </dependency>
 
         <dependency>
             <groupId>org.collectionspace.services</groupId>
 
     <build>
         <finalName>cspace-services-authz</finalName>
-        <plugins>
-
-        </plugins>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.apache.maven.plugins</groupId>
+                                               <artifactId>maven-resources-plugin</artifactId>
+                                               <version>2.5</version>
+                                               <executions>
+                                                       <execution>
+                                                               <phase>process-resources</phase>
+                                                               <goals>
+                                                                       <goal>resources</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                               <filters>
+                                       <filter>../../../build.properties</filter>
+                               </filters>
+                               <resources>
+                                       <resource>
+                                               <directory>src/main/resources</directory>
+                                               <filtering>true</filtering>
+                                       </resource>
+                               </resources>
     </build>
 </project>
index ad3c750c24948f32c71b3f6c301bc0939556a526..49d568cebca2dc30722231cda148b5b4d14b5f20 100644 (file)
@@ -30,8 +30,9 @@
         <constructor-arg ref="dataSource"/>
         <constructor-arg ref="lookupStrategy"/>
         <constructor-arg ref="aclCache"/>
-        <property name="classIdentityQuery" value="SELECT @@IDENTITY"/>
-        <property name="sidIdentityQuery" value="SELECT @@IDENTITY"/>
+        <!-- Set query properties for the ${db} db variant -->
+        <property name="classIdentityQuery" value="${db.spring.acl.classIdentityQuery}"/>
+        <property name="sidIdentityQuery" value="${db.spring.acl.sidIdentityQuery}"/>
     </bean>
 
     <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
index ee8b42708366388567f4ac103cab5c0e28cd293e..7775b8363d52fe65333e884531bd0c7c44746de9 100644 (file)
@@ -32,12 +32,12 @@ public interface IQueryManager {
        final static String SEARCH_GROUP_CLOSE = ")";\r
        final static String SEARCH_TERM_SEPARATOR = " ";\r
        final static String SEARCH_LIKE = " LIKE ";\r
+       final static String SEARCH_ILIKE = " ILIKE ";\r
     final static String SEARCH_TYPE_KEYWORDS = "keywords";\r
     final static String SEARCH_TYPE_KEYWORDS_KW = "kw";\r
     final static String SEARCH_TYPE_PARTIALTERM = "pt";\r
     final static String SEARCH_TYPE_DOCTYPE = "doctype";\r
     final static String SEARCH_TYPE_INVOCATION = "inv";\r
-       final static String ECM_FULLTEXT_LIKE = "ecm:fulltext" + SEARCH_TERM_SEPARATOR + SEARCH_LIKE;\r
        final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR;\r
        final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR;\r
 \r
index 34a1d5bcf017251efa61fbffc5953a3b4a04d657..be731bd35a11779fab54c4b1409415c739b056b7 100644 (file)
             <groupId>mysql</groupId>\r
             <artifactId>mysql-connector-java</artifactId>\r
         </dependency>\r
-        <dependency>\r
+                               <dependency>\r
+                                               <groupId>postgresql</groupId>\r
+                                               <artifactId>postgresql</artifactId>\r
+                               </dependency>\r
+         <dependency>\r
             <groupId>javax.persistence</groupId>\r
             <artifactId>persistence-api</artifactId>\r
         </dependency>\r
index 2ed6c5170583d6079f54ed7abad4b6bc6c743cdc..035f41361e1e5b2ef460778512e67e00a01a2ac4 100644 (file)
         <service:classname>org.collectionspace.services.common.init.ModifyFieldDatatypes</service:classname>
         <service:params>
           <service:field>
-            <service:table>nuxeo.collectionobjects_common_briefdescriptions</service:table>
+            <service:table>collectionobjects_common_briefdescriptions</service:table>
             <service:col>item</service:col>
             <service:type>LARGETEXT</service:type>
             <service:param />
           </service:field>
           <service:field>
-            <service:table>nuxeo.collectionobjects_common_comments</service:table>
+            <service:table>collectionobjects_common_comments</service:table>
             <service:col>item</service:col>
             <service:type>LARGETEXT</service:type>
             <service:param />
           </service:field>
           <service:field>
-            <service:table>nuxeo.collectionobjects_common_objectproductionreasons</service:table>
+            <service:table>collectionobjects_common_objectproductionreasons</service:table>
             <service:col>item</service:col>
             <service:type>LARGETEXT</service:type>
             <service:param />
           </service:field>
           <service:field>
-            <service:table>nuxeo.collectionobjects_common_ownersreferences</service:table>
+            <service:table>collectionobjects_common_ownersreferences</service:table>
             <service:col>item</service:col>
             <service:type>LARGETEXT</service:type>
             <service:param />
           </service:field>
           <service:field>
-            <service:table>nuxeo.collectionobjects_common_viewersreferences</service:table>
+            <service:table>collectionobjects_common_viewersreferences</service:table>
             <service:col>item</service:col>
             <service:type>LARGETEXT</service:type>
             <service:param />
index c0dd989d4080b8e1ffa2e9d17c008192f1b0e8b0..a4a5902c8cf708605a1756c08d915e76017ef69a 100644 (file)
@@ -21,6 +21,7 @@ import org.collectionspace.services.common.init.IInitHandler;
 import org.collectionspace.services.common.security.SecurityUtils;\r
 import org.collectionspace.services.common.service.*;\r
 import org.collectionspace.services.common.storage.JDBCTools;\r
+import org.collectionspace.services.common.storage.DatabaseProductType;\r
 import org.collectionspace.services.common.tenant.TenantBindingType;\r
 import org.collectionspace.services.common.types.PropertyItemType;\r
 import org.collectionspace.services.common.types.PropertyType;\r
@@ -56,10 +57,6 @@ public class ServiceMain {
     private static final String DEFAULT_ADMIN_PASSWORD = "Administrator";\r
     private static final String DEFAULT_READER_PASSWORD = "reader";\r
     \r
-    public static final String NUXEO_REPOSITORY_NAME = "NuxeoDS";\r
-    public static final String CSPACE_REPOSITORY_NAME = "CspaceDS";\r
-    public static final String DEFAULT_REPOSITORY_NAME = CSPACE_REPOSITORY_NAME;\r
-\r
     private ServiceMain() {\r
        //empty\r
     }\r
@@ -176,7 +173,7 @@ public class ServiceMain {
                conn = getConnection();\r
                // First find or create the tenants\r
                String queryTenantSQL = \r
-                       "SELECT `id`,`name` FROM `tenants`";\r
+                       "SELECT id,name FROM tenants";\r
                stmt = conn.createStatement();\r
                        ResultSet rs = stmt.executeQuery(queryTenantSQL);\r
                ArrayList<String> existingTenants = new ArrayList<String>();\r
@@ -195,7 +192,7 @@ public class ServiceMain {
                        rs.close();\r
 \r
                String insertTenantSQL = \r
-                       "INSERT INTO `tenants` (`id`,`name`,`created_at`) VALUES (?,?, now())";\r
+                       "INSERT INTO tenants (id,name,created_at) VALUES (?,?, now())";\r
                pstmt = conn.prepareStatement(insertTenantSQL); // create a statement\r
                for(String tId : tenantInfo.keySet()) {\r
                        if(existingTenants.contains(tId)) {\r
@@ -215,8 +212,8 @@ public class ServiceMain {
                pstmt.close();\r
                // Second find or create the users\r
                String queryUserSQL = \r
-                       "SELECT `username` FROM `users` WHERE `username` LIKE '"\r
-                               +TENANT_ADMIN_ACCT_PREFIX+"%' OR `username` LIKE '"\r
+                       "SELECT username FROM users WHERE username LIKE '"\r
+                               +TENANT_ADMIN_ACCT_PREFIX+"%' OR username LIKE '"\r
                                +TENANT_READER_ACCT_PREFIX+"%'";\r
                        rs = stmt.executeQuery(queryUserSQL);\r
                ArrayList<String> usersInRepo = new ArrayList<String>();\r
@@ -226,7 +223,7 @@ public class ServiceMain {
                        }\r
                        rs.close();\r
                String insertUserSQL = \r
-                       "INSERT INTO `users` (`username`,`passwd`, `created_at`)"\r
+                       "INSERT INTO users (username,passwd, created_at)"\r
                        +" VALUES (?,?, now())";\r
                pstmt = conn.prepareStatement(insertUserSQL); // create a statement\r
                for(String tName : tenantInfo.values()) {\r
@@ -267,8 +264,8 @@ public class ServiceMain {
                // Third, create the accounts. Assume that if the users were already there,\r
                // then the accounts were as well\r
             String insertAccountSQL = \r
-               "INSERT INTO `accounts_common` "\r
-               + "(`csid`, `email`, `userid`, `status`, `screen_name`, `created_at`) "\r
+               "INSERT INTO accounts_common "\r
+               + "(csid, email, userid, status, screen_name, created_at) "\r
                + "VALUES (?,?,?,'ACTIVE',?, now())";\r
             Hashtable<String, String> tenantAdminAcctCSIDs = new Hashtable<String, String>();\r
             Hashtable<String, String> tenantReaderAcctCSIDs = new Hashtable<String, String>();\r
@@ -314,9 +311,19 @@ public class ServiceMain {
                pstmt.close();\r
                // Fourth, bind accounts to tenants. Assume that if the users were already there,\r
                // then the accounts were bound to tenants correctly\r
-            String insertAccountTenantSQL =\r
-               "INSERT INTO `accounts_tenants` (`TENANTS_ACCOUNTSCOMMON_CSID`,`tenant_id`) "\r
-               + "VALUES (?, ?)";\r
+               String insertAccountTenantSQL;\r
+               DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType();\r
+               if (databaseProductType == DatabaseProductType.MYSQL) {\r
+                       insertAccountTenantSQL =\r
+                               "INSERT INTO accounts_tenants (TENANTS_ACCOUNTSCOMMON_CSID,tenant_id) "\r
+                               + " VALUES(?, ?)";\r
+               } else if (databaseProductType == DatabaseProductType.POSTGRESQL) {\r
+                       insertAccountTenantSQL =\r
+                               "INSERT INTO accounts_tenants (HJID, TENANTS_ACCOUNTSCOMMON_CSID,tenant_id) "\r
+                               + " VALUES(nextval('hibernate_sequence'), ?, ?)";\r
+               } else {\r
+                       throw new Exception("Unrecognized database system.");\r
+               }\r
                pstmt = conn.prepareStatement(insertAccountTenantSQL); // create a statement\r
                for(String tId : tenantInfo.keySet()) {\r
                        String tName = tenantInfo.get(tId);\r
@@ -345,7 +352,7 @@ public class ServiceMain {
                // Fifth, fetch and save the default roles\r
                        String springAdminRoleCSID = null;\r
                String querySpringRole = \r
-                       "SELECT `csid` from `roles` WHERE `rolename`='"+SPRING_ADMIN_ROLE+"'";\r
+                       "SELECT csid from roles WHERE rolename='"+SPRING_ADMIN_ROLE+"'";\r
                        rs = stmt.executeQuery(querySpringRole);\r
                if(rs.next()) {\r
                        springAdminRoleCSID = rs.getString(1);\r
@@ -355,7 +362,7 @@ public class ServiceMain {
                }\r
                } else {\r
                 String insertSpringAdminRoleSQL =\r
-                       "INSERT INTO `roles` (`csid`, `rolename`, `displayName`, `rolegroup`, `created_at`, `tenant_id`) "\r
+                       "INSERT INTO roles (csid, rolename, displayName, rolegroup, created_at, tenant_id) "\r
                        + "VALUES ('-1', 'ROLE_SPRING_ADMIN', 'SPRING_ADMIN', 'Spring Security Administrator', now(), '0')";\r
                        stmt.executeUpdate(insertSpringAdminRoleSQL);\r
                        springAdminRoleCSID = "-1";\r
@@ -366,7 +373,7 @@ public class ServiceMain {
                }\r
                rs.close();\r
                String getRoleCSIDSql =\r
-                       "SELECT `csid` from `roles` WHERE `tenant_id`=? and `rolename`=?";\r
+                       "SELECT csid from roles WHERE tenant_id=? and rolename=?";\r
                pstmt = conn.prepareStatement(getRoleCSIDSql); // create a statement\r
                rs = null;\r
             Hashtable<String, String> tenantAdminRoleCSIDs = new Hashtable<String, String>();\r
@@ -408,9 +415,18 @@ public class ServiceMain {
                pstmt.close();\r
                // Sixth, bind the accounts to roles. If the users already existed,\r
                // we'll assume they were set up correctly.\r
-            String insertAccountRoleSQL =\r
-               "INSERT INTO `accounts_roles`(`account_id`, `user_id`, `role_id`, `role_name`, `created_at`)"\r
-               + " VALUES(?, ?, ?, ?, now())";\r
+                                       String insertAccountRoleSQL;\r
+                                       if (databaseProductType == DatabaseProductType.MYSQL) {\r
+                                               insertAccountRoleSQL =\r
+                                               "INSERT INTO accounts_roles(account_id, user_id, role_id, role_name, created_at)"\r
+                                                       +" VALUES(?, ?, ?, ?, now())";\r
+                                       } else if (databaseProductType == DatabaseProductType.POSTGRESQL) {\r
+                                               insertAccountRoleSQL =\r
+                                               "INSERT INTO accounts_roles(HJID, account_id, user_id, role_id, role_name, created_at)"\r
+                                                       +" VALUES(nextval('hibernate_sequence'), ?, ?, ?, ?, now())";\r
+                                       } else {\r
+                                                       throw new Exception("Unrecognized database system.");\r
+                                       }\r
                if (logger.isDebugEnabled()) {\r
                        logger.debug("createDefaultAccounts binding accounts to roles with SQL:\n"\r
                                        +insertAccountRoleSQL);\r
@@ -563,7 +579,7 @@ public class ServiceMain {
     }\r
 \r
     private Connection getConnection() throws LoginException, SQLException {\r
-        return JDBCTools.getConnection(DEFAULT_REPOSITORY_NAME);\r
+        return JDBCTools.getConnection(JDBCTools.CSPACE_REPOSITORY_NAME);\r
     }\r
 \r
     void retrieveAllWorkspaceIds() throws Exception {\r
index 529bc5f89154ac3b594f4502c2c3f139804feed2..59a78daf83e80a72cdd0c2f2d15251dccf0c9b46 100755 (executable)
@@ -140,7 +140,7 @@ public class AddIndices extends InitHandler implements IInitHandler {
                 //\r
                 // If this assumption is no longer valid, we might instead\r
                 // identify the relevant repository from the table name here.\r
-                rows = JDBCTools.executeUpdate(sql, JDBCTools.getNuxeoRepositoryName());\r
+                rows = JDBCTools.executeUpdate(JDBCTools.NUXEO_REPOSITORY_NAME, sql);\r
                 logger.trace("Index added to column ("+columnName+") on table ("+tableName+")");\r
             }\r
             return rows;\r
@@ -184,7 +184,7 @@ public class AddIndices extends InitHandler implements IInitHandler {
         }\r
 \r
         try {\r
-            // Assumes indicies will only be created at post-init time\r
+            // Assumes indices will only be created at post-init time\r
             // for the Nuxeo repository.\r
             // \r
             // To date, for the CSpace repository, indices have typically been\r
@@ -193,7 +193,7 @@ public class AddIndices extends InitHandler implements IInitHandler {
             //\r
             // If this assumption is no longer valid, we might instead\r
             // identify the relevant repository from the table name here.\r
-            conn = JDBCTools.getConnection(JDBCTools.getNuxeoRepositoryName());\r
+            conn = JDBCTools.getConnection(JDBCTools.NUXEO_REPOSITORY_NAME);\r
             stmt = conn.createStatement();\r
             rs = stmt.executeQuery(sql);\r
             if (rs.last()) {\r
index d2638f0dfb5437b96f14129446d31045e0a08b98..701cacd97d9adf39107b425d0a7893b54f05a11c 100644 (file)
@@ -74,11 +74,13 @@ public class ModifyFieldDatatypes extends InitHandler implements IInitHandler {
                 if (databaseProductType == DatabaseProductType.MYSQL) {
                     logger.info("Modifying field " + field.getTable() + "."
                             + field.getCol() + " to datatype " + datatype);
-                    sql = "ALTER TABLE " + field.getTable() + " MODIFY COLUMN " + field.getCol() + " " + datatype;
+                    sql = "ALTER TABLE " + field.getTable() + " MODIFY COLUMN " 
+                               + field.getCol() + " " + datatype;
                 } else if (databaseProductType == DatabaseProductType.POSTGRESQL) {
                     logger.info("Modifying field " + field.getTable() + "."
                             + field.getCol() + " to datatype " + datatype);
-                    sql = "ALTER TABLE " + field.getTable() + " ALTER COLUMN " + field.getCol() + " " + datatype;
+                    sql = "ALTER TABLE " + field.getTable() + " ALTER COLUMN " 
+                               + field.getCol() + " TYPE " + datatype;
                 } else {
                     throw new Exception("Unrecognized database system.");
                 }
@@ -91,7 +93,7 @@ public class ModifyFieldDatatypes extends InitHandler implements IInitHandler {
                 //
                 // If this assumption is no longer valid, we might instead
                 // identify the relevant repository from the table name here.
-                rows = JDBCTools.executeUpdate(sql, JDBCTools.getNuxeoRepositoryName());
+                rows = JDBCTools.executeUpdate(JDBCTools.NUXEO_REPOSITORY_NAME, sql);
             }
         } catch (Exception e) {
             throw e;
@@ -147,7 +149,7 @@ public class ModifyFieldDatatypes extends InitHandler implements IInitHandler {
         }
 
         try {
-            conn = JDBCTools.getConnection(JDBCTools.getNuxeoRepositoryName());
+            conn = JDBCTools.getConnection(JDBCTools.NUXEO_REPOSITORY_NAME);
             stmt = conn.createStatement();
             rs = stmt.executeQuery(sql);
             while (rs.next()) {
index dec09948a2ee8018874327867ea18f9492f42084..9d268b0f3d3acba484c91800110a0eb5ab471af4 100644 (file)
@@ -39,9 +39,15 @@ import org.nuxeo.ecm.core.client.NuxeoClient;
 import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
 import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;\r
 import org.collectionspace.services.client.IQueryManager;\r
+import org.collectionspace.services.common.storage.DatabaseProductType;\r
+import org.collectionspace.services.common.storage.JDBCTools;\r
 \r
 public class QueryManagerNuxeoImpl implements IQueryManager {\r
        \r
+       private static String ECM_FULLTEXT_LIKE = \r
+               "ecm:fulltext" + SEARCH_TERM_SEPARATOR + IQueryManager.SEARCH_LIKE;\r
+       private static String SEARCH_LIKE_FORM = null;\r
+\r
        private final Logger logger = LoggerFactory\r
                        .getLogger(QueryManagerNuxeoImpl.class);\r
        \r
@@ -49,6 +55,22 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
        private static Pattern nonWordChars = Pattern.compile("[^\\p{L}\\p{M}\\p{N}_']");\r
        private static Pattern unescapedDblQuotes = Pattern.compile("(?<!\\\\)\"");\r
        private static Pattern unescapedSingleQuote = Pattern.compile("(?<!\\\\)'");\r
+       \r
+       private static String getLikeForm() {\r
+               if(SEARCH_LIKE_FORM == null) {\r
+                       try {\r
+                               DatabaseProductType type = JDBCTools.getDatabaseProductType();\r
+                               if(type == DatabaseProductType.MYSQL) {\r
+                                       SEARCH_LIKE_FORM = IQueryManager.SEARCH_LIKE;\r
+                               } else if(type == DatabaseProductType.POSTGRESQL) {\r
+                                       SEARCH_LIKE_FORM = IQueryManager.SEARCH_ILIKE;\r
+                               }\r
+                       } catch (Exception e) {\r
+                               SEARCH_LIKE_FORM = IQueryManager.SEARCH_LIKE;\r
+                       }\r
+               }\r
+               return SEARCH_LIKE_FORM;\r
+       }\r
 \r
        //TODO: This is currently just an example fixed query.  This should eventually be\r
        // removed or replaced with a more generic method.\r
@@ -153,7 +175,7 @@ public class QueryManagerNuxeoImpl implements IQueryManager {
                        throw new RuntimeException("No match field specified.");\r
                }\r
                String ptClause = field\r
-                       + IQueryManager.SEARCH_LIKE\r
+                       + getLikeForm()\r
                        + "'%" + unescapedSingleQuote.matcher(trimmed).replaceAll("\\\\'") + "%'";\r
                return ptClause;\r
        }\r
index b29914a30c3990169bae6a39a088b4208577b875..e145b2ef548eec51b828a358beffaaacf4b60c71 100755 (executable)
@@ -38,12 +38,17 @@ import java.sql.Statement;
  * $LastChangedDate:  $\r
  */\r
 public class JDBCTools {\r
+    public static String CSPACE_REPOSITORY_NAME = "CspaceDS";\r
+    public static String NUXEO_REPOSITORY_NAME = "NuxeoDS";\r
+    public static String DEFAULT_REPOSITORY_NAME = NUXEO_REPOSITORY_NAME;\r
+    private static String DBProductName = null;\r
+    private static DatabaseProductType DBProductType = DatabaseProductType.UNRECOGNIZED;\r
 \r
     //todo: make sure this will get instantiated in the right order\r
     final static Logger logger = LoggerFactory.getLogger(JDBCTools.class);\r
 \r
     public static Connection getConnection(String repositoryName) throws LoginException, SQLException {\r
-        if (Tools.isBlank(repositoryName)) {\r
+        if (Tools.isEmpty(repositoryName)) {\r
             repositoryName = getDefaultRepositoryName();\r
         }\r
         InitialContext ctx = null;\r
@@ -72,19 +77,13 @@ public class JDBCTools {
             }\r
         }\r
     }\r
-    \r
-    public static ResultSet executeQuery(String sql) throws Exception {\r
-        return executeQuery(sql, getDefaultRepositoryName());\r
-    }\r
 \r
-    public static ResultSet executeQuery(String sql, String repositoryName) throws Exception {\r
+\r
+    public static ResultSet executeQuery(String repoName, String sql) throws Exception {\r
         Connection conn = null;\r
         Statement stmt = null;\r
         try {\r
-            if (Tools.isBlank(repositoryName)) {\r
-                repositoryName = getDefaultRepositoryName();\r
-            }\r
-            conn = getConnection(repositoryName);\r
+            conn = getConnection(repoName);    // If null, uses default\r
             stmt = conn.createStatement();\r
             ResultSet rs = stmt.executeQuery(sql);\r
             stmt.close();\r
@@ -110,19 +109,12 @@ public class JDBCTools {
             }\r
         }\r
     }\r
-    \r
-    public static int executeUpdate(String sql) throws Exception {\r
-        return executeUpdate(sql, getDefaultRepositoryName());\r
-    }\r
 \r
-    public static int executeUpdate(String sql, String repositoryName) throws Exception {\r
+    public static int executeUpdate(String repoName, String sql) throws Exception {\r
         Connection conn = null;\r
         Statement stmt = null;\r
         try {\r
-            if (Tools.isBlank(repositoryName)) {\r
-                repositoryName = getDefaultRepositoryName();\r
-            }\r
-            conn = getConnection(repositoryName);\r
+            conn = getConnection(repoName);    // If null, uses default\r
             stmt = conn.createStatement();\r
             int rows = stmt.executeUpdate(sql);\r
             stmt.close();\r
@@ -169,23 +161,24 @@ public class JDBCTools {
      * @return the database product name\r
      */\r
     public static String getDatabaseProductName() {\r
-        String productName = "";\r
-        Connection conn = null;\r
-        try {\r
-            conn = getConnection(getDefaultRepositoryName());\r
-            productName = conn.getMetaData().getDatabaseProductName();\r
-        } catch (Exception e) {\r
-        } finally {\r
-            try {\r
-                if (conn != null) {\r
-                    conn.close();\r
-                }\r
-            } catch (SQLException sqle) {\r
-                logger.debug("SQL Exception closing statement/connection in getDatabaseProductName: " + sqle.getLocalizedMessage());\r
-                return productName;\r
-            }\r
-        }\r
-        return productName;\r
+       if(DBProductName==null) {\r
+               Connection conn = null;\r
+               try {\r
+                   conn = getConnection(getDefaultRepositoryName());\r
+                   DBProductName = conn.getMetaData().getDatabaseProductName();\r
+               } catch (Exception e) {\r
+               } finally {\r
+                   try {\r
+                       if (conn != null) {\r
+                           conn.close();\r
+                       }\r
+                   } catch (SQLException sqle) {\r
+                       logger.debug("SQL Exception closing statement/connection in getDatabaseProductName: "\r
+                                       + sqle.getLocalizedMessage());\r
+                   }\r
+               }\r
+       }\r
+        return DBProductName;\r
     }\r
 \r
     /**\r
@@ -196,24 +189,22 @@ public class JDBCTools {
      * @throws Exception \r
      */\r
     public static DatabaseProductType getDatabaseProductType() throws Exception {\r
-        DatabaseProductType productType = DatabaseProductType.UNRECOGNIZED;\r
-        String productName = getDatabaseProductName();\r
-        if (productName.matches("(?i).*mysql.*")) {\r
-            productType = DatabaseProductType.MYSQL;\r
-        } else if (productName.matches("(?i).*postgresql.*")) {\r
-            productType = DatabaseProductType.POSTGRESQL;\r
-        } else {\r
-            throw new Exception("Unrecognized database system " + productName);\r
-        }\r
-        return productType;\r
+       if(DBProductType == DatabaseProductType.UNRECOGNIZED) {\r
+               String productName = getDatabaseProductName();\r
+               if (productName.matches("(?i).*mysql.*")) {\r
+                       DBProductType = DatabaseProductType.MYSQL;\r
+               } else if (productName.matches("(?i).*postgresql.*")) {\r
+                       DBProductType = DatabaseProductType.POSTGRESQL;\r
+               } else {\r
+                   throw new Exception("Unrecognized database system " \r
+                                                       + productName);\r
+               }\r
+       }\r
+        return DBProductType;\r
     }\r
 \r
     public static String getDefaultRepositoryName() {\r
-        return ServiceMain.DEFAULT_REPOSITORY_NAME;\r
-    }\r
-    \r
-    public static String getNuxeoRepositoryName() {\r
-        return ServiceMain.NUXEO_REPOSITORY_NAME;\r
+        return DEFAULT_REPOSITORY_NAME;\r
     }\r
 \r
     /**\r
@@ -233,4 +224,5 @@ public class JDBCTools {
             System.out.println("database url=" + metadata.getURL());\r
         }\r
     }\r
+               \r
 }\r
index 468369f63f3dbe948cf8bfe48027687df173bd45..2f9037fc3b2293d6d35ca3b838e71fab57456dc9 100644 (file)
@@ -166,6 +166,43 @@ public class JpaStorageUtils {
        return result;
     }
     
+    private static AccountValue getAccountValue(String csid)
+       throws DocumentNotFoundException  {
+
+       try {
+               //
+               // If the CSID is null then return the currently logged in user's ID
+               //
+               String whereClause;
+               HashMap<String, Object> params = new HashMap<String, Object>();
+               if (csid.equals(CS_CURRENT_USER) == true) {
+                       whereClause = "where userId = :userId";
+                       params.put("userId", AuthN.get().getUserId());
+               } else {
+                       whereClause = "where csid = :csid";
+                       params.put("csid", csid);
+               }
+
+               Object account = JpaStorageUtils.getEntity(
+                               "org.collectionspace.services.account.AccountsCommon", whereClause, params);
+               if (account == null) {
+                       String msg = "User's account not found, csid=" + csid;
+                       throw new DocumentNotFoundException(msg);
+               }
+               AccountValue av = new AccountValue();
+               av.setAccountId((String)JaxbUtils.getValue(account, "getCsid"));
+               av.setScreenName((String)JaxbUtils.getValue(account, "getScreenName"));
+               av.setUserId((String)JaxbUtils.getValue(account, "getUserId"));
+            // Add the currentTenantId to the payload so the client knows the current tenancy.
+               av.setTenantId(AuthN.get().getCurrentTenantId());
+
+               return av;
+       } catch (Exception e) {
+               String msg = "User's account is in invalid state, csid=" + csid;
+               throw new DocumentNotFoundException(msg);               
+       }
+    }
+
     //FIXME: REM - This method should probably be moved to the AccountPermissionDocumemntHandler
     /*
      * This is a prototype for the /accounts/{csid}/permissions GET service call.
@@ -186,7 +223,8 @@ public class JpaStorageUtils {
         // permission -that is, the csid's userId match the currently logged in userId or
        // that they have read access to the "accounts" resource.
         //
-       String userId = getUserId(csid);
+       AccountValue account = getAccountValue(csid);
+       String userId = account.getUserId();
        String currentUserId = AuthN.get().getUserId(); 
         if (currentUserId.equalsIgnoreCase(userId) == false) {
                        CSpaceResource res = new URIResourceImpl("accounts", "GET");
@@ -203,49 +241,36 @@ public class JpaStorageUtils {
         AccountPermission result = new AccountPermission();
        EntityManagerFactory emf = null;
         EntityManager em = null;
-        Iterator<Object[]> tuples = null;
+        Iterator<Object> resultList = null;
         try {
-            StringBuilder queryStrBldr = new StringBuilder("SELECT ar, pr FROM " + AccountRoleRel.class.getName() +
-                       " ar, " + PermissionRoleRel.class.getName() + " pr" +
-                       " WHERE ar.roleId = pr.roleId and ar.userId=" + "'" + userId + "'");
+               List<AccountValue> accountValues = new ArrayList<AccountValue>();
+               accountValues.add(account);
+            result.setAccounts(accountValues);
+
+            emf = getEntityManagerFactory();
+            em = emf.createEntityManager();
+           
+            StringBuilder permQueryStrBldr = new StringBuilder(
+                       "SELECT DISTINCT pr FROM " + AccountRoleRel.class.getName() + " ar, " 
+                       + PermissionRoleRel.class.getName() + " pr"
+                       + " WHERE ar.roleId = pr.roleId and ar.userId=" + "'" + userId + "'");
             //
             // Filter by the permissionResource param if it is set to something
             //
             if (permissionResource != null && currentResource != null) {
-               queryStrBldr.append(" and (pr.permissionResource = " + "'" + currentResource + "'" +
+               permQueryStrBldr.append(" and (pr.permissionResource = " + "'" + currentResource + "'" +
                                " or pr.permissionResource = " + "'" + permissionResource + "'" + ")");
             }
-            //
-            // Add group by clause
-            //
-            queryStrBldr.append(" group by pr.permissionId");
-
-            emf = getEntityManagerFactory();
-            em = emf.createEntityManager();
-            String queryStr = queryStrBldr.toString(); //for debugging
+            String queryStr = permQueryStrBldr.toString(); //for debugging
             Query q = em.createQuery(queryStr);            
-            tuples = q.getResultList().iterator();
-            if (tuples.hasNext()) {
-               //
-               // get the first tuple, extract the AccountRoleRel and set the Account value for the result list
-               //
-               Object[] tuple = tuples.next();
-               List<AccountValue> accountValues = new ArrayList<AccountValue>();
-               accountValues.add(AuthorizationRoleRel.buildAccountValue((AccountRoleRel)tuple[0]));
-               //
-               // Since we extracted the first tuple, we need to store the first perm value as well
-               // before iterating over the rest of the tuples.
-               //
+            resultList = q.getResultList().iterator();
+
+            if (resultList.hasNext()) {
                List<PermissionValue> permissionValues = new ArrayList<PermissionValue>();
-               permissionValues.add(AuthorizationRoleRel.buildPermissionValue((PermissionRoleRel)tuple[1]));
-               //
-               // Now finish add the permission values.
-               //
-                   while (tuples.hasNext()) {
-                       tuple = tuples.next();
-                       permissionValues.add(AuthorizationRoleRel.buildPermissionValue((PermissionRoleRel)tuple[1]));
+                   while (resultList.hasNext()) {
+                       PermissionRoleRel permRolRel = (PermissionRoleRel)resultList.next();
+                       permissionValues.add(AuthorizationRoleRel.buildPermissionValue(permRolRel));
                    }
-                   result.setAccounts(accountValues);
                    result.setPermissions(permissionValues);
             }
         } catch (NoResultException nre) {
@@ -268,12 +293,6 @@ public class JpaStorageUtils {
                 releaseEntityManagerFactory(emf);
             }
         }
-        /*
-         * Add the currentTenantId to the payload so the client knows the current
-         * tenancy.
-         */
-        AccountValue av = result.getAccounts().get(0);
-        av.setTenantId(AuthN.get().getCurrentTenantId());
         return result;
     }
 
index 5c024266f819974d6cee0a7c25ddc11b5d7d4b5c..3004393bb312b6ceb2eae6d3754a19254d83e1d5 100644 (file)
     <target name="create_db"
     description="create tables(s), indices for id service">
                                <sql driver="${db.jdbc.driver.class}"
-            url="${db.jdbc.cspace.url}"
-            userid="${db.cspace.user}"
-            password="${db.cspace.user.password}"
+            url="${db.jdbc.nuxeo.url}"
+            userid="${db.nuxeo.user}"
+            password="${db.nuxeo.user.password}"
                                                src="${db.script.dir}/create_id_generators_table.sql" >
             <classpath>
                 <pathelement path="${db.driver.jar}"/>
             </classpath>
         </sql>
                                <sql driver="${db.jdbc.driver.class}"
-            url="${db.jdbc.cspace.url}"
-            userid="${db.cspace.user}"
-            password="${db.cspace.user.password}"
+            url="${db.jdbc.nuxeo.url}"
+            userid="${db.nuxeo.user}"
+            password="${db.nuxeo.user.password}"
             src="${db.script.dir}/load_id_generators.sql" >
             <classpath>
                 <pathelement path="${db.driver.jar}"/>
index c6ec9a25a158cbc23da0d997fb720068802e28f7..99a8d1b5e5689cbcb182ab4072c7b23fd320ad26 100644 (file)
@@ -939,13 +939,9 @@ public class IDServiceJdbcImpl implements IDService {
 
         logger.debug("> in getJdbcConnection");
         
-        // Providing an empty repository name to getConnection() will cause the
-        // default repository name to be used.
-        final String EMPTY_REPOSITORY_NAME = "";
-
         Connection conn = null;
         try {
-            conn = JDBCTools.getConnection(EMPTY_REPOSITORY_NAME);
+            conn = JDBCTools.getConnection(JDBCTools.NUXEO_REPOSITORY_NAME);
         } catch (LoginException e) {
             throw e;
         } catch (SQLException e) {
index 5657fbd700f4b82e0d96fab37deeb02b2ebbb504..57b950e4afdcac9c25659855261380b6cf44b79e 100644 (file)
@@ -25,9 +25,6 @@
  * $LastChangedDate$
  */
 
-CREATE DATABASE IF NOT EXISTS `cspace`;
-USE `cspace`;
-
 DROP TABLE IF EXISTS `id_generators`;
 CREATE TABLE `id_generators` (
   `csid`                varchar(80) PRIMARY KEY,
index 1de199f1ec4f6f61df1b1b7e53d27e2bbce061d3..6b114a88152486f2d64c82daefc85e65b7592472 100644 (file)
@@ -40,8 +40,6 @@
  * initial value is '1').
  */
 
-USE `cspace`;
-
 -- ACCESSION_LOT_NUMBER
 
 INSERT INTO `id_generators`
index 47adebafd51ebfa3488a73c7d5e21183a1fbb567..23f58c0a25ce150e6d7987b8d5a33cd9f0401db1 100644 (file)
  * $LastChangedDate$
  */
 
--- Will return non-fatal failure result code and error message
--- if this database already exists.
-CREATE DATABASE cspace WITH ENCODING = 'UTF8';
-
--- Explicitly use this database before creating a table within it
--- (only works with scripts executed by the 'psql' client).
-\c cspace;
-
 DROP TABLE IF EXISTS id_generators;
 CREATE TABLE id_generators
 (
@@ -49,10 +41,10 @@ CREATE TABLE id_generators
 );
 
 -- CREATE UNIQUE INDEX csid_idx ON id_generators USING btree (csid);
+CREATE OR REPLACE FUNCTION update_modified_column()
+RETURNS TRIGGER AS 'BEGIN NEW.modified = now(); RETURN NEW; END;' language 'plpgsql';
 
--- Update the timestamp in the 'modified' field when the record is updated.
-CREATE OR REPLACE RULE update_idgenerators_timestamp AS
-  ON UPDATE TO id_generators
-  DO INSERT INTO id_generators (modified)
-  VALUES (now());
+CREATE TRIGGER update_customer_modtime BEFORE UPDATE
+        ON id_generators FOR EACH ROW EXECUTE PROCEDURE 
+        update_modified_column();
 
index 1f554e4df52b7390277dee2a718218d12e9ca9b4..217609ff45c9652c60fb5d6dbe98b23fdc18af94 100644 (file)
@@ -40,9 +40,6 @@
  * initial value is '1').
  */
 
--- (Only works with scripts executed by the 'psql' client.)
-\c cspace;
-
 -- ACCESSION_LOT_NUMBER
 
 INSERT INTO id_generators
index 1ebd6ad3274549372ea75592a673e511e87d200f..b31c630aa73b6f2dd913229d9285e60c79b60e29 100644 (file)
                         </systemProperties>
                     </configuration>
                 </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>properties-maven-plugin</artifactId>
+          <version>1.0-alpha-2</version>
+        </plugin>
+                                                               
                                <plugin>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-site-plugin</artifactId>
                 <artifactId>mysql-connector-java</artifactId>
                 <version>5.1.5</version>
             </dependency>
+                                               <dependency>
+                                                               <groupId>postgresql</groupId>
+                                                               <artifactId>postgresql</artifactId>
+                                                               <version>8.4-702.jdbc4</version>
+                                               </dependency>
         </dependencies>
     </dependencyManagement>
 </project>
index 25aece532d1aee40b5669f8f83d9595dd7731b91..8df78c4fe1728591be97d346fb6d56ebf4d460fd 100644 (file)
@@ -6,6 +6,7 @@ DROP database IF EXISTS nuxeo;
 DROP USER IF EXISTS nuxeo;\r
 DROP USER IF EXISTS cspace;\r
 DROP USER IF EXISTS jboss;\r
+DROP USER IF EXISTS reader;\r
 \r
 CREATE ROLE @DB_NUXEO_USER@ WITH PASSWORD '@DB_NUXEO_PASSWORD@' LOGIN;\r
 CREATE ROLE @DB_CSPACE_USER@ WITH PASSWORD '@DB_CSPACE_PASSWORD@' LOGIN;\r