Author: jleroux
Date: Thu Dec 8 21:56:02 2011
New Revision: 1212147
URL:
http://svn.apache.org/viewvc?rev=1212147&view=revLog:
A patch from Martin Kreidenweis
https://issues.apache.org/jira/browse/OFBIZ-4451Warning in log when using @renderSubContentCache freemarker macro
When using the @renderSubContentCache freemarker macro, warnings like this appear in the log:
[ GenericEntity.java:314:WARN ] The field name (or key) [caContentAssocTypeId] is not valid for entity [ContentDataResourceView], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.
Patch: GenericValue.get() will actually not throw an exception but instead log a warning if the field doesn't exist, so now we first check if the field we are trying to access exists.
Checking one of the fields through the ModelEntity should be enough, as all three of them come from the same entity.
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=1212147&r1=1212146&r2=1212147&view=diff==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java Thu Dec 8 21:56:02 2011
@@ -1435,13 +1435,10 @@ public class ContentWorker implements or
thisNode.put("isReturnAfterPick", Boolean.FALSE);
thisNode.put("isPick", Boolean.TRUE);
thisNode.put("isFollow", Boolean.TRUE);
- try {
+ if (thisContent.getModelEntity().getField("caContentAssocTypeId") != null) {
thisNode.put("contentAssocTypeId", thisContent.get("caContentAssocTypeId"));
thisNode.put("mapKey", thisContent.get("caMapKey"));
thisNode.put("fromDate", thisContent.get("caFromDate"));
- thisNode.put("contentAssocTypeId", thisContent.get("caContentAssocTypeId"));
- } catch (Exception e) {
- // This ignores the case when thisContent does not have ContentAssoc values
}
return thisNode;
}