svn commit: r1374328 - in /ofbiz/trunk: applications/content/src/org/ofbiz/content/search/ applications/content/src/org/ofbiz/content/test/ applications/content/webapp/content/WEB-INF/actions/cms/ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actio...

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

svn commit: r1374328 - in /ofbiz/trunk: applications/content/src/org/ofbiz/content/search/ applications/content/src/org/ofbiz/content/test/ applications/content/webapp/content/WEB-INF/actions/cms/ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actio...

jacopoc
Author: jacopoc
Date: Fri Aug 17 15:43:30 2012
New Revision: 1374328

URL: http://svn.apache.org/viewvc?rev=1374328&view=rev
Log:
Fixed some inconsistent use of Lucene Version (now the current Version is set as a static final field of SearchWorker); misc minor code cleanups.

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java
    ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java?rev=1374328&r1=1374327&r2=1374328&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java Fri Aug 17 15:43:30 2012
@@ -58,6 +58,8 @@ public class SearchWorker {
 
     public static final String module = SearchWorker.class.getName();
 
+    public static final Version LUCENE_VERSION = Version.LUCENE_35;
+
     public static Map<String, Object> indexTree(LocalDispatcher dispatcher, Delegator delegator, String siteId, Map<String, Object> context, String path) throws Exception {
         Map<String, Object> results = FastMap.newInstance();
         GenericValue content = delegator.makeValue("Content", UtilMisc.toMap("contentId", siteId));
@@ -95,24 +97,21 @@ public class SearchWorker {
         indexContentList(dispatcher, delegator, context, idList, null);
     }
 
-    public static void indexContentList(LocalDispatcher dispatcher, Delegator delegator, Map<String, Object> context,List<String> idList, String path) throws Exception {
+    public static void indexContentList(LocalDispatcher dispatcher, Delegator delegator, Map<String, Object> context, List<String> idList, String path) throws Exception {
         Directory directory = FSDirectory.open(new File(getIndexPath(path)));
         if (Debug.infoOn()) Debug.logInfo("in indexContent, indexAllPath: " + directory.toString(), module);
-        GenericValue content = null;
         // Delete existing documents
-        List<GenericValue> contentList = null;
         IndexReader reader = null;
         try {
             reader = IndexReader.open(directory, false);
         } catch (Exception e) {
             // ignore
         }
-
-        contentList = FastList.newInstance();
+        List<GenericValue> contentList = FastList.newInstance();
         for (String id : idList) {
             if (Debug.infoOn()) Debug.logInfo("in indexContent, id:" + id, module);
             try {
-                content = delegator.findOne("Content", UtilMisc .toMap("contentId", id), true);
+                GenericValue content = delegator.findOne("Content", UtilMisc .toMap("contentId", id), true);
                 if (content != null) {
                     if (reader != null) {
                         deleteContentDocument(content, reader);
@@ -130,8 +129,8 @@ public class SearchWorker {
         // Now create
         IndexWriter writer = null;
         long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
-        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_34, analyzer);
+        Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+        IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
 
         try {
             IndexWriterConfig.setDefaultWriteLockTimeout(2000);
@@ -176,8 +175,8 @@ public class SearchWorker {
     public static void indexContent(LocalDispatcher dispatcher, Delegator delegator, Map<String, Object> context, GenericValue content, String path) throws Exception {
         Directory directory = FSDirectory.open(new File(getIndexPath(path)));
         long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
-        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
+        Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+        IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
         IndexWriter writer = null;
         try {
             try {
@@ -227,8 +226,8 @@ public class SearchWorker {
     public static void indexDataResource(Delegator delegator, Map<String, Object> context, String id, String path) throws Exception {
         Directory directory = FSDirectory.open(new File(getIndexPath(path)));
         long savedWriteLockTimeout = IndexWriterConfig.getDefaultWriteLockTimeout();
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
-        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
+        Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
+        IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, analyzer);
         IndexWriter writer = null;
 
         try {

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java?rev=1374328&r1=1374327&r2=1374328&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/test/LuceneTests.java Fri Aug 17 15:43:30 2012
@@ -85,9 +85,9 @@ public class LuceneTests extends OFBizTe
         String queryLine = "hand";
 
         IndexSearcher searcher = new IndexSearcher(r);
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
+        Analyzer analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
 
-        QueryParser parser = new QueryParser(Version.LUCENE_35, "content", analyzer);
+        QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
         Query query = parser.parse(queryLine);
         combQuery.add(query, BooleanClause.Occur.MUST);
 

Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy?rev=1374328&r1=1374327&r2=1374328&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy (original)
+++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/cms/Search.groovy Fri Aug 17 15:43:30 2012
@@ -56,7 +56,7 @@ try {
     Debug.logInfo("in search, indexPath:" + directory.toString(), "");
     searcher = new IndexSearcher(reader);
     Debug.logInfo("in search, searcher:" + searcher, "");
-    analyzer = new StandardAnalyzer(Version.LUCENE_30);
+    analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
 } catch (java.io.FileNotFoundException e) {
     request.setAttribute("errorMsgReq", "No index file exists.");
     Debug.logError("in search, error:" + e.getMessage(), "");
@@ -66,7 +66,7 @@ try {
 if (queryLine || siteId) {
     Query query = null;
     if (queryLine) {
-        QueryParser parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
+        QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
         query = parser.parse(queryLine);
         combQuery.add(query, BooleanClause.Occur.MUST);
     }

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy?rev=1374328&r1=1374327&r2=1374328&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/content/Search.groovy Fri Aug 17 15:43:30 2012
@@ -57,7 +57,7 @@ Searcher searcher = null;
 Analyzer analyzer = null;
 try {
     searcher = new IndexSearcher(reader);
-    analyzer = new StandardAnalyzer(Version.LUCENE_30);
+    analyzer = new StandardAnalyzer(SearchWorker.LUCENE_VERSION);
 } catch (java.io.FileNotFoundException e) {
     Debug.logError(e, "Search.groovy");
     request.setAttribute("errorMsgReq", "No index file exists.");
@@ -69,7 +69,7 @@ combQuery.add(termQuery, BooleanClause.O
 //Debug.logInfo("in search, combQuery(1):" + combQuery, "");
 if (queryLine && analyzer) {
     Query query = null;
-    QueryParser parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
+    QueryParser parser = new QueryParser(SearchWorker.LUCENE_VERSION, "content", analyzer);
     query = parser.parse(queryLine);
     combQuery.add(query, BooleanClause.Occur.MUST);
 }