You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2014/10/24 10:22:57 UTC

svn commit: r1634024 [1/3] - in /ofbiz/trunk/applications/content/src/org/ofbiz/content: ./ blog/ cms/ compdoc/ content/ data/ layout/ survey/ view/ webapp/ftl/

Author: lektran
Date: Fri Oct 24 08:22:56 2014
New Revision: 1634024

URL: http://svn.apache.org/r1634024
Log:
Convert content app's java file from Delegator usage to EntityQuery

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentKeywordIndex.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentSearch.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementEvents.java Fri Oct 24 08:22:56 2014
@@ -40,6 +40,7 @@ import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.security.Security;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -194,7 +195,7 @@ public class ContentManagementEvents {
         List<Object []> origPublishedLinkList = null;
         try {
             // TODO: this needs to be given author userLogin
-            delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", authorId), true);
+            EntityQuery.use(delegator).from("UserLogin").where("userLoginId", authorId).cache().queryOne();
             origPublishedLinkList = ContentManagementWorker.getPublishedLinks(delegator, targContentId, webSiteId, userLogin, security, permittedAction, permittedOperations, roles);
         } catch (GenericEntityException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -254,7 +255,12 @@ public class ContentManagementEvents {
                     if (!currentSubContentId.equals(origSubContentId)) {
                         // disable existing link
                         if (UtilValidate.isNotEmpty(origSubContentId) && origFromDate != null) {
-                            List<GenericValue> oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null), null, false);
+                            List<GenericValue> oldActiveValues = EntityQuery.use(delegator).from("ContentAssoc")
+                                    .where("contentId", targContentId, 
+                                            "contentIdTo", origSubContentId, 
+                                            "contentAssocTypeId", "PUBLISH_LINK", 
+                                            "thruDate", null)
+                                    .queryList();
                             for (GenericValue cAssoc : oldActiveValues) {
                                 cAssoc.set("thruDate", nowTimestamp);
                                 cAssoc.store();
@@ -295,7 +301,7 @@ public class ContentManagementEvents {
                         //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, results(3b):" + results , module);
                         if (!statusIdUpdated) {
                             try {
-                                GenericValue targContent = delegator.findOne("Content", UtilMisc.toMap("contentId", targContentId), false);
+                                GenericValue targContent = EntityQuery.use(delegator).from("Content").where("contentId", targContentId).queryOne();
                                 targContent.set("statusId", "CTNT_PUBLISHED");
                                 targContent.store();
                                 statusIdUpdated = true;
@@ -308,12 +314,12 @@ public class ContentManagementEvents {
                     }
                 } else if (UtilValidate.isNotEmpty(origSubContentId)) {
                     // if no current link is passed in, look to see if there is an existing link(s) that must be disabled
-                    List<GenericValue> oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", origSubContentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null), null, false);
-                    for (GenericValue cAssoc : oldActiveValues) {
-                        cAssoc.set("thruDate", nowTimestamp);
-                        cAssoc.store();
-                    }
-                    oldActiveValues = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentIdTo", contentId, "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null), null, false);
+                    List<GenericValue> oldActiveValues = EntityQuery.use(delegator).from("ContentAssoc")
+                            .where("contentId", targContentId, 
+                                    "contentIdTo", origSubContentId, 
+                                    "contentAssocTypeId", "PUBLISH_LINK", 
+                                    "thruDate", null)
+                            .queryList();
                     for (GenericValue cAssoc : oldActiveValues) {
                         cAssoc.set("thruDate", nowTimestamp);
                         cAssoc.store();

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java Fri Oct 24 08:22:56 2014
@@ -48,6 +48,7 @@ import org.ofbiz.entity.condition.Entity
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.model.ModelUtil;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.security.Security;
 import org.ofbiz.service.DispatchContext;
@@ -292,7 +293,7 @@ public class ContentManagementServices {
                 contentExists = false;
             } else {
                 try {
-                    GenericValue val = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                    GenericValue val = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
                     if (val == null) contentExists = false;
                 } catch (GenericEntityException e) {
                     return ServiceUtil.returnError(e.toString());
@@ -382,7 +383,7 @@ public class ContentManagementServices {
             contentAssocContext.put("skipPermissionCheck", context.get("skipPermissionCheck"));
             Map<String, Object> thisResult = null;
             try {
-                GenericValue contentAssocExisting = delegator.findOne("ContentAssoc", contentAssoc.getPrimaryKey(), false);
+                GenericValue contentAssocExisting = EntityQuery.use(delegator).from("ContentAssoc").where(contentAssoc.getPrimaryKey()).queryOne();
                 if (contentAssocExisting == null) {
                     ModelService contentAssocModel = dispatcher.getDispatchContext().getModelService("createContentAssoc");
                     Map<String, Object> ctx = contentAssocModel.makeValid(contentAssoc, "IN");
@@ -465,7 +466,7 @@ public class ContentManagementServices {
 
       List<GenericValue> siteRoles = null;
       try {
-          siteRoles = delegator.findByAnd("RoleType", UtilMisc.toMap("parentTypeId", "BLOG"), null, true);
+          siteRoles = EntityQuery.use(delegator).from("RoleType").where("parentTypeId", "BLOG").cache().queryList();
       } catch (GenericEntityException e) {
           return ServiceUtil.returnError(e.toString());
       }
@@ -556,7 +557,7 @@ public class ContentManagementServices {
       Locale locale = (Locale) context.get("locale");
       Map<String, Object> result = FastMap.newInstance();
       try {
-          //GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+          //GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
           ModelService checkPermModel = dispatcher.getDispatchContext().getModelService("checkContentPermission");
           Map<String, Object> ctx = checkPermModel.makeValid(context, "IN");
           Map<String, Object> thisResult = dispatcher.runSync("checkContentPermission", ctx);
@@ -613,7 +614,7 @@ public class ContentManagementServices {
           dataResourceExists = false;
       } else {
           try {
-              GenericValue val = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+              GenericValue val = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
               if (val == null) {
                   dataResourceExists = false;
               }
@@ -765,9 +766,7 @@ public class ContentManagementServices {
     }
 
     public static void addRoleToUser(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> serviceContext) throws GenericServiceException, GenericEntityException {
-        String partyId = (String)serviceContext.get("partyId");
-        Map<String, Object> findMap = UtilMisc.<String, Object>toMap("partyId", partyId);
-        List<GenericValue> userLoginList = delegator.findByAnd("UserLogin", findMap, null, false);
+        List<GenericValue> userLoginList = EntityQuery.use(delegator).from("UserLogin").where("partyId", serviceContext.get("partyId")).queryList();
         for (GenericValue partyUserLogin : userLoginList) {
             String partyUserLoginId = partyUserLogin.getString("userLoginId");
             serviceContext.put("contentId", partyUserLoginId); // author contentId
@@ -794,7 +793,7 @@ public class ContentManagementServices {
 
         List<GenericValue> siteRoles = null;
         try {
-            siteRoles = delegator.findByAnd("RoleType", UtilMisc.toMap("parentTypeId", "BLOG"), null, true);
+            siteRoles = EntityQuery.use(delegator).from("RoleType").where("parentTypeId", "BLOG").cache().queryList();
         } catch (GenericEntityException e) {
           return ServiceUtil.returnError(e.toString());
         }
@@ -876,7 +875,7 @@ public class ContentManagementServices {
             if (Debug.infoOn()) {
                 Debug.logInfo("in updateOrRemove, entityValuePK:" + entityValuePK, module);
             }
-            GenericValue entityValueExisting = delegator.findOne(entityName, entityValuePK, true);
+            GenericValue entityValueExisting = EntityQuery.use(delegator).from(entityName).where(entityValuePK).cache().queryOne();
             if (Debug.infoOn()) {
                 Debug.logInfo("in updateOrRemove, entityValueExisting:" + entityValueExisting, module);
             }
@@ -925,14 +924,16 @@ public class ContentManagementServices {
         EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
         EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentIdTo), conditionType), EntityOperator.AND);
         try {
-            List<GenericValue> listAll = delegator.findList("ContentAssoc", conditionMain, null, UtilMisc.toList("sequenceNum", "fromDate", "createdDate"), null, false);
-            List<GenericValue> listFiltered = EntityUtil.filterByDate(listAll);
+            List<GenericValue> listAll = EntityQuery.use(delegator).from("ContentAssoc")
+                    .where(conditionMain)
+                    .orderBy("sequenceNum", "fromDate", "createdDate")
+                    .filterByDate().queryList();
             String contentId = (String)context.get("contentId");
             String dir = (String)context.get("dir");
             int seqNum = seqIncrement;
             String thisContentId = null;
-            for (int i=0; i < listFiltered.size(); i++) {
-                GenericValue contentAssoc = listFiltered.get(i);
+            for (int i=0; i < listAll.size(); i++) {
+                GenericValue contentAssoc = listAll.get(i);
                 if (UtilValidate.isNotEmpty(contentId) && UtilValidate.isNotEmpty(dir)) {
                     // move targeted entry up or down
                     thisContentId = contentAssoc.getString("contentId");
@@ -941,7 +942,7 @@ public class ContentManagementServices {
                             if (i > 0) {
                                 // Swap with previous entry
                                 try {
-                                    GenericValue prevValue = listFiltered.get(i-1);
+                                    GenericValue prevValue = listAll.get(i-1);
                                     Long prevSeqNum = (Long)prevValue.get("sequenceNum");
                                     prevValue.put("sequenceNum", Long.valueOf(seqNum));
                                     prevValue.store();
@@ -952,9 +953,9 @@ public class ContentManagementServices {
                                 }
                             }
                         } else {
-                            if (i < listFiltered.size()) {
+                            if (i < listAll.size()) {
                                 // Swap with next entry
-                                GenericValue nextValue = listFiltered.get(i+1);
+                                GenericValue nextValue = listAll.get(i+1);
                                 nextValue.put("sequenceNum", Long.valueOf(seqNum));
                                 nextValue.store();
                                 seqNum += seqIncrement;
@@ -990,7 +991,7 @@ public class ContentManagementServices {
         Locale locale = (Locale) context.get("locale");
         //int seqNum = 9999;
         try {
-            GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             if (content == null) {
                 Debug.logError("content was null", module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", ""), locale));
@@ -1075,7 +1076,7 @@ public class ContentManagementServices {
         String contentId = (String)context.get("contentId");
 
         try {
-            GenericValue thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             if (thisContent == null)
                 throw new RuntimeException("No entity found for id=" + contentId);
 
@@ -1092,13 +1093,12 @@ public class ContentManagementServices {
 
            EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
            EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, thisContentId), conditionType), EntityOperator.AND);
-            List listAll = delegator.findByConditionCache("ContentAssoc", conditionMain, null, null);
-            List listFiltered = EntityUtil.filterByDate(listAll);
+            List listFiltered = EntityQuery.use(delegator).from("ContentAssoc").where(mainCondition).cache().filterByDate().queryList();
             Iterator iter = listFiltered.iterator();
             while (iter.hasNext()) {
                 GenericValue contentAssoc = (GenericValue)iter.next();
                 String subContentId = contentAssoc.getString("contentId");
-                GenericValue contentTo = delegator.findOne("Content", UtilMisc.toMap("contentId", subContentId), true);
+                GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", subContentId).cache().queryOne();
                 Integer childBranchCount = (Integer)contentTo.get("childBranchCount");
                 int branchCount = (childBranchCount == null) ? 1 : childBranchCount.intValue();
                 if (mode != null && mode.equalsIgnoreCase("remove"))
@@ -1146,7 +1146,7 @@ public class ContentManagementServices {
             contentTypeId = "OUTLINE_NODE";
         GenericValue thisContent = null;
         try {
-            thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             if (thisContent == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
             }
@@ -1186,7 +1186,7 @@ public class ContentManagementServices {
         }
         GenericValue thisContent = null;
         try {
-            thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             if (thisContent == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                         "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
@@ -1324,16 +1324,13 @@ public class ContentManagementServices {
         Map<String, Object> results = FastMap.newInstance();
         Delegator delegator = dctx.getDelegator();
         String contentIdTo = (String)context.get("contentId");
-        List<EntityExpr> condList = FastList.newInstance();
-        EntityExpr expr = EntityCondition.makeCondition("caContentIdTo", EntityOperator.EQUALS, contentIdTo);
-        condList.add(expr);
-        expr = EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.EQUALS, "SUB_CONTENT");
-        condList.add(expr);
-        expr = EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null);
-        condList.add(expr);
-        EntityConditionList<EntityExpr> entityCondList = EntityCondition.makeCondition(condList, EntityOperator.AND);
-         try {
-             List<GenericValue> lst = delegator.findList("ContentAssocDataResourceViewFrom", entityCondList, null, UtilMisc.toList("caSequenceNum", "caFromDate", "createdDate"), null, false);
+        try {
+             List<GenericValue> lst = EntityQuery.use(delegator).from("ContentAssocDataResourceViewFrom")
+                     .where("caContentIdTo", contentIdTo,
+                             "caContentAssocTypeId", "SUB_CONTENT",
+                             "caThruDate", null)
+                     .orderBy("caSequenceNum", "caFromDate", "createdDate")
+                     .queryList();
              results.put("_LIST_", lst);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
@@ -1387,7 +1384,7 @@ public class ContentManagementServices {
         String contentAssocTypeId = (String)context.get("contentAssocTypeId");
 
         try {
-            GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+            GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
             if (content == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
             }
@@ -1413,7 +1410,7 @@ public class ContentManagementServices {
         String contentAssocTypeId = (String)context.get("contentAssocTypeId");
 
         try {
-            GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+            GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
             if (content == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
             }
@@ -1467,11 +1464,12 @@ public class ContentManagementServices {
         boolean hasExistingContentRole = false;
         GenericValue contentRole = null;
         try {
-            List<GenericValue> contentRoleList = delegator.findByAnd("ContentRole", UtilMisc.toMap("partyId", partyId, "contentId", webPubPt, "roleTypeId", roleTypeId), null, true);
-            List<GenericValue> listFiltered = EntityUtil.filterByDate(contentRoleList, true);
-            List<GenericValue> listOrdered = EntityUtil.orderBy(listFiltered, UtilMisc.toList("fromDate DESC"));
-            if (listOrdered.size() > 0) {
-                contentRole = listOrdered.get(0);
+            contentRole = EntityQuery.use(delegator).from("ContentRole")
+                    .where("partyId", partyId, "contentId", webPubPt, "roleTypeId", roleTypeId)
+                    .orderBy("fromDate DESC")
+                    .cache().filterByDate()
+                    .queryFirst();
+            if (contentRole != null) {
                 hasExistingContentRole = true;
             }
         } catch (GenericEntityException e) {
@@ -1548,14 +1546,16 @@ public class ContentManagementServices {
         }
         GenericValue productContent = null;
            try {
-            List<GenericValue> lst = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "productContentTypeId", "ONLINE_ACCESS"), null, true);
-            List<GenericValue> listFiltered = EntityUtil.filterByDate(lst, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true);
-            List<GenericValue> listOrdered = EntityUtil.orderBy(listFiltered, UtilMisc.toList("purchaseFromDate", "purchaseThruDate"));
-            List<GenericValue> listThrusOnly = EntityUtil.filterOutByCondition(listOrdered, EntityCondition.makeCondition("purchaseThruDate", EntityOperator.EQUALS, null));
+            List<GenericValue> lst = EntityQuery.use(delegator).from("ProductContent")
+                    .where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
+                    .orderBy("purchaseFromDate", "purchaseThruDate")
+                    .filterByDate("purchaseFromDate", "purchaseThruDate")
+                    .cache().queryList();
+            List<GenericValue> listThrusOnly = EntityUtil.filterOutByCondition(lst, EntityCondition.makeCondition("purchaseThruDate", EntityOperator.EQUALS, null));
             if (listThrusOnly.size() > 0) {
                 productContent = listThrusOnly.get(0);
-            } else if (listOrdered.size() > 0) {
-                productContent = listOrdered.get(0);
+            } else if (lst.size() > 0) {
+                productContent = lst.get(0);
             }
         } catch (GenericEntityException e) {
             Debug.logError(e.toString(), module);
@@ -1592,9 +1592,10 @@ public class ContentManagementServices {
 
         GenericValue orderHeader = null;
         try {
-            List<GenericValue> orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"), null, false);
-            if (orderRoleList.size() > 0) {
-                GenericValue orderRole = orderRoleList.get(0);
+            GenericValue orderRole = EntityQuery.use(delegator).from("OrderRole")
+                    .where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")
+                    .queryFirst();
+            if (orderRole != null) {
                 String partyId = (String) orderRole.get("partyId");
                 context.put("partyId", partyId);
             } else {
@@ -1602,7 +1603,7 @@ public class ContentManagementServices {
                 return ServiceUtil.returnFailure(msg);
 
             }
-            orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+            orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
             if (orderHeader == null) {
                 String msg = "No OrderHeader found for orderId:" + orderId;
                 return ServiceUtil.returnError(msg);
@@ -1614,9 +1615,10 @@ public class ContentManagementServices {
             for (GenericValue orderItem : orderItemList) {
                 BigDecimal qty = orderItem.getBigDecimal("quantity");
                 String productId = (String) orderItem.get("productId");
-                List<GenericValue> productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "productContentTypeId", "ONLINE_ACCESS"), null, false);
-                List<GenericValue> productContentListFiltered = EntityUtil.filterByDate(productContentList);
-                if (productContentListFiltered.size() > 0) {
+                long productContentCount = EntityQuery.use(delegator).from("ProductContent")
+                        .where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
+                        .filterByDate().queryCount();
+                if (productContentCount > 0) {
                     context.put("productId", productId);
                     context.put("quantity", Integer.valueOf(qty.intValue()));
                     Map<String, Object> ctx = subscriptionModel.makeValid(context, "IN");
@@ -1655,7 +1657,7 @@ public class ContentManagementServices {
         ctx.put("contentAssocTypeIdList", contentAssocTypeIdList);
         try {
 
-            GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             result = followNodeChildrenMethod(content, dispatcher, serviceName, ctx);
         } catch (GenericEntityException e) {
             Debug.logError(e.toString(), module);
@@ -1705,7 +1707,7 @@ public class ContentManagementServices {
       }
       if (UtilValidate.isNotEmpty(oldDataResourceId)) {
           try {
-              dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", oldDataResourceId), false);
+              dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", oldDataResourceId).queryOne();
           } catch (GenericEntityException e) {
               Debug.logError(e.toString(), module);
               return ServiceUtil.returnError(e.toString());

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java Fri Oct 24 08:22:56 2014
@@ -19,6 +19,7 @@
 package org.ofbiz.content;
 
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -47,6 +48,7 @@ import org.ofbiz.entity.GenericPK;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.entityext.permission.EntityPermissionChecker;
 import org.ofbiz.minilang.MiniLangException;
@@ -265,7 +267,7 @@ public class ContentManagementWorker {
             request.setAttribute("currentPK", currentPK);
             GenericValue currentValue = null;
             try {
-                currentValue = delegator.findOne(currentPK.getEntityName(), currentPK, false);
+                currentValue = EntityQuery.use(delegator).from(currentPK.getEntityName()).where(currentPK).queryOne();
             } catch (GenericEntityException e) {
             }
             request.setAttribute("currentValue", currentValue);
@@ -315,7 +317,9 @@ public class ContentManagementWorker {
     public static List<GenericValue> getAllPublishPoints(Delegator delegator, String parentPubPt) throws GeneralException {
         List<GenericValue> relatedPubPts = null;
         try {
-            relatedPubPts = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", parentPubPt, "contentAssocTypeId", "SUBSITE"), null, true);
+            relatedPubPts = EntityQuery.use(delegator).from("ContentAssoc")
+                    .where("contentIdTo", parentPubPt, "contentAssocTypeId", "SUBSITE")
+                    .cache().queryList();
         } catch (GenericEntityException e) {
             throw new GeneralException(e.getMessage());
         }
@@ -323,7 +327,7 @@ public class ContentManagementWorker {
         GenericValue webSitePublishPoint = null;
         for (GenericValue contentAssoc : relatedPubPts) {
            String pub = (String)contentAssoc.get("contentId");
-           //webSitePublishPoint = delegator.findOne("WebSitePublishPoint", UtilMisc.toMap("contentId", pub), true);
+           //webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", pub).cache().queryOne();
            webSitePublishPoint = getWebSitePublishPoint(delegator, pub, false);
            allPublishPoints.add(webSitePublishPoint);
         }
@@ -362,7 +366,7 @@ public class ContentManagementWorker {
     public static List<Map<String, Object>> getStaticValues(Delegator delegator,  String parentPlaceholderId, List<String []> permittedPublishPointList) throws GeneralException {
         List<GenericValue> assocValueList = null;
         try {
-            assocValueList = delegator.findByAnd("Content", UtilMisc.toMap("contentTypeId", parentPlaceholderId), null, true);
+            assocValueList = EntityQuery.use(delegator).from("Content").where("contentTypeId", parentPlaceholderId).cache().queryList();
         } catch (GenericEntityException e) {
             throw new GeneralException(e.getMessage());
         }
@@ -406,7 +410,7 @@ public class ContentManagementWorker {
             webSitePublishPoint = cachedWebSitePublishPoints.get(contentId);
 
         if (webSitePublishPoint == null) {
-            webSitePublishPoint = delegator.findOne("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId), false);
+            webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).queryOne();
             // If no webSitePublishPoint exists, still try to look for parent by making a dummy value
             if (webSitePublishPoint == null) {
                 webSitePublishPoint = delegator.makeValue("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId));
@@ -425,7 +429,7 @@ public class ContentManagementWorker {
             //if (Debug.infoOn()) Debug.logInfo("in overrideWebSitePublishPoint, contentIdTo:" + contentIdTo, module);
         if (contentIdTo != null) {
             //webSitePublishPoint = getWebSitePublishPoint(delegator, contentIdTo, false);
-            webSitePublishPoint = delegator.findOne("WebSitePublishPoint", UtilMisc.toMap("contentId", contentIdTo), true);
+            webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentIdTo).cache().queryOne();
             if (webSitePublishPoint != null) {
                 webSitePublishPoint = GenericValue.create(webSitePublishPoint);
                 webSitePublishPoint = overrideWebSitePublishPoint(delegator, webSitePublishPoint);
@@ -440,18 +444,17 @@ public class ContentManagementWorker {
     public static GenericValue getParentWebSitePublishPointValue(Delegator delegator, String  contentId) throws GenericEntityException {
 
         String contentIdTo = getParentWebSitePublishPointId(delegator, contentId);
-        GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentIdTo), true);
+        GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentIdTo).cache().queryOne();
         return content;
     }
 
     public static String getParentWebSitePublishPointId(Delegator delegator, String  contentId) throws GenericEntityException {
         String contentIdTo = null;
-        List<GenericValue> contentAssocList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentAssocTypeId", "SUBSITE"), null, true);
-        List<GenericValue> filteredContentAssocList = EntityUtil.filterByDate(contentAssocList);
-        if (filteredContentAssocList.size() > 0) {
-            GenericValue contentAssoc = filteredContentAssocList.get(0);
-            if (contentAssoc != null)
-                contentIdTo = contentAssoc.getString("contentIdTo");
+        GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc")
+                .where("contentId", contentId, "contentAssocTypeId", "SUBSITE")
+                .filterByDate().cache().queryFirst();
+        if (contentAssoc != null) {
+            contentIdTo = contentAssoc.getString("contentIdTo");
         }
         return contentIdTo;
     }
@@ -470,7 +473,7 @@ public class ContentManagementWorker {
 
 /*
         if (webSitePublishPoint == null) {
-            webSitePublishPoint = delegator.findOne("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId), false);
+            webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).queryOne();
             // If no webSitePublishPoint exists, still try to look for parent by making a dummy value
             if (webSitePublishPoint == null) {
                 webSitePublishPoint = delegator.makeValue("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId));
@@ -517,8 +520,9 @@ public class ContentManagementWorker {
 /* */
         List<GenericValue> assocValueList = null;
         try {
-            List<GenericValue> rawAssocValueList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", targContentId, "contentAssocTypeId", "PUBLISH_LINK"), null, true);
-            assocValueList = EntityUtil.filterByDate(rawAssocValueList);
+            assocValueList = EntityQuery.use(delegator).from("ContentAssoc")
+                    .where("contentId", targContentId, "contentAssocTypeId", "PUBLISH_LINK")
+                    .filterByDate().cache().queryList();
         } catch (GenericEntityException e) {
             throw new GeneralException(e.getMessage());
         }
@@ -616,7 +620,9 @@ public class ContentManagementWorker {
     public static List<GenericValue> getAllDepartmentContent(Delegator delegator, String parentPubPt) throws GeneralException {
         List<GenericValue> relatedPubPts = null;
         try {
-            relatedPubPts = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", parentPubPt, "contentAssocTypeId", "DEPARTMENT"), null, true);
+            relatedPubPts = EntityQuery.use(delegator).from("ContentAssoc")
+                    .where("contentIdTo", parentPubPt, "contentAssocTypeId", "DEPARTMENT")
+                    .cache().queryList();
 
         } catch (GenericEntityException e) {
             throw new GeneralException(e.getMessage());
@@ -625,7 +631,7 @@ public class ContentManagementWorker {
         GenericValue departmentContent = null;
         for (GenericValue contentAssoc : relatedPubPts) {
            String pub = (String)contentAssoc.get("contentId");
-           departmentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", pub), true);
+           departmentContent = EntityQuery.use(delegator).from("Content").where("contentId", pub).cache().queryOne();
            allDepartmentPoints.add(departmentContent);
         }
         return allDepartmentPoints;
@@ -634,7 +640,7 @@ public class ContentManagementWorker {
     public static String getUserName(HttpServletRequest request, String userLoginId) throws GenericEntityException {
         String userName = null;
         Delegator delegator = (Delegator)request.getAttribute("delegator");
-        GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), true);
+        GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).cache().queryOne();
         GenericValue person = userLogin.getRelatedOne("Person", true);
         userName = person.getString("firstName") + " " + person.getString("lastName");
         return userName;
@@ -642,28 +648,26 @@ public class ContentManagementWorker {
 
     public static int updateStatsTopDown(Delegator delegator, String contentId, List<String> typeList) throws GenericEntityException {
         int subLeafCount = 0;
-        GenericValue thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+        GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
         if (thisContent == null)
             throw new RuntimeException("No entity found for id=" + contentId);
 
-       EntityCondition conditionMain = null;
+       List<EntityCondition> conditionMain = new ArrayList<EntityCondition>();
+       conditionMain.add(EntityCondition.makeCondition("contentIdTo", contentId));
        if (typeList.size() > 0) {
-           EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
-           conditionMain = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId), conditionType), EntityOperator.AND);
-       } else {
-           conditionMain = EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId);
+           conditionMain.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList));
+       }
+       List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc").where(conditionMain)
+               .filterByDate().cache().queryList();
+       for (GenericValue contentAssoc : contentAssocs) {
+           String subContentId = contentAssoc.getString("contentId");
+           subLeafCount += updateStatsTopDown(delegator, subContentId, typeList);
        }
-        List<GenericValue> listAll = delegator.findList("ContentAssoc", conditionMain, null, null, null, true);
-        List<GenericValue> listFiltered = EntityUtil.filterByDate(listAll);
-        for (GenericValue contentAssoc : listFiltered) {
-            String subContentId = contentAssoc.getString("contentId");
-            subLeafCount += updateStatsTopDown(delegator, subContentId, typeList);
-        }
 
         // If no children, count this as a leaf
         if (subLeafCount == 0)
             subLeafCount = 1;
-        thisContent.put("childBranchCount", Long.valueOf(listFiltered.size()));
+        thisContent.put("childBranchCount", Long.valueOf(contentAssocs.size()));
         thisContent.put("childLeafCount", Long.valueOf(subLeafCount));
         thisContent.store();
 
@@ -671,17 +675,17 @@ public class ContentManagementWorker {
     }
 
     public static void updateStatsBottomUp(Delegator delegator, String contentId, List<String> typeList, int branchChangeAmount, int leafChangeAmount) throws GenericEntityException {
-        GenericValue thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+        GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
         if (thisContent == null)
             throw new RuntimeException("No entity found for id=" + contentId);
 
-        EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
-        EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId), conditionType), EntityOperator.AND);
-        List<GenericValue> listAll = delegator.findList("ContentAssoc", conditionMain, null, null, null, true);
-        List<GenericValue> listFiltered = EntityUtil.filterByDate(listAll);
-        for (GenericValue contentAssoc : listFiltered) {
+        List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc")
+                .where(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList),
+                        EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId))
+                .cache().filterByDate().queryList();
+        for (GenericValue contentAssoc : contentAssocs) {
             String contentIdTo = contentAssoc.getString("contentIdTo");
-            GenericValue contentTo = delegator.findOne("Content", UtilMisc.toMap("contentId", contentIdTo), false);
+            GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", contentIdTo).queryOne();
             int intLeafCount = 0;
             Long leafCount = (Long)contentTo.get("childLeafCount");
             if (leafCount != null) {

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ConvertTree.java Fri Oct 24 08:22:56 2014
@@ -34,6 +34,7 @@ import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -123,7 +124,6 @@ In order ta make this service active add
                                 String check = "\\", checkSubContent = ",", contentName = "", contentNameInprogress = "", data = line.substring(3, size);
                                 //Debug.logInfo("======Data======"+data);
                                 size = data.length();
-                                List<GenericValue> contents = null;
 
                                 for (int index = 0; index< size; index++) {//start character in line
                                     boolean contentNameMatch = false;
@@ -135,21 +135,21 @@ In order ta make this service active add
                                             contentName = contentName.substring(0, 100);
                                         }
                                         //check duplicate folder
-                                        contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName), null, false);
-                                        if (contents.size() > 0) {
-                                            GenericValue contentResult = contents.get(0);
-                                            contentId = contentResult.get("contentId").toString();
+                                        GenericValue content = EntityQuery.use(delegator).from("Content").where("contentName", contentName).queryFirst();
+                                        if (content != null) {
+                                            contentId = content.getString("contentId");
                                         }
-                                        if (contents.size() > 0 && hasFolder==true) {
-                                            GenericValue contentResult = contents.get(0);
-                                            contentId = contentResult.get("contentId").toString();
+                                        if (content != null && hasFolder==true) {
                                             if (rootContent != null) {
-                                                contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent), null, false);
-                                                List<GenericValue> contentAssocCheck = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", rootContent), null, false);
+                                                contentAssocs = EntityQuery.use(delegator).from("ContentAssoc")
+                                                        .where("contentId", contentId, "contentIdTo", rootContent)
+                                                        .queryList();
+                                                List<GenericValue> contentAssocCheck = EntityQuery.use(delegator).from("ContentAssoc").where("contentIdTo", rootContent).queryList();
+
                                                 Iterator<GenericValue> contentAssChecks = contentAssocCheck.iterator();
                                                 while (contentAssChecks.hasNext() && contentNameMatch == false) {
                                                     GenericValue contentAss = contentAssChecks.next();
-                                                    GenericValue contentcheck = delegator.findOne("Content", UtilMisc.toMap("contentId", contentAss.get("contentId")), false);
+                                                    GenericValue contentcheck = EntityQuery.use(delegator).from("Content").where("contentId", contentAss.get("contentId")).queryOne();
                                                     if (contentcheck!=null) {
                                                         if (contentcheck.get("contentName").equals(contentName) && contentNameMatch == false) {
                                                             contentNameMatch = true;
@@ -159,7 +159,9 @@ In order ta make this service active add
                                                 }
                                             } else {
                                                 rootContent = "HOME_DUCUMENT";
-                                                contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent), null, false);
+                                                contentAssocs = EntityQuery.use(delegator).from("ContentAssoc")
+                                                        .where("contentId", contentId, "contentIdTo", rootContent)
+                                                        .queryList();
                                             }
                                             contentAssocSize = contentAssocs.size();
                                         }
@@ -174,10 +176,6 @@ In order ta make this service active add
                                             Entity.set("createdByUserLogin", userLogin.get("userLoginId"));
                                             Entity.set("lastModifiedByUserLogin", userLogin.get("userLoginId"));
                                             Entity.set("createdDate", UtilDateTime.nowTimestamp());
-                                            Entity.set("lastUpdatedStamp", UtilDateTime.nowTimestamp());
-                                            Entity.set("lastUpdatedTxStamp", UtilDateTime.nowTimestamp());
-                                            Entity.set("createdStamp", UtilDateTime.nowTimestamp());
-                                            Entity.set("createdTxStamp", UtilDateTime.nowTimestamp());
                                             delegator.create(Entity);
                                             hasFolder = false;
                                         } else {
@@ -188,7 +186,12 @@ In order ta make this service active add
                                         if (rootContent == null) {
                                             rootContent = "HOME_DUCUMENT";
                                         }
-                                        contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", rootContent, "contentAssocTypeId", "TREE_CHILD"), null, false);
+                                        contentAssocs = EntityQuery.use(delegator).from("ContentAssoc")
+                                                .where("contentId", contentId, 
+                                                        "contentIdTo", rootContent,
+                                                        "contentAssocTypeId", "TREE_CHILD")
+                                                .queryList();
+
                                         if (contentAssocs.size() == 0) {
                                             contentAssoc = FastMap.newInstance();
                                             contentAssoc.put("contentId", contentId);
@@ -263,13 +266,15 @@ In order ta make this service active add
                     if (contentName.length()>100) {
                         contentName = contentName.substring(0,100);
                     }
-                    List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName), UtilMisc.toList("-contentId"), false);
+                    List<GenericValue> contents = EntityQuery.use(delegator).from("Content").where("contentName", contentName).orderBy("-contentId").queryList();
                     if (contents != null) {
                         Iterator<GenericValue> contentCheck = contents.iterator();
                         while (contentCheck.hasNext() && contentNameMatch == false) {
                             GenericValue contentch = contentCheck.next();
                             if (contentch != null) {
-                                List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentch.get("contentId"), "contentIdTo", rootContent), null, false);
+                                List<GenericValue> contentAssocsChecks = EntityQuery.use(delegator).from("ContentAssoc")
+                                        .where("contentId", contentch.get("contentId"), "contentIdTo", rootContent)
+                                        .queryList();
                                 if (contentAssocsChecks.size() > 0) {
                                     contentNameMatch = true;
                                 }
@@ -323,14 +328,16 @@ In order ta make this service active add
                 //lastItem
                 if (index == size - 1) {
                     contentNameMatch = false;
-                    List<GenericValue> contents = delegator.findByAnd("Content", UtilMisc.toMap("contentName", contentName), null, false);
+                    List<GenericValue> contents = EntityQuery.use(delegator).from("Content").where("contentName", contentName).queryList();
                     if (contents != null) {
                         Iterator<GenericValue> contentCheck = contents.iterator();
                         while (contentCheck.hasNext() && contentNameMatch == false) {
                             GenericValue contentch = contentCheck.next();
                             if (contentch != null) {
-                                List<GenericValue> contentAssocsChecks = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentch.get("contentId"), "contentIdTo", rootContent), null, false);
-                                if (contentAssocsChecks.size() > 0) {
+                                long contentAssocCount = EntityQuery.use(delegator).from("ContentAssoc")
+                                        .where("contentId", contentch.get("contentId"), "contentIdTo", rootContent)
+                                        .queryCount();
+                                if (contentAssocCount > 0) {
                                     contentNameMatch = true;
                                 }
                             }

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java Fri Oct 24 08:22:56 2014
@@ -36,6 +36,7 @@ import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
@@ -74,7 +75,7 @@ public class BlogRssServices {
         // get the main blog content
         GenericValue content = null;
         try {
-            content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+            content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
         }
@@ -101,14 +102,14 @@ public class BlogRssServices {
 
     public static List<SyndEntry> generateEntryList(LocalDispatcher dispatcher, Delegator delegator, String contentId, String entryLink, Locale locale, GenericValue userLogin) {
         List<SyndEntry> entries = FastList.newInstance();
-        List<EntityCondition> exprs = FastList.newInstance();
-        exprs.add(EntityCondition.makeCondition("contentIdStart", contentId));
-        exprs.add(EntityCondition.makeCondition("caContentAssocTypeId", "PUBLISH_LINK"));
-        exprs.add(EntityCondition.makeCondition("statusId", "CTNT_PUBLISHED"));
 
         List<GenericValue> contentRecs = null;
         try {
-            contentRecs = delegator.findList("ContentAssocViewTo", EntityCondition.makeCondition(exprs), null, UtilMisc.toList("-caFromDate"), null, false);
+            contentRecs = EntityQuery.use(delegator).from("ContentAssocViewTo")
+                    .where("contentIdStart", contentId,
+                           "caContentAssocTypeId", "PUBLISH_LINK",
+                           "statusId", "CTNT_PUBLISHED")
+                    .orderBy("-caFromDate").queryList();
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
         }

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java Fri Oct 24 08:22:56 2014
@@ -43,6 +43,7 @@ import org.ofbiz.content.content.Content
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.webapp.control.RequestHandler;
@@ -116,15 +117,14 @@ public class CmsEvents {
 
         // if path info is null; check for a default content
         if (pathInfo == null) {
-            List<GenericValue> defaultContents = null;
+            GenericValue defaultContent = null;
             try {
-                defaultContents = delegator.findByAnd("WebSiteContent", UtilMisc.toMap("webSiteId", webSiteId,
-                        "webSiteContentTypeId", "DEFAULT_PAGE"), UtilMisc.toList("-fromDate"), true);
+                defaultContent = EntityQuery.use(delegator).from("WebSiteContent")
+                        .where("webSiteId", webSiteId, "webSiteContentTypeId", "DEFAULT_PAGE")
+                        .orderBy("-fromDate").filterByDate().cache().queryFirst();
             } catch (GenericEntityException e) {
                 Debug.logError(e, module);
             }
-            defaultContents = EntityUtil.filterByDate(defaultContents);
-            GenericValue defaultContent = EntityUtil.getFirst(defaultContents);
             if (defaultContent != null) {
                 pathInfo = defaultContent.getString("contentId");
             }
@@ -143,7 +143,7 @@ public class CmsEvents {
 
             GenericValue pathAlias = null;
             try {
-                pathAlias = delegator.findOne("WebSitePathAlias", UtilMisc.toMap("webSiteId", webSiteId, "pathAlias", pathInfo), true);
+                pathAlias = EntityQuery.use(delegator).from("WebSitePathAlias").where("webSiteId", webSiteId, "pathAlias", pathInfo).cache().queryOne();
             } catch (GenericEntityException e) {
                 Debug.logError(e, module);
             }
@@ -197,30 +197,32 @@ public class CmsEvents {
 
             // We try to find a specific Error page for this website concerning the status code
             if (statusCode != HttpServletResponse.SC_OK) {
-                List<GenericValue> errorContainers = null;
+                GenericValue errorContainer = null;
                 try {
-                    errorContainers = delegator.findByAnd("WebSiteContent",
-                            UtilMisc.toMap("webSiteId", webSiteId, "webSiteContentTypeId", "ERROR_ROOT"),
-                            UtilMisc.toList("-fromDate"), true);
+                    errorContainer = EntityQuery.use(delegator).from("WebSiteContent")
+                            .where("webSiteId", webSiteId, "webSiteContentTypeId", "ERROR_ROOT")
+                            .orderBy("fromDate").filterByDate().cache().queryFirst();
                 } catch (GenericEntityException e) {
                     Debug.logError(e, module);
                 }
 
-                errorContainers = EntityUtil.filterByDate(errorContainers);
-                if (UtilValidate.isNotEmpty(errorContainers)) {
-                    if (Debug.verboseOn()) Debug.logVerbose("Found error containers: " + errorContainers, module);
-                    GenericValue errorContainer = EntityUtil.getFirst(errorContainers);
+                if (errorContainer != null) {
+                    if (Debug.verboseOn()) Debug.logVerbose("Found error containers: " + errorContainer, module);
 
-                    List<GenericValue> errorPages = null;
+                    GenericValue errorPage = null;
                     try {
-                        errorPages = delegator.findByAnd("ContentAssocViewTo", UtilMisc.toMap("contentIdStart", errorContainer.getString("contentId"), "caContentAssocTypeId", "TREE_CHILD", "contentTypeId", "DOCUMENT", "caMapKey", String.valueOf(statusCode)), null, false);
+                        errorPage = EntityQuery.use(delegator).from("ContentAssocViewTo")
+                                .where("contentIdStart", errorContainer.getString("contentId"),
+                                        "caContentAssocTypeId", "TREE_CHILD",
+                                        "contentTypeId", "DOCUMENT",
+                                        "caMapKey", String.valueOf(statusCode))
+                                .filterByDate().queryFirst();
                     } catch (GenericEntityException e) {
                         Debug.logError(e, module);
                     }
-                    errorPages = EntityUtil.filterByDate(errorPages);
-                    if (UtilValidate.isNotEmpty(errorPages)) {
-                        if (Debug.verboseOn()) Debug.logVerbose("Found error pages " + statusCode + " : " + errorPages, module);
-                        contentId = EntityUtil.getFirst(errorPages).getString("contentId");
+                    if (errorPage != null) {
+                        if (Debug.verboseOn()) Debug.logVerbose("Found error pages " + statusCode + " : " + errorPage, module);
+                        contentId = errorPage.getString("contentId");
                     } else {
                         if (Debug.verboseOn()) Debug.logVerbose("No specific error page, falling back to the Error Container for " + statusCode, module);
                         contentId = errorContainer.getString("contentId");
@@ -231,7 +233,7 @@ public class CmsEvents {
                 // We try to find a generic content Error page concerning the status code
                 if (!hasErrorPage) {
                     try {
-                        GenericValue errorPage = delegator.findOne("Content", UtilMisc.toMap("contentId", "CONTENT_ERROR_" + statusCode), true);
+                        GenericValue errorPage = EntityQuery.use(delegator).from("Content").where("contentId", "CONTENT_ERROR_" + statusCode).cache().queryOne();
                         if (errorPage != null) {
                             Debug.logVerbose("Found generic page " + statusCode, module);
                             contentId = errorPage.getString("contentId");
@@ -269,8 +271,7 @@ public class CmsEvents {
                     templateMap.put("formStringRenderer", formStringRenderer);
                     
                     // if use web analytics
-                    List<GenericValue> webAnalytics = delegator.findByAnd("WebAnalyticsConfig", UtilMisc.toMap("webSiteId", webSiteId), null, false);
-                    
+                    List<GenericValue> webAnalytics = EntityQuery.use(delegator).from("WebAnalyticsConfig").where("webSiteId", webSiteId).queryList();
                     // render
                     if (UtilValidate.isNotEmpty(webAnalytics) && hasErrorPage) {
                         ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", null, null, true, webAnalytics);
@@ -293,14 +294,14 @@ public class CmsEvents {
                 String contentName = null;
                 String siteName = null;
                 try {
-                    GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+                    GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
                     if (content != null && UtilValidate.isNotEmpty(content)) {
                         contentName = content.getString("contentName");
                     } else {
                         request.setAttribute("_ERROR_MESSAGE_", "Content: " + contentName + " [" + contentId + "] is not a publish point for the current website: [" + webSiteId + "]");
                         return "error";
                     }
-                    siteName = delegator.findOne("WebSite", UtilMisc.toMap("webSiteId", webSiteId), true).getString("siteName");
+                    siteName = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne().getString("siteName");
                 } catch (GenericEntityException e) {
                     Debug.logError(e, module);
                 }
@@ -311,7 +312,7 @@ public class CmsEvents {
         String siteName = null;
         GenericValue webSite = null;
         try {
-            webSite = delegator.findOne("WebSite", UtilMisc.toMap("webSiteId", webSiteId), true);
+            webSite = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne();
             if (webSite != null) {
             	siteName = webSite.getString("siteName");
             }
@@ -334,9 +335,9 @@ public class CmsEvents {
         List<GenericValue> publishPoints = null;
         boolean hadContent = false;
         try {
-            publishPoints = delegator.findByAnd("WebSiteContent",
-                    UtilMisc.toMap("webSiteId", webSiteId, "contentId", contentId, "webSiteContentTypeId", "PUBLISH_POINT"),
-                    UtilMisc.toList("-fromDate"), true);
+            publishPoints = EntityQuery.use(delegator).from("WebSiteContent")
+                    .where("webSiteId", webSiteId, "contentId", contentId, "webSiteContentTypeId", "PUBLISH_POINT")
+                    .orderBy("-fromDate").cache().queryList();
         } catch (GenericEntityException e) {
             throw e;
         }
@@ -350,9 +351,9 @@ public class CmsEvents {
         } else {
             // the passed in contentId is not a publish point for the web site;
             // however we will publish its content if it is a node of one of the trees that have a publish point as the root
-            List<GenericValue> topLevelContentValues = delegator.findByAnd("WebSiteContent",
-                UtilMisc.toMap("webSiteId", webSiteId, "webSiteContentTypeId", "PUBLISH_POINT"), UtilMisc.toList("-fromDate"), true);
-            topLevelContentValues = EntityUtil.filterByDate(topLevelContentValues);
+            List<GenericValue> topLevelContentValues = EntityQuery.use(delegator).from("WebSiteContent")
+                    .where("webSiteId", webSiteId, "webSiteContentTypeId", "PUBLISH_POINT")
+                    .orderBy("-fromDate").cache().filterByDate().queryList();
 
             if (topLevelContentValues != null) {
                 for (GenericValue point: topLevelContentValues) {
@@ -376,15 +377,17 @@ public class CmsEvents {
     }
 
     protected static int verifySubContent(Delegator delegator, String contentId, String contentIdFrom) throws GeneralException {
-        List<GenericValue> contentAssoc = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdFrom, "contentIdTo", contentId, "contentAssocTypeId", "SUB_CONTENT"), null, true);
+        List<GenericValue> contentAssoc = EntityQuery.use(delegator).from("ContentAssoc")
+                .where("contentId", contentIdFrom, "contentIdTo", contentId, "contentAssocTypeId", "SUB_CONTENT")
+                .cache().queryList();
+
         boolean hadContent = false;
         if (UtilValidate.isNotEmpty(contentAssoc)) {
             hadContent = true;
         }
         contentAssoc = EntityUtil.filterByDate(contentAssoc);
         if (UtilValidate.isEmpty(contentAssoc)) {
-            List<GenericValue> assocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdFrom), null, true);
-            assocs = EntityUtil.filterByDate(assocs);
+            List<GenericValue> assocs = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdFrom).cache().filterByDate().queryList();
             if (assocs != null) {
                 for (GenericValue assoc : assocs) {
                     int subContentStatusCode = verifySubContent(delegator, contentId, assoc.getString("contentIdTo"));

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java Fri Oct 24 08:22:56 2014
@@ -40,6 +40,7 @@ import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelService;
@@ -79,7 +80,7 @@ public class CompDocEvents {
 
         if (UtilValidate.isNotEmpty(contentId)) {
             try {
-                delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Error running serviceName persistContentAndAssoc", module);
                 String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.error_modelservice_for_srv_name", locale);

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java Fri Oct 24 08:22:56 2014
@@ -21,17 +21,14 @@ package org.ofbiz.content.compdoc;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.sql.Timestamp;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 
 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.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -40,8 +37,8 @@ import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
-import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -85,7 +82,7 @@ public class CompDocServices {
 
         if (UtilValidate.isNotEmpty(contentId)) {
             try {
-                delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Error running serviceName persistContentAndAssoc", module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(CoreEvents.err_resource, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
@@ -147,27 +144,19 @@ public class CompDocServices {
         GenericValue userLogin = (GenericValue) context.get("userLogin");
 
         try {
-            Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
             List<EntityCondition> exprList = FastList.newInstance();
             exprList.add(EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId));
+            exprList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, "COMPDOC_PART"));
             exprList.add(EntityCondition.makeCondition("rootRevisionContentId", EntityOperator.EQUALS, contentId));
             if (UtilValidate.isNotEmpty(contentRevisionSeqId)) {
                 exprList.add(EntityCondition.makeCondition("contentRevisionSeqId", EntityOperator.LESS_THAN_EQUAL_TO, contentRevisionSeqId));
             }
-            exprList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, "COMPDOC_PART"));
-            exprList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp));
 
-            List<EntityCondition> thruList = FastList.newInstance();
-            thruList.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
-            thruList.add(EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp));
-            exprList.add(EntityCondition.makeCondition(thruList, EntityOperator.OR));
-
-            EntityConditionList<EntityCondition> conditionList = EntityCondition.makeCondition(exprList, EntityOperator.AND);
-
-            String [] fields = {"rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", "contentAssocTypeId", "fromDate", "sequenceNum"};
-            Set<String> selectFields = UtilMisc.toSetArray(fields);
-            List<String> orderByFields = UtilMisc.toList("sequenceNum");
-            List<GenericValue> compDocParts = delegator.findList("ContentAssocRevisionItemView", conditionList, selectFields, orderByFields, null, false);
+            List<GenericValue> compDocParts = EntityQuery.use(delegator)
+                    .select("rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", "contentAssocTypeId", "fromDate", "sequenceNum")
+                    .from("ContentAssocRevisionItemView")
+                    .where(exprList)
+                    .orderBy("sequenceNum").filterByDate().queryList();
 
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             Document document = new Document();
@@ -176,12 +165,12 @@ public class CompDocServices {
             //PdfWriter writer = PdfWriter.getInstance(document, baos);
             PdfCopy writer = new PdfCopy(document, baos);
             document.open();
-            int pgCnt =0;
+            int pgCnt = 0;
             for (GenericValue contentAssocRevisionItemView : compDocParts) {
                 //String thisContentId = contentAssocRevisionItemView.getString("contentId");
                 //String thisContentRevisionSeqId = contentAssocRevisionItemView.getString("maxRevisionSeqId");
                 String thisDataResourceId = contentAssocRevisionItemView.getString("dataResourceId");
-                GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", thisDataResourceId), false);
+                GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", thisDataResourceId).queryOne();
                 String inputMimeType = null;
                 if (dataResource != null) {
                     inputMimeType = dataResource.getString("mimeTypeId");
@@ -204,13 +193,13 @@ public class CompDocServices {
                     String acroFormContentId = null;
                     GenericValue surveyResponse = null;
                     if (UtilValidate.isNotEmpty(surveyResponseId)) {
-                        surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+                        surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
                         if (surveyResponse != null) {
                             surveyId = surveyResponse.getString("surveyId");
                         }
                     }
                     if (UtilValidate.isNotEmpty(surveyId)) {
-                        GenericValue survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false);
+                        GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
                         if (survey != null) {
                             acroFormContentId = survey.getString("acroFormContentId");
                             if (UtilValidate.isNotEmpty(acroFormContentId)) {
@@ -314,12 +303,12 @@ public class CompDocServices {
 
             GenericValue dataResource = null;
             if (UtilValidate.isEmpty(contentRevisionSeqId)) {
-                GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+                GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
                 dataResourceId = content.getString("dataResourceId");
                 Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
-                dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+                dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
              } else {
-                GenericValue contentRevisionItem = delegator.findOne("ContentRevisionItem", UtilMisc.toMap("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId), true);
+                GenericValue contentRevisionItem = EntityQuery.use(delegator).from("ContentRevisionItem").where("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId).cache().queryOne();
                 if (contentRevisionItem == null) {
                     throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + contentId
                                                    + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
@@ -329,7 +318,7 @@ public class CompDocServices {
                         + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
                 dataResourceId = contentRevisionItem.getString("newDataResourceId");
                 Debug.logInfo("SCVH(3)- dataResourceId:" + dataResourceId, module);
-                dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+                dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
             }
             String inputMimeType = null;
             if (dataResource != null) {
@@ -350,13 +339,13 @@ public class CompDocServices {
                 String acroFormContentId = null;
                 GenericValue surveyResponse = null;
                 if (UtilValidate.isNotEmpty(surveyResponseId)) {
-                    surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+                    surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
                     if (surveyResponse != null) {
                         surveyId = surveyResponse.getString("surveyId");
                     }
                 }
                 if (UtilValidate.isNotEmpty(surveyId)) {
-                    GenericValue survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false);
+                    GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
                     if (survey != null) {
                         acroFormContentId = survey.getString("acroFormContentId");
                         if (UtilValidate.isNotEmpty(acroFormContentId)) {

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentEvents.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentEvents.java Fri Oct 24 08:22:56 2014
@@ -32,6 +32,7 @@ import org.ofbiz.entity.GenericEntityExc
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.util.EntityQuery;
 import org.ofbiz.content.content.ContentKeywordIndex;
 import org.ofbiz.security.Security;
 
@@ -78,11 +79,12 @@ public class ContentEvents {
             // begin the transaction
             beganTx = TransactionUtil.begin(7200);
             try {
+                EntityQuery contentQuery = EntityQuery.use(delegator).from("Content");
                 if (Debug.infoOn()) {
-                    long count = delegator.findCountByCondition("Content", null, null, null);
+                    long count = contentQuery.queryCount();
                     Debug.logInfo("========== Found " + count + " contents to index ==========", module);
                 }
-                entityListIterator = delegator.find("Content", null, null, null, null, null);
+                entityListIterator = contentQuery.queryIterator();
             } catch (GenericEntityException gee) {
                 Debug.logWarning(gee, gee.getMessage(), module);
                 Map<String, String> messageMap = UtilMisc.toMap("gee", gee.toString());