svn commit: r1750350 - in /ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content: search/DocumentIndexer.java search/SearchWorker.java test/LuceneTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1750350 - in /ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content: search/DocumentIndexer.java search/SearchWorker.java test/LuceneTests.java

Arun Patidar-4
Author: arunpatidar
Date: Mon Jun 27 14:36:06 2016
New Revision: 1750350

URL: http://svn.apache.org/viewvc?rev=1750350&view=rev
Log:
Applied patch from jira issue - OFBIZ-7405 - Enforce noninstantiability to SearchWorker Class. Thanks Rahul Singh Kushwah   for your contribution.

Modified:
    ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/DocumentIndexer.java
    ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java
    ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/test/LuceneTests.java

Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/DocumentIndexer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/DocumentIndexer.java?rev=1750350&r1=1750349&r2=1750350&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/DocumentIndexer.java (original)
+++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/DocumentIndexer.java Mon Jun 27 14:36:06 2016
@@ -99,7 +99,7 @@ public class DocumentIndexer extends Thr
             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);

Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java?rev=1750350&r1=1750349&r2=1750350&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java (original)
+++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java Mon Jun 27 14:36:06 2016
@@ -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;
+    }
 }

Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/test/LuceneTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/test/LuceneTests.java?rev=1750350&r1=1750349&r2=1750350&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/test/LuceneTests.java (original)
+++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/test/LuceneTests.java Mon Jun 27 14:36:06 2016
@@ -81,7 +81,7 @@ public class LuceneTests extends OFBizTe
 
         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);