Applied patch from jira issue - OFBIZ-7405 - Enforce noninstantiability to SearchWorker Class. Thanks Rahul Singh Kushwah for your contribution.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@1750350 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -99,7 +99,7 @@ public class DocumentIndexer extends Thread {
|
||||
if (indexWriter == null) {
|
||||
try {
|
||||
StandardAnalyzer analyzer = new StandardAnalyzer();
|
||||
analyzer.setVersion(SearchWorker.LUCENE_VERSION);
|
||||
analyzer.setVersion(SearchWorker.getLuceneVersion());
|
||||
indexWriter = new IndexWriter(this.indexDirectory, new IndexWriterConfig(analyzer));
|
||||
} catch (CorruptIndexException e) {
|
||||
Debug.logError("Corrupted lucene index: " + e.getMessage(), module);
|
||||
|
||||
@@ -38,11 +38,13 @@ import org.apache.lucene.util.Version;
|
||||
/**
|
||||
* SearchWorker Class
|
||||
*/
|
||||
public class SearchWorker {
|
||||
public final class SearchWorker {
|
||||
|
||||
public static final String module = SearchWorker.class.getName();
|
||||
|
||||
public static final Version LUCENE_VERSION = Version.LUCENE_5_3_1;
|
||||
private static final Version LUCENE_VERSION = Version.LUCENE_5_3_1;
|
||||
|
||||
private SearchWorker() {}
|
||||
|
||||
public static void indexContentTree(LocalDispatcher dispatcher, Delegator delegator, String siteId) throws Exception {
|
||||
GenericValue content = delegator.makeValue("Content", UtilMisc.toMap("contentId", siteId));
|
||||
@@ -88,4 +90,8 @@ public class SearchWorker {
|
||||
indexer.queue(new ContentDocument(content, dispatcher));
|
||||
}
|
||||
}
|
||||
|
||||
public static Version getLuceneVersion() {
|
||||
return LUCENE_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class LuceneTests extends OFBizTestCase {
|
||||
|
||||
IndexSearcher searcher = new IndexSearcher(r);
|
||||
Analyzer analyzer = new StandardAnalyzer();
|
||||
analyzer.setVersion(SearchWorker.LUCENE_VERSION);
|
||||
analyzer.setVersion(SearchWorker.getLuceneVersion());
|
||||
|
||||
QueryParser parser = new QueryParser("content", analyzer);
|
||||
Query query = parser.parse(queryLine);
|
||||
|
||||
Reference in New Issue
Block a user