tenant bindings file, we will create a corresponding Nuxeo repository config-
uration file. You won't have to change the value for most of these elements
and attributes because they will be set when CollectionSpace starts.
-
+
*** NOTE *** One value you may want to change is the 'binaryStore' path which is the location
that Nuxeo places binary files like images and PDF documents. Be sure to read the comment to
the right of the <binaryStore> element below.
<!-- Values in the following elements are primarily added during execution -->
<!-- of the 'ant deploy' command, within the Services source code tree. -->
<!-- (Several values are also added during system startup, into repository-specific -->
-<!-- 'clones' of this prototype configuration file, as noted below.) -->
+<!-- 'clones' of this prototype configuration file, as noted below.) -->
<!-- See http://doc.nuxeo.com/display/ADMINDOC/VCS+Configuration for more config details -->
<component name="config:default-repository">
<extension target="org.nuxeo.ecm.core.blob.BlobManager" point="configuration">
<extension target="org.nuxeo.ecm.core.storage.sql.RepositoryService" point="repository">
<repository name="default" factory="org.nuxeo.ecm.core.storage.sql.ra.PoolingRepositoryFactory">
<pool minPoolSize="0" maxPoolSize="20" blockingTimeoutMillis="100" idleTimeoutMinutes="10"/>
- <clustering enabled="false" delay="1000"/>
+ <clustering enabled="false" delay="1000"/>
<xa-datasource>@XA_DATASOURCE@</xa-datasource> <!-- The transactional datasource for Nuxeo -->
<noDDL>false</noDDL>
- <sqlInitFile>vcsconfig.sql.txt</sqlInitFile> <!-- see https://doc.nuxeo.com/display/ADMINDOC/VCS+Configuration#VCSConfiguration-DatabaseCreationOption -->
+ <sqlInitFile>vcsconfig.sql.txt</sqlInitFile> <!-- see https://doc.nuxeo.com/display/ADMINDOC/VCS+Configuration#VCSConfiguration-DatabaseCreationOption -->
<aclOptimizations enabled="true"/>
<pathOptimizations enabled="true"/>
<idType>varchar</idType>
<indexing>
- <fulltext disabled="false" analyzer="english">
+ <fulltext disabled="false" analyzer="cspace_english">
<index name="default">
<!-- all props implied -->
</index>
</index>
</fulltext>
</indexing>
- <usersSeparator key="," />
+ <usersSeparator key="," />
<property name="ServerName">@DB_SERVER_HOSTNAME@</property>
<property name="DatabaseName"></property> <!-- The value of the database name element is inserted during system startup. -->
<property name="JDBCOptions">@DB_JDBC_OPTIONS@</property>
# or https://doc.nuxeo.com/nxdoc/repository-configuration/#page-title
#
+#CATEGORY: first
+
+#
+# Ensure that a configuration exists for the CSpace-specific fulltext analyzer named in
+# proto-repo-config.xml.
+#
+# We modify the configuration later (see unaccent_text_search_configuration.sql). Those
+# modifications can't be done here, because they require having postgres extensions installed,
+# and script does not run as a superuser, which is required to install extensions.
+#
+# For now, the text search configuration just needs to exist, so Nuxeo will be able to start.
+#
+
+#TEST:
+SELECT 1 FROM pg_ts_config WHERE cfgname = '${fulltextAnalyzer}';
+
+#IF: emptyResult
+CREATE TEXT SEARCH CONFIGURATION ${fulltextAnalyzer} ( COPY = english );
+
+
+
#CATEGORY: afterTableCreation
#
<service:initHandler xmlns:service="http://collectionspace.org/services/config/service">
<service:classname>org.collectionspace.services.common.init.RunSqlScripts</service:classname>
<service:params>
+ <service:property>
+ <service:key>sqlScriptName</service:key>
+ <service:value>unaccent_text_search_configuration.sql</service:value>
+ </service:property>
</service:params>
</service:initHandler>
</tenant:serviceBindings>
// Upgrade database schema
svcMain.upgradeDatabase();
+ // Create required postgres extensions
+ svcMain.createRequiredExtensions();
+
// Create required indexes (aka indices) in tables not associated
// with any specific tenant.
svcMain.createRequiredIndices();
}
}
+ void createRequiredExtensions() throws Exception {
+ Hashtable<String, TenantBindingType> tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings();
+
+ // Loop through all tenants in tenant-bindings.xml
+
+ String cspaceInstanceId = getCspaceInstanceId();
+
+ for (TenantBindingType tbt : tenantBindingTypeMap.values()) {
+ List<String> repositoryNameList = ConfigUtils.getRepositoryNameList(tbt);
+
+ if (repositoryNameList != null && repositoryNameList.isEmpty() == false) {
+ // Loop through each repo/DB defined in a tenant bindings file
+
+ for (String repositoryName : repositoryNameList) {
+ try {
+ JDBCTools.executeUpdate(JDBCTools.CSADMIN_NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId, "CREATE EXTENSION IF NOT EXISTS \"unaccent\"");
+ }
+ catch(Exception e) {
+ logger.warn("Could not install unaccent postgresql extension. Accent-insensitive full text search is not available without this extension. On some platforms you may need to manually install this extension as a superuser.");
+ }
+ }
+ } else {
+ String errMsg = "repositoryNameList was empty or null.";
+
+ logger.error(errMsg);
+
+ throw new Exception(errMsg);
+ }
+ }
+ }
+
/**
* Create required indexes (aka indices) in database tables not associated
* with any specific tenant.
for (ServiceBindingType sbt: sbtList) {
if (sbt.getName().equalsIgnoreCase(RUNSQLSCRIPTS_SERVICE_NAME)) {
runInitHandler(cspaceInstanceId, tbt, sbt);
- return;
+ continue;
}
}
}
+++ /dev/null
-DO $$
-BEGIN
-
- IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'unaccent') THEN
- CREATE EXTENSION unaccent;
- END IF;
-
- IF NOT EXISTS (SELECT 1 FROM pg_ts_config WHERE cfgname = 'unaccent_english') THEN
- CREATE TEXT SEARCH CONFIGURATION unaccent_english ( COPY = english );
-
- ALTER TEXT SEARCH CONFIGURATION unaccent_english
- ALTER MAPPING FOR asciihword, asciiword, hword_asciipart, hword, hword_part, word
- WITH unaccent, english_stem;
- END IF;
-
-END $$;
\ No newline at end of file
--- /dev/null
+/*
+ * If the unaccent extension is installed, modify the cspace_english text search configuration to
+ * be accent-insensitive.
+ */
+
+DO $$
+BEGIN
+
+ IF EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'unaccent') THEN
+ IF EXISTS (SELECT 1 FROM pg_ts_config WHERE cfgname = 'cspace_english') THEN
+ ALTER TEXT SEARCH CONFIGURATION cspace_english
+ ALTER MAPPING FOR asciihword, asciiword, hword_asciipart, hword, hword_part, word
+ WITH unaccent, english_stem;
+ END IF;
+ END IF;
+
+END $$;