Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/ContentWorker.java Tue Oct 28 08:56:02 2014 @@ -51,6 +51,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.SimpleMapProcessor; @@ -107,28 +108,31 @@ public class ContentWorker implements or // Content rendering methods // ------------------------------------- public static GenericValue findContentForRendering(Delegator delegator, String contentId, Locale locale, String partyId, String roleTypeId, boolean cache) throws GeneralException, IOException { - GenericValue content; if (UtilValidate.isEmpty(contentId)) { Debug.logError("No content ID found.", module); return null; } - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), cache); + GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache(cache).queryOne(); if (content == null) { throw new GeneralException("No content found for content ID [" + contentId + "]"); } // if the content is a PUBLISH_POINT and the data resource is not defined; get the related content if ("WEB_SITE_PUB_PT".equals(content.get("contentTypeId")) && content.get("dataResourceId") == null) { - List<GenericValue> relContentIds = delegator.findByAnd("ContentAssocDataResourceViewTo", - UtilMisc.toMap("contentIdStart", content.get("contentId"),"statusId","CTNT_PUBLISHED", - "caContentAssocTypeId", "PUBLISH_LINK"), UtilMisc.toList("caFromDate"), true); + GenericValue relContent = EntityQuery.use(delegator) + .from("ContentAssocDataResourceViewTo") + .where("contentIdStart", content.get("contentId"), + "statusId","CTNT_PUBLISHED", + "caContentAssocTypeId", "PUBLISH_LINK") + .orderBy("caFromDate") + .filterByDate("caFromDate", "caThruDate") + .cache().queryFirst(); - relContentIds = EntityUtil.filterByDate(relContentIds, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); - if (UtilValidate.isNotEmpty(relContentIds)) { - content = EntityUtil.getFirst(relContentIds); + if (relContent != null) { + content = relContent; } - if (content == null) { + if (relContent == null) { throw new GeneralException("No related content found for publish point [" + contentId + "]"); } } @@ -178,7 +182,7 @@ public class ContentWorker implements or String serviceName = content.getString("serviceName"); //Kept for backward compatibility GenericValue custMethod = null; if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) { - custMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", content.get("customMethodId")), true); + custMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", content.get("customMethodId")).cache().queryOne(); } if (custMethod != null) serviceName = custMethod.getString("customMethodName"); if (dispatcher != null && UtilValidate.isNotEmpty(serviceName)) { @@ -227,7 +231,7 @@ public class ContentWorker implements or if (!isDecorated && UtilValidate.isNotEmpty(contentDecoratorId)) { // if there is a decorator content; do not render this content; // instead render the decorator - GenericValue decorator = delegator.findOne("Content", UtilMisc.toMap("contentId", contentDecoratorId), cache); + GenericValue decorator = EntityQuery.use(delegator).from("Content").where("contentId", contentDecoratorId).cache(cache).queryOne(); if (decorator == null) { throw new GeneralException("No decorator content found for decorator contentId [" + contentDecoratorId + "]"); } @@ -286,8 +290,8 @@ public class ContentWorker implements or // This part is using an xml file as the input data and an ftl or xsl file to present it. if (UtilValidate.isNotEmpty(mimeType)) { if (mimeType.toLowerCase().indexOf("xml") >= 0) { - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); - GenericValue templateDataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", templateDataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); + GenericValue templateDataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", templateDataResourceId).cache().queryOne(); if ("FTL".equals(templateDataResource.getString("dataTemplateTypeId"))) { StringReader sr = new StringReader(textData); try { @@ -346,16 +350,14 @@ public class ContentWorker implements or Map<String,Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { // find the sub-content with matching mapKey - List<String> orderBy = UtilMisc.toList("-fromDate"); - List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId)); + List<EntityCondition> exprs = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId)); if (UtilValidate.isNotEmpty(mapKey)) { exprs.add(EntityCondition.makeCondition("mapKey", EntityOperator.EQUALS, mapKey)); } - List<GenericValue> assocs; - assocs = delegator.findList("ContentAssoc", EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy, null, cache); - assocs = EntityUtil.filterByDate(assocs); - GenericValue subContent = EntityUtil.getFirst(assocs); + GenericValue subContent = EntityQuery.use(delegator).from("ContentAssoc") + .where(exprs) + .orderBy("-fromDate").cache(cache).filterByDate().queryFirst(); if (subContent == null) { //throw new GeneralException("No sub-content found with map-key [" + mapKey + "] for content [" + contentId + "]"); @@ -762,7 +764,7 @@ public class ContentWorker implements or for (GenericValue assoc : assocList) { String contentId = (String) assoc.get(contentIdName); if (Debug.infoOn()) Debug.logInfo("contentId:" + contentId, ""); - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); if (UtilValidate.isNotEmpty(contentTypes)) { contentTypeId = content.getString("contentTypeId"); if (contentTypes.contains(contentTypeId)) { @@ -810,10 +812,8 @@ public class ContentWorker implements or expr = EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, tsThru); exprListAnd.add(expr); } - EntityConditionList<EntityExpr> contentCondList = EntityCondition.makeCondition(exprListAnd, EntityOperator.AND); Delegator delegator = currentContent.getDelegator(); - contentList = delegator.findList(contentAssocViewName, contentCondList, null, null, null, false); - return contentList; + return EntityQuery.use(delegator).from(contentAssocViewName).where(exprListAnd).queryList(); } public static List<GenericValue> getAssociations(GenericValue currentContent, String linkDir, List<String> assocTypes, String strFromDate, String strThruDate) throws GenericEntityException { @@ -844,13 +844,7 @@ public class ContentWorker implements or } exprList.add(joinExpr); if (UtilValidate.isNotEmpty(assocTypes)) { - List<EntityExpr> exprListOr = FastList.newInstance(); - for (String assocType : assocTypes) { - expr = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, assocType); - exprListOr.add(expr); - } - EntityConditionList assocExprList = EntityCondition.makeCondition(exprListOr, EntityOperator.OR); - exprList.add(assocExprList); + exprList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, assocTypes)); } if (fromDate != null) { EntityExpr fromExpr = EntityCondition.makeCondition("fromDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate); @@ -864,7 +858,7 @@ public class ContentWorker implements or thruList.add(thruExpr); EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null); thruList.add(thruExpr2); - EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR); + EntityConditionList<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR); exprList.add(thruExprList); } else if (fromDate != null) { List<EntityExpr> thruList = FastList.newInstance(); @@ -873,25 +867,19 @@ public class ContentWorker implements or thruList.add(thruExpr); EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null); thruList.add(thruExpr2); - EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR); + EntityConditionList<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR); exprList.add(thruExprList); } else { EntityExpr thruExpr2 = EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null); exprList.add(thruExpr2); } - EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND); - //if (Debug.infoOn()) Debug.logInfo(" assocExprList:" + assocExprList , ""); - List<GenericValue> relatedAssocs = delegator.findList("ContentAssoc", assocExprList, null, UtilMisc.toList("-fromDate"), null, false); - //if (Debug.infoOn()) Debug.logInfo(" relatedAssoc:" + relatedAssocs.size() , ""); - //for (int i = 0; i < relatedAssocs.size(); i++) { - //GenericValue a = (GenericValue) relatedAssocs.get(i); - //} - return relatedAssocs; + + return EntityQuery.use(delegator).from("ContentAssoc").where(exprList).orderBy("-fromDate").queryList(); } public static void getContentTypeAncestry(Delegator delegator, String contentTypeId, List<String> contentTypes) throws GenericEntityException { contentTypes.add(contentTypeId); - GenericValue contentTypeValue = delegator.findOne("ContentType", UtilMisc.toMap("contentTypeId", contentTypeId), false); + GenericValue contentTypeValue = EntityQuery.use(delegator).from("ContentType").where("contentTypeId", contentTypeId).queryOne(); if (contentTypeValue == null) return; String parentTypeId = (String) contentTypeValue.get("parentTypeId"); @@ -922,12 +910,8 @@ public class ContentWorker implements or andMap = UtilMisc.<String, Object>toMap(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId); } try { - List<GenericValue> lst = delegator.findByAnd("ContentAssoc", andMap, null, true); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst:" + lst, ""); - List<GenericValue> lst2 = EntityUtil.filterByDate(lst); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst2:" + lst2, ""); - if (lst2.size() > 0) { - GenericValue contentAssoc = lst2.get(0); + GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where(andMap).cache().filterByDate().queryFirst(); + if (contentAssoc != null) { getContentAncestry(delegator, contentAssoc.getString(contentIdOtherField), contentAssocTypeId, direction, contentAncestorList); contentAncestorList.add(contentAssoc); } @@ -949,18 +933,17 @@ public class ContentWorker implements or } if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, ""); - Map<String, Object> andMap = UtilMisc.<String, Object>toMap(contentIdField, contentId); try { - List<GenericValue> lst = delegator.findByAnd("ContentAssoc", andMap, null, true); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst:" + lst, ""); - List<GenericValue> lst2 = EntityUtil.filterByDate(lst); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst2:" + lst2, ""); - for (GenericValue contentAssoc : lst2) { + List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc") + .where(contentIdField, contentId) + .cache().filterByDate().queryList(); + for (GenericValue contentAssoc : contentAssocs) { String contentIdOther = contentAssoc.getString(contentIdOtherField); if (!contentAncestorList.contains(contentIdOther)) { getContentAncestryAll(delegator, contentIdOther, passedContentTypeId, direction, contentAncestorList); if (!contentAncestorList.contains(contentIdOther)) { - GenericValue contentTo = delegator.findOne("Content", UtilMisc.toMap("contentId", contentIdOther), true); + GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", contentIdOther).cache().queryOne(); + String contentTypeId = contentTo.getString("contentTypeId"); if (contentTypeId != null && contentTypeId.equals(passedContentTypeId)) contentAncestorList.add(contentIdOther); @@ -1004,14 +987,14 @@ public class ContentWorker implements or //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, ""); try { - List<GenericValue> lst = delegator.findByAnd("ContentAssoc", UtilMisc.toMap(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId), null, true); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst:" + lst, ""); - List<GenericValue> lst2 = EntityUtil.filterByDate(lst); - //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, lst2:" + lst2, ""); - if (lst2.size() > 0) { - GenericValue contentAssoc = lst2.get(0); + GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc") + .where(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId) + .cache().filterByDate().queryFirst(); + if (contentAssoc != null) { getContentAncestryValues(delegator, contentAssoc.getString(contentIdOtherField), contentAssocTypeId, direction, contentAncestorList); - GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentAssoc.getString(contentIdOtherField)), true); + GenericValue content = EntityQuery.use(delegator).from("Content") + .where("contentId", contentAssoc.getString(contentIdOtherField)) + .cache().queryOne(); contentAncestorList.add(content); } @@ -1082,11 +1065,11 @@ public class ContentWorker implements or view = entityList.get(0); } } else { - List<GenericValue> lst = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", subContentId), null, false); - if (UtilValidate.isEmpty(lst)) { + view = EntityQuery.use(delegator).from("ContentDataResourceView") + .where("contentId", subContentId).queryFirst(); + if (view == null) { throw new IOException("No subContent found for subContentId=." + subContentId); } - view = lst.get(0); } } catch (GenericEntityException e) { throw new IOException(e.getMessage()); @@ -1131,13 +1114,9 @@ public class ContentWorker implements or } public static GenericValue getContentCache(Delegator delegator, String contentId) throws GenericEntityException { - GenericValue view = null; - List<GenericValue> lst = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentId), null, true); - //if (Debug.infoOn()) Debug.logInfo("getContentCache, lst(2):" + lst, ""); - if (UtilValidate.isNotEmpty(lst)) { - view = lst.get(0); - } - return view; + return EntityQuery.use(delegator).from("ContentDataResourceView") + .where("contentId", contentId) + .cache().queryFirst(); } public static GenericValue getCurrentContent(Delegator delegator, List<Map<String, ? extends Object>> trail, GenericValue userLogin, Map<String, Object> ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException { @@ -1227,7 +1206,7 @@ public class ContentWorker implements or ctx.put("contentIdTo", assocContentId); } if (thisContent == null) - thisContent = delegator.findOne("Content", UtilMisc.toMap("contentId", assocContentId), true); + thisContent = EntityQuery.use(delegator).from("Content").where("contentId", assocContentId).cache().queryOne(); ctx.put("content", thisContent); List<Object> purposes = getPurposes(thisContent); ctx.put("purposes", purposes); @@ -1393,10 +1372,10 @@ public class ContentWorker implements or exprListAnd.add(expr); } - EntityConditionList<EntityExpr> contentCondList = EntityCondition.makeCondition(exprListAnd, EntityOperator.AND); - List<GenericValue> contentList = delegator.findList("ContentAssocDataResourceViewFrom", contentCondList, null, null, null, false); - List<GenericValue> filteredList = EntityUtil.filterByDate(contentList, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); - return filteredList; + return EntityQuery.use(delegator).from("ContentAssocDataResourceViewFrom") + .where(exprListAnd) + .filterByDate("caFromDate", "caThruDate") + .queryList(); } public static GenericValue getContentAssocViewFrom(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, String statusId, String privilegeEnumId) throws GenericEntityException { @@ -1458,7 +1437,7 @@ public class ContentWorker implements or List<String> values = null; for (String contentId : contentIdList) { try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); return FastList.newInstance(); @@ -1481,7 +1460,7 @@ public class ContentWorker implements or GenericValue content = null; for (String contentId : contentIdList) { try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); return FastList.newInstance(); @@ -1512,7 +1491,7 @@ public class ContentWorker implements or String parentContentId = (String)ctx.get("contentId"); if (UtilValidate.isEmpty(mimeTypeId) && UtilValidate.isNotEmpty(parentContentId)) { // will need these below try { - GenericValue parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", parentContentId), false); + GenericValue parentContent = EntityQuery.use(delegator).from("Content").where("contentId", parentContentId).queryOne(); if (parentContent != null) { mimeTypeId = (String) parentContent.get("mimeTypeId"); ctx.put("parentContent", parentContent); @@ -1549,7 +1528,7 @@ public class ContentWorker implements or if (UtilValidate.isEmpty(mimeTypeId)) { if (UtilValidate.isNotEmpty(contentId) && UtilValidate.isNotEmpty(dataResourceId)) { - view = delegator.findOne("SubContentDataResourceView", UtilMisc.toMap("contentId", contentId, "drDataResourceId", dataResourceId), false); + view = EntityQuery.use(delegator).from("SubContentDataResourceView").where("contentId", contentId, "drDataResourceId", dataResourceId).queryOne(); if (view != null) { mimeTypeId = view.getString("mimeTypeId"); String drMimeTypeId = view.getString("drMimeTypeId"); @@ -1568,7 +1547,7 @@ public class ContentWorker implements or if (UtilValidate.isEmpty(mimeTypeId)) { if (UtilValidate.isNotEmpty(parentContentId)) { - parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + parentContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); if (parentContent != null) { mimeTypeId = parentContent.getString("mimeTypeId"); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java Tue Oct 28 08:56:02 2014 @@ -47,7 +47,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.SimpleMapProcessor; import org.ofbiz.service.GenericServiceException; @@ -294,12 +294,13 @@ public class UploadContentAndImage { // Check for existing AUTHOR link String userLoginId = userLogin.getString("userLoginId"); - GenericValue authorContent = delegator.findOne("Content", UtilMisc.toMap("contentId", userLoginId), true); + GenericValue authorContent = EntityQuery.use(delegator).from("Content").where("contentId", userLoginId).cache().queryOne(); if (authorContent != null) { - List<GenericValue> authorAssocList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", ftlContentId, "contentIdTo", userLoginId, "contentAssocTypeId", "AUTHOR"), null, false); - List<GenericValue> currentAuthorAssocList = EntityUtil.filterByDate(authorAssocList); + long currentAuthorAssocCount = EntityQuery.use(delegator).from("ContentAssoc") + .where("contentId", ftlContentId, "contentIdTo", userLoginId, "contentAssocTypeId", "AUTHOR") + .filterByDate().queryCount(); //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]currentAuthorAssocList " + currentAuthorAssocList, module); - if (currentAuthorAssocList.size() == 0) { + if (currentAuthorAssocCount == 0) { // Don't want to bother with permission checking on this association GenericValue authorAssoc = delegator.makeValue("ContentAssoc"); authorAssoc.set("contentId", ftlContentId); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataEvents.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataEvents.java Tue Oct 28 08:56:02 2014 @@ -21,7 +21,6 @@ package org.ofbiz.content.data; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.List; import java.util.Locale; import java.util.Map; @@ -39,6 +38,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.ServiceUtil; @@ -81,7 +81,7 @@ public class DataEvents { // get the content record GenericValue content; 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); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); @@ -108,7 +108,7 @@ public class DataEvents { // get the data resource GenericValue dataResource; try { - dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); @@ -244,7 +244,7 @@ public class DataEvents { } try { - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); if (!"Y".equals(dataResource.getString("isPublic"))) { // now require login... GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); @@ -257,9 +257,11 @@ public class DataEvents { // make sure the logged in user can download this content; otherwise is a pretty big security hole for DataResource records... // TODO: should we restrict the roleTypeId? - List<GenericValue> contentAndRoleList = delegator.findByAnd("ContentAndRole", - UtilMisc.toMap("partyId", userLogin.get("partyId"), "dataResourceId", dataResourceId), null, false); - if (contentAndRoleList.size() == 0) { + long contentAndRoleCount = EntityQuery.use(delegator).from("ContentAndRole") + .where("partyId", userLogin.get("partyId"), + "dataResourceId", dataResourceId) + .queryCount(); + if (contentAndRoleCount == 0) { String errorMsg = "You do not have permission to download the Data Resource with ID [" + dataResourceId + "], ie you are not associated with it."; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Tue Oct 28 08:56:02 2014 @@ -72,6 +72,7 @@ import org.ofbiz.content.content.UploadC 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.EntityUtilProperties; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -114,15 +115,12 @@ public class DataResourceWorker impleme } // Find all the categoryTypes that are children of the categoryNode. - String matchValue = null; - if (parentCategoryId != null) { - matchValue = parentCategoryId; - } - List<GenericValue> categoryValues = delegator.findByAnd("DataCategory", UtilMisc.toMap("parentCategoryId", matchValue), null, true); + List<GenericValue> categoryValues = EntityQuery.use(delegator).from("DataCategory") + .where("parentCategoryId", parentCategoryId) + .cache().queryList(); categoryNode.put("count", Integer.valueOf(categoryValues.size())); List<Map<String, Object>> subCategoryIds = FastList.newInstance(); - for (int i = 0; i < categoryValues.size(); i++) { - GenericValue category = categoryValues.get(i); + for (GenericValue category : categoryValues) { String id = (String) category.get("dataCategoryId"); String categoryName = (String) category.get("categoryName"); Map<String, Object> newNode = FastMap.newInstance(); @@ -154,7 +152,7 @@ public class DataResourceWorker impleme */ public static void getDataCategoryAncestry(Delegator delegator, String dataCategoryId, List<String> categoryTypeIds) throws GenericEntityException { categoryTypeIds.add(dataCategoryId); - GenericValue dataCategoryValue = delegator.findOne("DataCategory", UtilMisc.toMap("dataCategoryId", dataCategoryId), false); + GenericValue dataCategoryValue = EntityQuery.use(delegator).from("DataCategory").where("dataCategoryId", dataCategoryId).queryOne(); if (dataCategoryValue == null) return; String parentCategoryId = (String) dataCategoryValue.get("parentCategoryId"); @@ -310,7 +308,7 @@ public class DataResourceWorker impleme String ownerContentId = (String) context.get("ownerContentId"); if (UtilValidate.isNotEmpty(ownerContentId)) { try { - GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", ownerContentId), false); + GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", ownerContentId).queryOne(); if (content != null) serviceInMap.put("currentContent", content); } catch (GenericEntityException e) { @@ -334,7 +332,7 @@ public class DataResourceWorker impleme public static byte[] acquireImage(Delegator delegator, String dataResourceId) throws GenericEntityException { byte[] b = null; - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); if (dataResource == null) return b; @@ -345,7 +343,7 @@ public class DataResourceWorker impleme public static byte[] acquireImage(Delegator delegator, GenericValue dataResource) throws GenericEntityException { byte[] b = null; String dataResourceId = dataResource.getString("dataResourceId"); - GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne(); if (imageDataResource != null) { //b = (byte[]) imageDataResource.get("imageData"); b = imageDataResource.getBytes("imageData"); @@ -461,7 +459,7 @@ public class DataResourceWorker impleme mimeType = view.getString("drMimeTypeId"); //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, mimeType(2):" + mimeType, ""); if (UtilValidate.isEmpty(mimeType) && UtilValidate.isNotEmpty(dataResourceId)) { - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, dataResource(2):" + dataResource, ""); mimeType = dataResource.getString("mimeTypeId"); @@ -586,7 +584,7 @@ public class DataResourceWorker impleme throw new GeneralException("Cannot clear dataResource related cache for a null dataResourceId"); } - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); if (dataResource != null) { String dataTemplateTypeId = dataResource.getString("dataTemplateTypeId"); if ("FTL".equals(dataTemplateTypeId)) { @@ -652,7 +650,9 @@ public class DataResourceWorker impleme } // get the data resource object - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource") + .where("dataResourceId", dataResourceId) + .cache(cache).queryOne(); if (dataResource == null) { throw new GeneralException("No data resource object found for dataResourceId: [" + dataResourceId + "]"); @@ -707,7 +707,7 @@ public class DataResourceWorker impleme } else { String defaultVisualThemeId = EntityUtilProperties.getPropertyValue("general", "VISUAL_THEME", delegator); if (defaultVisualThemeId != null) { - GenericValue themeValue = delegator.findOne("VisualThemeResource", UtilMisc.toMap("visualThemeId", defaultVisualThemeId, "resourceTypeEnumId", "VT_DOCBOOKSTYLESHEET", "sequenceId", "01"), true); + GenericValue themeValue = EntityQuery.use(delegator).from("VisualThemeResource").where("visualThemeId", defaultVisualThemeId, "resourceTypeEnumId", "VT_DOCBOOKSTYLESHEET", "sequenceId", "01").cache().queryOne(); sourceFileLocation = new File(System.getProperty("ofbiz.home") + "/themes" + themeValue.get("resourceValue")); UtilMisc.copyFile(sourceFileLocation,targetFileLocation); } @@ -827,7 +827,9 @@ public class DataResourceWorker impleme String text = dataResource.getString("objectInfo"); writeText(dataResource, text, templateContext, mimeTypeId, locale, out); } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) { - GenericValue electronicText = delegator.findOne("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + GenericValue electronicText = EntityQuery.use(delegator).from("ElectronicText") + .where("dataResourceId", dataResourceId) + .cache(cache).queryOne(); if (electronicText != null) { String text = electronicText.getString("textData"); writeText(dataResource, text, templateContext, mimeTypeId, locale, out); @@ -902,7 +904,7 @@ public class DataResourceWorker impleme if ("text/html".equals(targetMimeTypeId)) { // get the default mime type template - GenericValue mimeTypeTemplate = delegator.findOne("MimeTypeHtmlTemplate", UtilMisc.toMap("mimeTypeId", dataResourceMimeTypeId), true); + GenericValue mimeTypeTemplate = EntityQuery.use(delegator).from("MimeTypeHtmlTemplate").where("mimeTypeId", dataResourceMimeTypeId).cache().queryOne(); if (mimeTypeTemplate != null && mimeTypeTemplate.get("templateLocation") != null) { // prepare the context @@ -1008,7 +1010,9 @@ public class DataResourceWorker impleme if ("SHORT_TEXT".equals(dataResourceTypeId) || "LINK".equals(dataResourceTypeId)) { text = dataResource.getString("objectInfo"); } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) { - GenericValue electronicText = delegator.findOne("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + GenericValue electronicText = EntityQuery.use(delegator).from("ElectronicText") + .where("dataResourceId", dataResourceId) + .cache(cache).queryOne(); if (electronicText != null) { text = electronicText.getString("textData"); } @@ -1025,22 +1029,22 @@ public class DataResourceWorker impleme GenericValue valObj; if ("IMAGE_OBJECT".equals(dataResourceTypeId)) { - valObj = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + valObj = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).cache(cache).queryOne(); if (valObj != null) { bytes = valObj.getBytes("imageData"); } } else if ("VIDEO_OBJECT".equals(dataResourceTypeId)) { - valObj = delegator.findOne("VideoDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + valObj = EntityQuery.use(delegator).from("VideoDataResource").where("dataResourceId", dataResourceId).cache(cache).queryOne(); if (valObj != null) { bytes = valObj.getBytes("videoData"); } } else if ("AUDIO_OBJECT".equals(dataResourceTypeId)) { - valObj = delegator.findOne("AudioDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + valObj = EntityQuery.use(delegator).from("AudioDataResource").where("dataResourceId", dataResourceId).cache(cache).queryOne(); if (valObj != null) { bytes = valObj.getBytes("audioData"); } } else if ("OTHER_OBJECT".equals(dataResourceTypeId)) { - valObj = delegator.findOne("OtherDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), cache); + valObj = EntityQuery.use(delegator).from("OtherDataResource").where("dataResourceId", dataResourceId).cache(cache).queryOne(); if (valObj != null) { bytes = valObj.getBytes("dataResourceContent"); } @@ -1088,7 +1092,7 @@ public class DataResourceWorker impleme // TODO: remove this method in favor of getDataResourceStream public static void streamDataResource(OutputStream os, Delegator delegator, String dataResourceId, String https, String webSiteId, Locale locale, String rootDir) throws IOException, GeneralException { try { - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); if (dataResource == null) { throw new GeneralException("Error in streamDataResource: DataResource with ID [" + dataResourceId + "] was not found."); } @@ -1105,7 +1109,7 @@ public class DataResourceWorker impleme String text = dataResource.getString("objectInfo"); os.write(text.getBytes()); } else if (dataResourceTypeId.equals("ELECTRONIC_TEXT")) { - GenericValue electronicText = delegator.findOne("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue electronicText = EntityQuery.use(delegator).from("ElectronicText").where("dataResourceId", dataResourceId).cache().queryOne(); if (electronicText != null) { String text = electronicText.getString("textData"); if (text != null) os.write(text.getBytes()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataServices.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/data/DataServices.java Tue Oct 28 08:56:02 2014 @@ -22,13 +22,12 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; -import java.io.StringWriter; import java.io.IOException; import java.io.RandomAccessFile; +import java.io.StringWriter; import java.io.Writer; import java.nio.ByteBuffer; import java.sql.Timestamp; -import java.util.List; import java.util.Locale; import java.util.Map; @@ -44,6 +43,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.ModelService; @@ -137,9 +137,9 @@ public class DataServices { // get first statusId for content out of the statusItem table if not provided if (UtilValidate.isEmpty(dataResource.get("statusId"))) { try { - List<GenericValue> statusItems = delegator.findByAnd("StatusItem",UtilMisc.toMap("statusTypeId", "CONTENT_STATUS"), UtilMisc.toList("sequenceId"), false); - if (!UtilValidate.isEmpty(statusItems)) { - dataResource.put("statusId", statusItems.get(0).getString("statusId")); + GenericValue statusItem = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "CONTENT_STATUS").orderBy("sequenceId").queryFirst(); + if (statusItem != null) { + dataResource.put("statusId", statusItem.get("statusId")); } } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); @@ -312,7 +312,7 @@ public class DataServices { // If textData exists, then create DataResource and return dataResourceId String dataResourceId = (String) context.get("dataResourceId"); try { - dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentDataResourceNotFound", UtilMisc.toMap("parameters.dataResourceId", dataResourceId), locale)); @@ -366,7 +366,7 @@ public class DataServices { Debug.logVerbose("in updateElectronicText, textData:" + textData, module); } try { - electronicText = delegator.findOne("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId), false); + electronicText = EntityQuery.use(delegator).from("ElectronicText").where("dataResourceId", dataResourceId).queryOne(); if (electronicText != null) { electronicText.put("textData", textData); electronicText.store(); @@ -521,7 +521,7 @@ public class DataServices { if (byteBuffer != null) { byte[] imageBytes = byteBuffer.array(); try { - GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne(); if (Debug.infoOn()) { Debug.logInfo("imageDataResource(U):" + imageDataResource, module); Debug.logInfo("imageBytes(U):" + imageBytes, module); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java Tue Oct 28 08:56:02 2014 @@ -44,6 +44,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.SimpleMapProcessor; import org.ofbiz.service.GenericServiceException; @@ -136,7 +137,7 @@ public class LayoutEvents { dispatcher.runSync("deactivateAssocs", context2); } - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); //Debug.logVerbose("in createLayoutImage, dataResource:" + dataResource, module); // Use objectInfo field to store the name of the file, since there is no // place in ImageDataResource for it. @@ -147,7 +148,7 @@ public class LayoutEvents { } // See if this needs to be a create or an update procedure - GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne(); //Debug.logVerbose("in createLayoutImage, imageDataResource(0):" + imageDataResource, module); if (imageDataResource == null) { imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); @@ -195,7 +196,7 @@ public class LayoutEvents { String dataResourceId = (String) context.get("drDataResourceId"); Debug.logVerbose("in createLayoutImage(java), dataResourceId:" + dataResourceId, ""); - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource, ""); // Use objectInfo field to store the name of the file, since there is no // place in ImageDataResource for it. @@ -207,7 +208,7 @@ public class LayoutEvents { } // See if this needs to be a create or an update procedure - GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne(); if (imageDataResource == null) { imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); imageDataResource.set("imageData", byteWrap.array()); @@ -253,10 +254,11 @@ public class LayoutEvents { if (UtilValidate.isEmpty(contentId)) { // Look for an existing associated Content try { - List lst = delegator.findByAnd("DataResourceContentView ", UtilMisc.toMap("dataResourceId", dataResourceId)); - if (lst.size() > 0) { - GenericValue dataResourceContentView = (GenericValue) lst.get(0); - contentId = (String) dataResourceContentView.get("coContentId"); + GenericValue dataResourceContentView = EntityQuery.use(delegator).from("DataResourceContentView") + .where("dataResourceId", dataResourceId) + .queryFirst(); + if (dataResourceContentView != null) { + contentId = dataResourceContentView.getString("coContentId"); } } catch (GenericEntityException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); @@ -321,7 +323,7 @@ public class LayoutEvents { String newId = null; String newDataResourceId = null; try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); Debug.logVerbose("in cloneLayout, content:" + content, ""); if (content == null) { String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_empty", locale); @@ -334,7 +336,7 @@ public class LayoutEvents { newId = delegator.getNextSeqId("Content"); newContent.set("contentId", newId); String dataResourceId = (String) content.get("dataResourceId"); - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); if (dataResource != null) { GenericValue newDataResource = delegator.makeValue("DataResource", dataResource); Debug.logVerbose("in cloneLayout, newDataResource:" + newDataResource, ""); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java Tue Oct 28 08:56:02 2014 @@ -45,7 +45,7 @@ import org.ofbiz.content.data.DataResour import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -214,7 +214,7 @@ public class PdfSurveyServices { } pdfStamper.close(); if (UtilValidate.isNotEmpty(contentId)) { - survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false); + survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne(); survey.set("acroFormContentId", contentId); survey.store(); } @@ -247,7 +247,7 @@ public class PdfSurveyServices { //String contentId = (String)context.get("contentId"); surveyResponseId = (String)context.get("surveyResponseId"); if (UtilValidate.isNotEmpty(surveyResponseId)) { - GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false); + GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne(); if (surveyResponse != null) { surveyId = surveyResponse.getString("surveyId"); } @@ -270,13 +270,15 @@ public class PdfSurveyServices { //AcroFields.Item item = fs.getFieldItem(fieldName); //int type = fs.getFieldType(fieldName); String value = fs.getField(fieldName); - List<GenericValue> questions = delegator.findByAnd("SurveyQuestionAndAppl", UtilMisc.toMap("surveyId", surveyId, "externalFieldRef", fieldName), null, false); - if (questions.size() == 0) { + GenericValue surveyQuestionAndAppl = EntityQuery.use(delegator).from("SurveyQuestionAndAppl") + .where("surveyId", surveyId, + "externalFieldRef", fieldName) + .queryFirst(); + if (surveyQuestionAndAppl == null) { Debug.logInfo("No question found for surveyId:" + surveyId + " and externalFieldRef:" + fieldName, module); continue; } - GenericValue surveyQuestionAndAppl = questions.get(0); String surveyQuestionId = (String)surveyQuestionAndAppl.get("surveyQuestionId"); String surveyQuestionTypeId = (String)surveyQuestionAndAppl.get("surveyQuestionTypeId"); GenericValue surveyResponseAnswer = delegator.makeValue("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId, "surveyQuestionId", surveyQuestionId)); @@ -422,13 +424,13 @@ public class PdfSurveyServices { Document document = new Document(); try { if (UtilValidate.isNotEmpty(surveyResponseId)) { - GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false); + GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne(); if (surveyResponse != null) { surveyId = surveyResponse.getString("surveyId"); } } if (UtilValidate.isNotEmpty(surveyId) && UtilValidate.isEmpty(contentId)) { - GenericValue survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false); + GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne(); if (survey != null) { String acroFormContentId = survey.getString("acroFormContentId"); if (UtilValidate.isNotEmpty(acroFormContentId)) { @@ -440,11 +442,11 @@ public class PdfSurveyServices { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); - List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false); + List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList(); for (GenericValue surveyResponseAnswer : responses) { String value = null; String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId"); - GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), false); + GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).queryOne(); String questionType = surveyQuestion.getString("surveyQuestionTypeId"); // DEJ20060227 this isn't used, if needed in the future should get from SurveyQuestionAppl.externalFieldRef String fieldName = surveyQuestion.getString("description"); if ("OPTION".equals(questionType)) { @@ -489,10 +491,10 @@ public class PdfSurveyServices { List<Object> qAndA = FastList.newInstance(); try { - List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false); + List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList(); for (GenericValue surveyResponseAnswer : responses) { String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId"); - GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), false); + GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).queryOne(); qAndA.add(UtilMisc.toMap("question", surveyQuestion, "response", surveyResponseAnswer)); } results.put("questionsAndAnswers", qAndA); @@ -517,28 +519,31 @@ public class PdfSurveyServices { try { String surveyId = null; if (UtilValidate.isNotEmpty(surveyResponseId)) { - GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false); + GenericValue 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"); } } - List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false); + List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList(); for (GenericValue surveyResponseAnswer : responses) { String value = null; String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId"); - GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), true); + GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).cache().queryOne(); - List<GenericValue> surveyQuestionApplList = EntityUtil.filterByDate(delegator.findByAnd("SurveyQuestionAppl", UtilMisc.toMap("surveyId", surveyId, "surveyQuestionId", surveyQuestionId), UtilMisc.toList("-fromDate"), true), false); - GenericValue surveyQuestionAppl = EntityUtil.getFirst(surveyQuestionApplList); + GenericValue surveyQuestionAppl = EntityQuery.use(delegator).from("SurveyQuestionAppl") + .where("surveyId", surveyId, + "surveyQuestionId", surveyQuestionId) + .orderBy("-fromDate") + .filterByDate().cache().queryFirst(); String questionType = surveyQuestion.getString("surveyQuestionTypeId"); String fieldName = surveyQuestionAppl.getString("externalFieldRef"); @@ -618,7 +623,7 @@ public class PdfSurveyServices { String https = (String)context.get("https"); String webSiteId = (String)context.get("webSiteId"); String rootDir = (String)context.get("rootDir"); - GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true); + GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne(); String dataResourceId = content.getString("dataResourceId"); inputByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); } catch (GenericEntityException e) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java Tue Oct 28 08:56:02 2014 @@ -45,8 +45,8 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import freemarker.template.Configuration; @@ -240,7 +240,7 @@ public class SurveyWrapper { public GenericValue getSurvey() { GenericValue survey = null; try { - survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), true); + survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get Survey : " + surveyId, module); } @@ -286,12 +286,10 @@ public class SurveyWrapper { List<GenericValue> questions = FastList.newInstance(); try { - Map<String, Object> fields = UtilMisc.<String, Object>toMap("surveyId", surveyId); - List<String> order = UtilMisc.toList("sequenceNum", "surveyMultiRespColId"); - questions = delegator.findByAnd("SurveyQuestionAndAppl", fields, order, true); - if (questions != null) { - questions = EntityUtil.filterByDate(questions); - } + questions = EntityQuery.use(delegator).from("SurveyQuestionAndAppl") + .where("surveyId", surveyId) + .orderBy("sequenceNum", "surveyMultiRespColId") + .filterByDate().cache().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get questions for survey : " + surveyId, module); } @@ -312,7 +310,10 @@ public class SurveyWrapper { String responseId = null; List<GenericValue> responses = null; try { - responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId), UtilMisc.toList("-lastModifiedDate"), false); + responses = EntityQuery.use(delegator).from("SurveyResponse") + .where("surveyId", surveyId, "partyId", partyId) + .orderBy("-lastModifiedDate") + .queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -335,7 +336,7 @@ public class SurveyWrapper { public long getNumberResponses() throws SurveyWrapperException { long responses = 0; try { - responses = delegator.findCountByCondition("SurveyResponse", EntityCondition.makeCondition("surveyId", EntityOperator.EQUALS, surveyId), null, null); + responses = EntityQuery.use(delegator).from("SurveyResponse").where("surveyId", surveyId).queryCount(); } catch (GenericEntityException e) { throw new SurveyWrapperException(e); } @@ -345,7 +346,7 @@ public class SurveyWrapper { public List<GenericValue> getSurveyResponses(GenericValue question) throws SurveyWrapperException { List<GenericValue> responses = null; try { - responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyQuestionId", question.getString("surveyQuestionId")), null, false); + responses = EntityQuery.use(delegator).from("SurveyResponse").where("surveyQuestionId", question.get("surveyQuestionId")).queryList(); } catch (GenericEntityException e) { throw new SurveyWrapperException(e); } @@ -359,7 +360,7 @@ public class SurveyWrapper { if (responseId != null) { List<GenericValue> answers = null; try { - answers = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", responseId), null, false); + answers = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", responseId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -658,7 +659,9 @@ public class SurveyWrapper { long result = 0; try { - result = delegator.findCountByCondition("SurveyResponseAndAnswer", makeEliCondition(question), null, null); + result = EntityQuery.use(delegator).from("SurveyResponseAndAnswer") + .where(makeEliCondition(question)) + .queryCount(); } catch (GenericEntityException e) { Debug.logError(e, module); throw new SurveyWrapperException("Unable to get responses", e); @@ -724,19 +727,11 @@ public class SurveyWrapper { } private EntityListIterator getEli(GenericValue question, int maxRows) throws GenericEntityException { - EntityFindOptions efo = new EntityFindOptions(); - efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); - efo.setResultSetConcurrency(EntityFindOptions.CONCUR_READ_ONLY); - efo.setSpecifyTypeAndConcur(true); - efo.setDistinct(false); - if (maxRows > 0) { - efo.setMaxRows(maxRows); - } - - EntityListIterator eli = null; - eli = delegator.find("SurveyResponseAndAnswer", makeEliCondition(question), null, null, null, efo); - - return eli; + return EntityQuery.use(delegator).from("SurveyResponseAndAnswer") + .where(makeEliCondition(question)) + .cursorScrollInsensitive() + .maxRows(maxRows) + .queryIterator(); } @SuppressWarnings("serial") Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java Tue Oct 28 08:56:02 2014 @@ -41,6 +41,7 @@ import org.ofbiz.content.data.DataResour import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.webapp.view.AbstractViewHandler; import org.ofbiz.webapp.view.ViewHandlerException; import org.ofbiz.webapp.website.WebSiteWorker; @@ -83,7 +84,7 @@ public class SimpleContentViewHandler ex if (UtilValidate.isEmpty(contentRevisionSeqId)) { if (UtilValidate.isEmpty(mapKey) && UtilValidate.isEmpty(contentAssocTypeId)) { if (UtilValidate.isNotEmpty(contentId)) { - 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"); } if (Debug.verboseOn()) Debug.logVerbose("dataResourceId:" + dataResourceId, module); @@ -105,7 +106,7 @@ public class SimpleContentViewHandler ex if (Debug.verboseOn()) Debug.logVerbose("dataResourceId:" + dataResourceId, module); } } else { - GenericValue contentRevisionItem = delegator.findOne("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId), true); + GenericValue contentRevisionItem = EntityQuery.use(delegator).from("ContentRevisionItem").where("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId).cache().queryOne(); if (contentRevisionItem == null) { throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId); @@ -117,7 +118,7 @@ public class SimpleContentViewHandler ex } } if (UtilValidate.isNotEmpty(dataResourceId)) { - GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); // DEJ20080717: why are we rendering the DataResource directly instead of rendering the content? ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java Tue Oct 28 08:56:02 2014 @@ -35,6 +35,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.service.LocalDispatcher; import freemarker.core.Environment; @@ -135,7 +136,7 @@ public class EditRenderSubContentTransfo mimeTypeIdTemp = (String) subContentDataResourceView.get("mimeTypeId"); if (UtilValidate.isEmpty(mimeTypeIdTemp) && UtilValidate.isNotEmpty(contentId)) { // will need these below try { - parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + parentContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); if (parentContent != null) { mimeTypeIdTemp = (String) parentContent.get("mimeTypeId"); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java Tue Oct 28 08:56:02 2014 @@ -37,6 +37,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.service.LocalDispatcher; import org.ofbiz.webapp.ftl.LoopWriter; @@ -116,7 +117,7 @@ public class LoopSubContentTransform imp String parentContentId = (String)ctx.get("contentId"); if (UtilValidate.isEmpty(mimeTypeId) && UtilValidate.isNotEmpty(parentContentId)) { // will need these below try { - GenericValue parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", parentContentId), false); + GenericValue parentContent = EntityQuery.use(delegator).from("Content").where("contentId", parentContentId).queryOne(); if (parentContent != null) { mimeTypeId = (String) parentContent.get("mimeTypeId"); ctx.put("parentContent", parentContent); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java?rev=1634818&r1=1634817&r2=1634818&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java Tue Oct 28 08:56:02 2014 @@ -32,13 +32,13 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilGenerics; -import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.content.content.ContentWorker; 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.LocalDispatcher; import org.ofbiz.webapp.ftl.LoopWriter; @@ -124,7 +124,7 @@ public class TraverseSubContentTransform } if (UtilValidate.isNotEmpty(thisContentId)) { try { - view = delegator.findOne("Content", UtilMisc.toMap("contentId", thisContentId), false); + view = EntityQuery.use(delegator).from("Content").where("contentId", thisContentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error getting sub-content", module); throw new RuntimeException(e.getMessage()); @@ -186,7 +186,7 @@ public class TraverseSubContentTransform /* if (UtilValidate.isNotEmpty(contentId)) { try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { // TODO: Not sure what to put here. throw new RuntimeException(e.getMessage()); |
Free forum by Nabble | Edit this page |