You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2011/11/15 22:54:01 UTC

svn commit: r1202437 - in /ofbiz/trunk/applications/content/src/org/ofbiz/content/search: ContentDocument.java SearchWorker.java

Author: erwan
Date: Tue Nov 15 21:54:01 2011
New Revision: 1202437

URL: http://svn.apache.org/viewvc?rev=1202437&view=rev
Log:
refactoring in Lucene search, using for each instead of while, no functional changes

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchWorker.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java?rev=1202437&r1=1202436&r2=1202437&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java Tue Nov 15 21:54:01 2011
@@ -180,9 +180,7 @@ public class ContentDocument {
             return false;
         }
         List<String> featureList = FastList.newInstance();
-        Iterator<GenericValue> iter = featureDataResourceList.iterator();
-        while (iter.hasNext()) {
-            GenericValue productFeatureDataResource = iter .next();
+        for (GenericValue productFeatureDataResource : featureDataResourceList) {
             String feature = productFeatureDataResource.getString("productFeatureId");
             featureList.add(feature);
         }

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=1202437&r1=1202436&r2=1202437&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 Tue Nov 15 21:54:01 2011
@@ -20,7 +20,6 @@ package org.ofbiz.content.search;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -65,17 +64,13 @@ public class SearchWorker {
         List<GenericValue> siteList = ContentWorker.getAssociatedContent(content, "To", UtilMisc.toList("SUBSITE", "PUBLISH_LINK", "SUB_CONTENT"), null, UtilDateTime.nowTimestamp().toString(), null);
 
         if (siteList != null) {
-            Iterator<GenericValue> iter = siteList.iterator();
-            while (iter.hasNext()) {
-                GenericValue siteContent = iter.next();
+            for (GenericValue siteContent : siteList) {
                 String siteContentId = siteContent.getString("contentId");
                 List<GenericValue> subContentList = ContentWorker.getAssociatedContent(siteContent, "To", UtilMisc.toList("SUBSITE", "PUBLISH_LINK", "SUB_CONTENT"), null, UtilDateTime.nowTimestamp().toString(), null);
 
                 if (subContentList != null) {
                     List<String> contentIdList = FastList.newInstance();
-                    Iterator<GenericValue> iter2 = subContentList.iterator();
-                    while (iter2.hasNext()) {
-                        GenericValue subContent = iter2.next();
+                    for (GenericValue subContent : subContentList) {
                         contentIdList.add(subContent.getString("contentId"));
                     }
 
@@ -108,7 +103,6 @@ public class SearchWorker {
         if (Debug.infoOn()) Debug.logInfo("in indexContent, indexAllPath: " + directory.toString(), module);
         GenericValue content = null;
         // Delete existing documents
-        Iterator<String> iter = null;
         List<GenericValue> contentList = null;
         IndexReader reader = null;
         try {
@@ -118,9 +112,7 @@ public class SearchWorker {
         }
 
         contentList = FastList.newInstance();
-        iter = idList.iterator();
-        while (iter.hasNext()) {
-            String id = iter.next();
+        for (String id : idList) {
             if (Debug.infoOn()) Debug.logInfo("in indexContent, id:" + id, module);
             try {
                 content = delegator.findByPrimaryKeyCache("Content", UtilMisc .toMap("contentId", id));
@@ -146,10 +138,8 @@ public class SearchWorker {
             writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
         }
 
-        Iterator<GenericValue> contentListIter = contentList.iterator();
-        while (contentListIter.hasNext()) {
-            content = contentListIter.next();
-            indexContent(dispatcher, delegator, context, content, writer);
+        for (GenericValue gv : contentList) {
+            indexContent(dispatcher, delegator, context, gv, writer);
         }
         writer.optimize();
         writer.close();