From c4a82b18c1ea2552f97b869d34674e4f24ed61c7 Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Fri, 15 Jul 2011 19:31:26 +0000 Subject: [PATCH] ALF-9079: RSOLR 019: Lucene to SOLR switchover administration - make solr base URL configurable git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29092 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../Search/solr/solr-search-context.xml | 21 ++++++++-- .../Search/solr/solr-search.properties | 1 + ...stractLuceneIndexerAndSearcherFactory.java | 18 ++++++++ .../impl/solr/AbstractSolrQueryLanguage.java | 42 +++++++++++++++++++ .../solr/SolrAlfrescoFTSQueryLanguage.java | 6 ++- .../impl/solr/SolrCMISQueryLanguage.java | 7 ++-- .../solr/SolrIndexerAndSearcherFactory.java | 11 +++++ 7 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 config/alfresco/subsystems/Search/solr/solr-search.properties create mode 100644 source/java/org/alfresco/repo/search/impl/solr/AbstractSolrQueryLanguage.java diff --git a/config/alfresco/subsystems/Search/solr/solr-search-context.xml b/config/alfresco/subsystems/Search/solr/solr-search-context.xml index 407514f45c..ac8aca33cb 100644 --- a/config/alfresco/subsystems/Search/solr/solr-search-context.xml +++ b/config/alfresco/subsystems/Search/solr/solr-search-context.xml @@ -30,7 +30,14 @@ - + + + ${solr.base.url} + + + + @@ -49,7 +56,8 @@ - + @@ -66,7 +74,8 @@ - + @@ -80,7 +89,8 @@ - + @@ -121,6 +131,9 @@ + + ${solr.base.url} + diff --git a/config/alfresco/subsystems/Search/solr/solr-search.properties b/config/alfresco/subsystems/Search/solr/solr-search.properties new file mode 100644 index 0000000000..defb170688 --- /dev/null +++ b/config/alfresco/subsystems/Search/solr/solr-search.properties @@ -0,0 +1 @@ +solr.base.url=http://localhost:8080/solr \ No newline at end of file diff --git a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java index 853cd7d8a0..84645732f3 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/AbstractLuceneIndexerAndSearcherFactory.java @@ -198,6 +198,8 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory extends AbstractIn private ConfigurableApplicationContext applicationContext; + private boolean contentIndexingEnabled = true; + /** * Private constructor for the singleton TODO: FIt in with IOC */ @@ -1974,6 +1976,22 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory extends AbstractIn this.writerRamBufferSizeMb = writerRamBufferSizeMb; } + + + + @Override + public boolean isContentIndexingEnabled() + { + return contentIndexingEnabled; + } + + @Override + public void setContentIndexingEnabled(boolean contentIndexingEnabled) + { + this.contentIndexingEnabled = contentIndexingEnabled; + + } + protected LuceneQueryLanguageSPI getQueryLanguage(String name) { return getQueryLanguages().get(name); diff --git a/source/java/org/alfresco/repo/search/impl/solr/AbstractSolrQueryLanguage.java b/source/java/org/alfresco/repo/search/impl/solr/AbstractSolrQueryLanguage.java new file mode 100644 index 0000000000..40efd9e1ef --- /dev/null +++ b/source/java/org/alfresco/repo/search/impl/solr/AbstractSolrQueryLanguage.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.search.impl.solr; + +import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryLanguage; + +/** + * @author Andy + * + */ +public abstract class AbstractSolrQueryLanguage extends AbstractLuceneQueryLanguage +{ + private String baseUrl; + + public String getBaseUrl() + { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) + { + this.baseUrl = baseUrl; + } + + +} diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrAlfrescoFTSQueryLanguage.java b/source/java/org/alfresco/repo/search/impl/solr/SolrAlfrescoFTSQueryLanguage.java index 75adecfd9b..761de62a3e 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrAlfrescoFTSQueryLanguage.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrAlfrescoFTSQueryLanguage.java @@ -61,7 +61,7 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * @author Andy */ -public class SolrAlfrescoFTSQueryLanguage extends AbstractLuceneQueryLanguage +public class SolrAlfrescoFTSQueryLanguage extends AbstractSolrQueryLanguage { static Log s_logger = LogFactory.getLog(SolrAlfrescoFTSQueryLanguage.class); @@ -104,7 +104,9 @@ public class SolrAlfrescoFTSQueryLanguage extends AbstractLuceneQueryLanguage httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true); httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin")); - StringBuilder url = new StringBuilder("http://localhost:8080/solr/alfresco/afts"); + StringBuilder url = new StringBuilder(); + url.append(getBaseUrl()); + url.append("/alfresco/afts"); //duplicate the query in the URL url.append("?q="); URLCodec encoder = new URLCodec(); diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryLanguage.java b/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryLanguage.java index e1507157ab..4fa324b986 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryLanguage.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryLanguage.java @@ -58,7 +58,7 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * @author Andy */ -public class SolrCMISQueryLanguage extends AbstractLuceneQueryLanguage +public class SolrCMISQueryLanguage extends AbstractSolrQueryLanguage { static Log s_logger = LogFactory.getLog(SolrCMISQueryLanguage.class); @@ -103,8 +103,9 @@ public class SolrCMISQueryLanguage extends AbstractLuceneQueryLanguage httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true); httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin")); - StringBuilder url = new StringBuilder("http://localhost:8080/solr/alfresco/cmis"); - // duplicate the query in the URL + StringBuilder url = new StringBuilder(); + url.append(getBaseUrl()); + url.append("/alfresco/cmis"); url.append("?q="); URLCodec encoder = new URLCodec(); url.append(encoder.encode(searchParameters.getQuery(), "UTF-8")); diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrIndexerAndSearcherFactory.java b/source/java/org/alfresco/repo/search/impl/solr/SolrIndexerAndSearcherFactory.java index 526cb4435c..9642d70cc5 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrIndexerAndSearcherFactory.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrIndexerAndSearcherFactory.java @@ -44,6 +44,7 @@ public class SolrIndexerAndSearcherFactory extends AbstractIndexerAndSearcher private NodeService nodeService; private QueryRegisterComponent queryRegister; private TenantService tenantService; + private String baseUrl; public DictionaryService getDictionaryService() { @@ -95,6 +96,16 @@ public class SolrIndexerAndSearcherFactory extends AbstractIndexerAndSearcher this.tenantService = tenantService; } + public String getBaseUrl() + { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) + { + this.baseUrl = baseUrl; + } + /* (non-Javadoc) * @see org.alfresco.repo.search.IndexerAndSearcher#getIndexer(org.alfresco.service.cmr.repository.StoreRef) */