svn commit: r485874 - in /incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product: category/CategoryContentWrapper.java product/ProductContentWrapper.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r485874 - in /incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product: category/CategoryContentWrapper.java product/ProductContentWrapper.java

jaz-3
Author: jaz
Date: Mon Dec 11 13:22:33 2006
New Revision: 485874

URL: http://svn.apache.org/viewvc?view=rev&rev=485874
Log:
fixed possible NPE; change to implement new interface

Modified:
    incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java
    incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java

Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?view=diff&rev=485874&r1=485873&r2=485874
==============================================================================
--- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original)
+++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Mon Dec 11 13:22:33 2006
@@ -31,7 +31,9 @@
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.GeneralRuntimeException;
 import org.ofbiz.content.content.ContentWorker;
+import org.ofbiz.content.content.ContentWrapper;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.model.ModelEntity;
@@ -41,7 +43,7 @@
 /**
  * Category Content Worker: gets category content to display
  */
-public class CategoryContentWrapper {
+public class CategoryContentWrapper implements ContentWrapper {
     
     public static final String module = CategoryContentWrapper.class.getName();
     
@@ -109,9 +111,12 @@
         if (UtilValidate.isEmpty(mimeTypeId)) {
             mimeTypeId = "text/html";
         }
+
+        if (delegator == null) {
+            throw new GeneralRuntimeException("Unable to find a delegator to use!");
+        }
         
         String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId);
-//        Debug.logInfo("candidateFieldName=" + candidateFieldName, module);
         ModelEntity categoryModel = delegator.getModelEntity("ProductCategory");
         if (categoryModel.isField(candidateFieldName)) {
             if (productCategory == null) {

Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?view=diff&rev=485874&r1=485873&r2=485874
==============================================================================
--- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java (original)
+++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java Mon Dec 11 13:22:33 2006
@@ -31,8 +31,10 @@
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.GeneralRuntimeException;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.content.content.ContentWorker;
+import org.ofbiz.content.content.ContentWrapper;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.model.ModelEntity;
@@ -42,7 +44,7 @@
 /**
  * Product Content Worker: gets product content to display
  */
-public class ProductContentWrapper {
+public class ProductContentWrapper implements ContentWrapper {
     
     public static final String module = ProductContentWrapper.class.getName();
     public static final String SEPARATOR = "::";    // cache key separator
@@ -131,9 +133,12 @@
         if (UtilValidate.isEmpty(mimeTypeId)) {
             mimeTypeId = "text/html";
         }
+
+        if (delegator == null) {
+            throw new GeneralRuntimeException("Unable to find a delegator to use!");
+        }
         
-        String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId);
-        //Debug.logInfo("candidateFieldName=" + candidateFieldName, module);
+        String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId);        
         ModelEntity productModel = delegator.getModelEntity("Product");
         if (productModel.isField(candidateFieldName)) {
             if (product == null) {