Author: jacopoc
Date: Fri Aug 30 14:37:20 2013 New Revision: 1518980 URL: http://svn.apache.org/r1518980 Log: Minor code cleanup for the Java classes in the "lucene" component: replaced unnecessary usage of Javolution, simplified some code, suppressed unnecessary empty lines. Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/ContentDocument.java ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchEvents.java ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchServices.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/ContentDocument.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/ContentDocument.java?rev=1518980&r1=1518979&r2=1518980&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/ContentDocument.java (original) +++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/ContentDocument.java Fri Aug 30 14:37:20 2013 @@ -19,13 +19,13 @@ package org.ofbiz.content.search; import java.io.IOException; +import java.lang.String; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; -import javolution.util.FastList; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.StringUtil; @@ -75,9 +75,8 @@ public class ContentDocument { String description = content.getString("description"); if (UtilValidate.isNotEmpty(description)) doc.add(new TextField("description", description, Store.YES)); - List<String> ancestorList = FastList.newInstance(); - Delegator delegator = content.getDelegator(); - ContentWorker.getContentAncestryAll(delegator, contentId, "WEB_SITE_PUB_PT", "TO", ancestorList); + List<String> ancestorList = new ArrayList<String>(); + ContentWorker.getContentAncestryAll(content.getDelegator(), contentId, "WEB_SITE_PUB_PT", "TO", ancestorList); String ancestorString = StringUtil.join(ancestorList, " "); if (UtilValidate.isNotEmpty(ancestorString)) { Field field = new StringField("site", ancestorString, Store.NO); @@ -90,12 +89,10 @@ public class ContentDocument { } public static boolean indexDataResource(GenericValue content, Document doc, Map<String, Object> context, LocalDispatcher dispatcher) { - Delegator delegator = content.getDelegator(); String contentId = content.getString("contentId"); - String dataResourceId = content.getString("dataResourceId"); GenericValue dataResource; try { - dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + dataResource = content.getRelatedOne("DataResource", true); } catch (GenericEntityException e) { Debug.logError(e, module); List<String> badIndexList = UtilGenerics.checkList(context.get("badIndexList")); @@ -118,7 +115,7 @@ public class ContentDocument { } String text; try { - text = ContentWorker.renderContentAsText(dispatcher, delegator, contentId, context, locale, mimeTypeId, true); + text = ContentWorker.renderContentAsText(dispatcher, content.getDelegator(), contentId, context, locale, mimeTypeId, true); } catch (GeneralException e) { Debug.logError(e, module); List<String> badIndexList = UtilGenerics.checkList(context.get("badIndexList")); @@ -143,7 +140,7 @@ public class ContentDocument { badIndexList.add(contentId + " - " + e.getMessage()); return false; } - List<String> featureList = FastList.newInstance(); + List<String> featureList = new ArrayList<String>(); for (GenericValue productFeatureDataResource : featureDataResourceList) { String feature = productFeatureDataResource.getString("productFeatureId"); featureList.add(feature); Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchEvents.java?rev=1518980&r1=1518979&r2=1518980&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchEvents.java (original) +++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchEvents.java Fri Aug 30 14:37:20 2013 @@ -18,14 +18,15 @@ *******************************************************************************/ package org.ofbiz.content.search; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javolution.util.FastMap; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilGenerics; @@ -36,8 +37,6 @@ import org.ofbiz.service.GenericServiceE import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; - - /** * SearchEvents Class */ @@ -48,7 +47,7 @@ public class SearchEvents { public static String indexTree(HttpServletRequest request, HttpServletResponse response) { Map<String, Object> result; - Map<String, Object> serviceInMap = FastMap.newInstance(); + Map<String, Object> serviceInMap = new HashMap<String, Object>(); HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); serviceInMap.put("userLogin", userLogin); Modified: ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchServices.java?rev=1518980&r1=1518979&r2=1518980&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchServices.java (original) +++ ofbiz/trunk/specialpurpose/lucene/src/org/ofbiz/content/search/SearchServices.java Fri Aug 30 14:37:20 2013 @@ -18,14 +18,15 @@ *******************************************************************************/ package org.ofbiz.content.search; +import java.lang.Object; +import java.lang.String; +import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import javolution.util.FastList; -import javolution.util.FastMap; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -34,7 +35,6 @@ import org.ofbiz.service.DispatchContext import org.ofbiz.service.ServiceUtil; import org.ofbiz.service.LocalDispatcher; - /** * SearchServices Class */ @@ -53,10 +53,10 @@ public class SearchServices { if (path == null) { path = SearchWorker.getIndexPath(path); } - Map<String, Object> envContext = FastMap.newInstance(); + Map<String, Object> envContext = new HashMap<String, Object>(); if (Debug.infoOn()) Debug.logInfo("in indexTree, siteId:" + siteId, module); - List<String> badIndexList = FastList.newInstance(); + List<String> badIndexList = new ArrayList<String>(); envContext.put("badIndexList", badIndexList); envContext.put("goodIndexCount", Integer.valueOf(0)); 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=1518980&r1=1518979&r2=1518980&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 Fri Aug 30 14:37:20 2013 @@ -20,12 +20,11 @@ package org.ofbiz.content.search; import java.io.File; import java.io.IOException; +import java.lang.String; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import javolution.util.FastList; -import javolution.util.FastMap; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilGenerics; @@ -61,7 +60,6 @@ public class SearchWorker { public static final Version LUCENE_VERSION = Version.LUCENE_40; 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)); if (Debug.infoOn()) Debug.logInfo("in indexTree, siteId:" + siteId + " content:" + content, module); List<GenericValue> siteList = ContentWorker.getAssociatedContent(content, "To", UtilMisc.toList("SUBSITE", "PUBLISH_LINK", "SUB_CONTENT"), null, UtilDateTime.nowTimestamp().toString(), null); @@ -72,7 +70,7 @@ public class SearchWorker { 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(); + List<String> contentIdList = new ArrayList<String>(); for (GenericValue subContent : subContentList) { contentIdList.add(subContent.getString("contentId")); } @@ -87,10 +85,8 @@ public class SearchWorker { List<String> badIndexList = UtilGenerics.checkList(context.get("badIndexList")); badIndexList.add(siteId + " had no sub-entities."); } - results.put("badIndexList", context.get("badIndexList")); - results.put("goodIndexCount", context.get("goodIndexCount")); - return results; + return UtilMisc.toMap("badIndexList", context.get("badIndexList"), "goodIndexCount", context.get("goodIndexCount")); } public static String getIndexPath(String path) { @@ -126,7 +122,7 @@ public class SearchWorker { if (Debug.infoOn()) Debug.logInfo("in indexContentList, indexAllPath: " + directory.toString(), module); // Delete existing documents IndexWriter writer = getDefaultIndexWriter(directory); - List<GenericValue> contentList = FastList.newInstance(); + List<GenericValue> contentList = new ArrayList<GenericValue>(); for (String id : idList) { if (Debug.infoOn()) Debug.logInfo("in indexContentList, id:" + id, module); try { 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=1518980&r1=1518979&r2=1518980&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 Fri Aug 30 14:37:20 2013 @@ -20,11 +20,12 @@ package org.ofbiz.content.test; import java.io.File; +import java.lang.Object; +import java.lang.String; +import java.util.HashMap; import java.util.List; import java.util.Map; -import javolution.util.FastMap; - import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.DirectoryReader; @@ -60,7 +61,7 @@ public class LuceneTests extends OFBizTe } public void testCreateIndex() throws Exception { - Map<String, Object> ctx = FastMap.newInstance(); + Map<String, Object> ctx = new HashMap<String, Object>(); ctx.put("contentId", "WebStoreCONTENT"); ctx.put("userLogin", userLogin); Map<String, Object> resp = dispatcher.runSync("indexTree", ctx); |
Free forum by Nabble | Edit this page |