import org.collectionspace.services.config.ClientType;
import org.collectionspace.services.config.ServiceConfig;
import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.config.tenant.ElasticSearchIndexConfig;
import org.collectionspace.services.config.tenant.EventListenerConfig;
import org.collectionspace.services.config.tenant.EventListenerConfigurations;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
logger.debug(String.format("Repository name is %s", repositoryName));
Document protoElasticsearchExtensionDoc = XmlTools.fileToXMLDocument(protoElasticsearchExtensionFile);
- protoElasticsearchExtensionDoc = updateElasticSearchExtensionDoc(protoElasticsearchExtensionDoc, repositoryName, this.getCspaceInstanceId());
+ protoElasticsearchExtensionDoc = updateElasticSearchExtensionDoc(protoElasticsearchExtensionDoc, repositoryName, this.getCspaceInstanceId(), tbt.getElasticSearchIndexConfig());
if (logger.isDebugEnabled()) {
String extension = protoElasticsearchExtensionDoc.asXML();
logger.trace(String.format("Updated Elasticsearch extension for '%s' repository: contents=\n", repositoryName, extension));
* This method is filling out the elasticsearch-config.xml file with tenant specific repository information.
*/
private Document updateElasticSearchExtensionDoc(Document elasticsearchConfigDoc, String repositoryName,
- String cspaceInstanceId) {
+ String cspaceInstanceId, ElasticSearchIndexConfig elasticSearchIndexConfig) {
// Set the <elasticSearchIndex> element's name attribute
String indexName = getElasticsearchIndexName(elasticsearchConfigDoc, repositoryName, cspaceInstanceId);
elasticsearchConfigDoc = XmlTools.setAttributeValue(elasticsearchConfigDoc,
ConfigUtils.ELASTICSEARCH_INDEX_EXTENSION_XPATH + "/elasticSearchIndex", "repository", repositoryName);
+ if (elasticSearchIndexConfig != null) {
+ String settings = elasticSearchIndexConfig.getSettings();
+ String mapping = elasticSearchIndexConfig.getMapping();
+
+ if (settings != null) {
+ XmlTools.setElementValue(elasticsearchConfigDoc, ConfigUtils.ELASTICSEARCH_INDEX_EXTENSION_XPATH + "/elasticSearchIndex/settings", settings);
+ }
+
+ if (mapping != null) {
+ XmlTools.setElementValue(elasticsearchConfigDoc, ConfigUtils.ELASTICSEARCH_INDEX_EXTENSION_XPATH + "/elasticSearchIndex/mapping", mapping);
+ }
+ }
+
return elasticsearchConfigDoc;
}
<xs:element name="properties" type="types:PropertyType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="remoteClientConfigurations" type="RemoteClientConfigurations" minOccurs="0" maxOccurs="1"/>
<xs:element name="emailConfig" type="EmailConfig" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="elasticSearchIndexConfig" type="ElasticSearchIndexConfig" minOccurs="0" maxOccurs="1"/>
<xs:element name="serviceBindings" type="service:ServiceBindingType" minOccurs="0" maxOccurs="unbounded"/>
<!--
Processing all of the tenant bindings at startup involves several sub-tasks and is expensive (slow), so we'll compute the MD5 hash of the config and persist it in the corresponding tenant record.
<xs:element name="passwordResetConfig" type="PasswordResetConfig" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
-
+
+ <xs:complexType name="ElasticSearchIndexConfig">
+ <xs:annotation>
+ <xs:documentation>Configuration of a tenant's Elasticsearch index</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="settings" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="mapping" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="SMTPConfig">
<xs:annotation>
<xs:documentation>SMTP config for sending emails.</xs:documentation>