<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
<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>
<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>
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
\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
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
-\r
<project name="trunk-install" default="package" basedir=".">\r
<description>\r
collectionspace services\r
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
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
<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
<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"
-\r
<project name="account.client" default="package" basedir=".">\r
<description>\r
collectionspace account service\r
<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
"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>
-\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
+++ /dev/null
-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);
+++ /dev/null
---
--- 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);
+++ /dev/null
---
--- 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');
"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>
-\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
"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>
"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>
-\r
<project name="authentication.pstore" default="package" basedir=".">\r
<description>\r
collectionspace authentication service\r
<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
+++ /dev/null
-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));
+++ /dev/null
---
--- 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;
-
-
+++ /dev/null
---\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
"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>
<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
<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>
<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">
</constructor-arg>
</bean>
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<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>
"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>
-\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
+++ /dev/null
---
--- 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`);
+++ /dev/null
-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);
+++ /dev/null
---
--- 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);
-
+++ /dev/null
---\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
"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>
<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">
<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
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}">
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 -->
</properties>
</repository-client>
-
</svc:service-config>
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
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
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
*/\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
}\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
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
throw new RuntimeException(e);\r
}\r
}\r
- instance = temp;\r
+ instance = newInstance;\r
}\r
}\r
}\r
}\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
//\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
}\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
\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
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
}\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
}\r
return uriTemplateRegistry;\r
}\r
-\r
-\r
}\r
}\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
}\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
// 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
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
*/\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
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
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
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
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
*/\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
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
+++ /dev/null
-/*
- * 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;
+++ /dev/null
-/*
- * 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;
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";
<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" />
-\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
"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>
+++ /dev/null
---
--- 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;
-
+++ /dev/null
---
--- 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;
-
-- 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@;
-- 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