svn commit: r1184997 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java

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

svn commit: r1184997 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java

jleroux@apache.org
Author: jleroux
Date: Mon Oct 17 04:54:52 2011
New Revision: 1184997

URL: http://svn.apache.org/viewvc?rev=1184997&view=rev
Log:
A patch from Dimitri Unruh https://issues.apache.org/jira/browse/OFBIZ-4471
"Minor API Extension for WebSiteWorker.java"

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java?rev=1184997&r1=1184996&r2=1184997&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/website/WebSiteWorker.java Mon Oct 17 04:54:52 2011
@@ -46,13 +46,37 @@ public class WebSiteWorker {
         if (webSiteId == null) {
             return null;
         }
-        Delegator delegator = (Delegator) request.getAttribute("delegator");
 
+        return findWebSite((Delegator) request.getAttribute("delegator"), webSiteId);
+    }
+
+    /**
+     * returns a WebSite-GenericValue (using entityCache)
+     *
+     * @param delegator
+     * @param webSiteId
+     * @return
+     */
+    public static GenericValue findWebSite(Delegator delegator, String webSiteId) {
+        return findWebSite(delegator, webSiteId, true);
+    }
+
+    /**
+     * returns a WebSite-GenericValue
+     *
+     * @param delegator
+     * @param webSiteId
+     * @param useCache
+     * @return
+     */
+    public static GenericValue findWebSite(Delegator delegator, String webSiteId, boolean useCache) {
+        GenericValue result = null;
         try {
-            return delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId));
-        } catch (GenericEntityException e) {
-            Debug.logError(e, "Error looking up website with id " + webSiteId, module);
+            result = delegator.findOne("WebSite", useCache, UtilMisc.toMap("webSiteId", webSiteId));
+        }
+        catch (GenericEntityException e) {
+            Debug.logError("Error looking up website with id " + webSiteId, module);
         }
-        return null;
+        return result;
     }
 }