Author: jonesde
Date: Tue Oct 10 09:55:28 2006
New Revision: 454828

URL: http://svn.apache.org/viewvc?view=rev&rev=454828
Log:
Fixed issue where delegatorName is not found: looks for delegator in the 
ServletContext attribute which is where it always should be for an application; 
this way the Visit is more reliably created, especially after logout when the 
session is cleared and for a bit the delegatorName isn't there

Modified:
    
incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java

Modified: 
incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java?view=diff&rev=454828&r1=454827&r2=454828
==============================================================================
--- 
incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java
 (original)
+++ 
incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/VisitHandler.java
 Tue Oct 10 09:55:28 2006
@@ -144,13 +144,20 @@
 
             if (visit == null) {
                 GenericDelegator delegator = null;
+                
+                // first try the session attribute delegatorName
                 String delegatorName = (String) 
session.getAttribute("delegatorName");
-
                 if (UtilValidate.isNotEmpty(delegatorName)) {
                     delegator = 
GenericDelegator.getGenericDelegator(delegatorName);
                 }
+                
+                // then try the ServletContext attribute delegator, should 
always be there...
                 if (delegator == null) {
-                    Debug.logError("Could not find delegator with 
delegatorName [" + delegatorName + "] in session, not creating Visit entity", 
module);
+                    delegator = (GenericDelegator) 
session.getServletContext().getAttribute("delegator");
+                }
+                
+                if (delegator == null) {
+                    Debug.logError("Could not find delegator with 
delegatorName [" + delegatorName + "] in session, or a delegator attribute in 
the ServletContext, not creating Visit entity", module);
                 } else {
                     visit = delegator.makeValue("Visit", null);
                     visit.set("visitId", delegator.getNextSeqId("Visit"));


Reply via email to