You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2012/03/26 22:56:30 UTC

svn commit: r1305581 [28/36] - in /ofbiz/branches/20111205EmailHandling: ./ applications/accounting/config/ applications/accounting/data/ applications/accounting/entitydef/ applications/accounting/script/org/ofbiz/accounting/finaccount/ applications/ac...

Modified: ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ModelServiceReader.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ModelServiceReader.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ModelServiceReader.java Mon Mar 26 20:56:02 2012
@@ -54,8 +54,6 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
-import org.webslinger.invoker.Wrap;
-
 import freemarker.template.utility.StringUtil;
 
 /**
@@ -65,7 +63,6 @@ import freemarker.template.utility.Strin
 public class ModelServiceReader implements Serializable {
 
     public static final String module = ModelServiceReader.class.getName();
-    protected static boolean serviceDebugMode = true;
 
     /** is either from a URL or from a ResourceLoader (through the ResourceHandler) */
     protected boolean isFromURL;
@@ -94,7 +91,6 @@ public class ModelServiceReader implemen
         this.readerURL = readerURL;
         this.handler = handler;
         this.dctx = dctx;
-        serviceDebugMode = "true".equals(UtilProperties.getPropertyValue("service", "servicedispatcher.servicedebugmode", "true"));
     }
 
     private Map<String, ModelService> getModelServices() {
@@ -204,21 +200,6 @@ public class ModelServiceReader implemen
         ModelService service = new ModelService();
 
         service.name = UtilXml.checkEmpty(serviceElement.getAttribute("name")).intern();
-        if (serviceDebugMode) {
-            Wrap<GenericInvoker> wrap = new Wrap<GenericInvoker>().fileName(resourceLocation + '#' + service.name).wrappedClass(GenericInvokerImpl.class);
-            for (Method method: GenericInvokerImpl.class.getDeclaredMethods()) {
-                if (method.getName().startsWith("run")) {
-                    wrap.wrap(method);
-                } else if (method.getName().startsWith("send")) {
-                    wrap.wrap(method);
-                }
-            }
-            Object startLine = serviceElement.getUserData("startLine");
-            if (startLine != null) {
-                wrap.lineNumber(((Integer) startLine).intValue());
-            }
-            service.invoker = wrap.newInstance(new Class<?>[] {ModelService.class}, new Object[] {service});
-        }
         service.definitionLocation = resourceLocation;
         service.engineName = UtilXml.checkEmpty(serviceElement.getAttribute("engine")).intern();
         service.location = UtilXml.checkEmpty(serviceElement.getAttribute("location")).intern();
@@ -749,54 +730,4 @@ public class ModelServiceReader implemen
 
         return document;
     }
-
-    public static class GenericInvokerImpl implements GenericInvoker {
-        private final ModelService modelService;
-
-        public GenericInvokerImpl(ModelService modelService) {
-            this.modelService = modelService;
-        }
-
-        public Map<String, Object> runSync(String localName, GenericEngine engine, Map<String, Object> context) throws GenericServiceException {
-            return engine.runSync(localName, modelService, context);
-        }
-
-        public void runSyncIgnore(String localName, GenericEngine engine, Map<String, Object> context) throws GenericServiceException {
-            engine.runSyncIgnore(localName, modelService, context);
-        }
-
-        public void runAsync(String localName, GenericEngine engine, Map<String, Object> context, GenericRequester requester, boolean persist) throws GenericServiceException {
-            if (requester != null) {
-                engine.runAsync(localName, modelService, context, requester, persist);
-            } else {
-                engine.runAsync(localName, modelService, context, persist);
-            }
-        }
-
-        public void sendCallbacks(GenericEngine engine, Map<String, Object> context, Map<String, Object> result, Throwable t, int mode) throws GenericServiceException {
-            if (t != null) {
-                engine.sendCallbacks(modelService, context, t, mode);
-            } else if (result != null) {
-                engine.sendCallbacks(modelService, context, result, mode);
-            } else {
-                engine.sendCallbacks(modelService, context, mode);
-            }
-        }
-
-        public GenericInvokerImpl copy(ModelService modelService) {
-            try {
-                try {
-                    return getClass().getConstructor(ModelService.class).newInstance(modelService);
-                } catch (InvocationTargetException e) {
-                    throw e.getCause();
-                }
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Error e) {
-                throw e;
-            } catch (Throwable e) {
-                throw (InternalError) new InternalError(e.getMessage()).initCause(e);
-            }
-        }
-    }
 }

Modified: ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Mon Mar 26 20:56:02 2012
@@ -74,7 +74,6 @@ public class ServiceDispatcher {
     protected static boolean enableJM = true;
     protected static boolean enableJMS = true;
     protected static boolean enableSvcs = true;
-    protected static boolean serviceDebugMode = true;
 
     protected Delegator delegator = null;
     protected GenericEngineFactory factory = null;
@@ -123,7 +122,6 @@ public class ServiceDispatcher {
         if (enableSvcs) {
             this.runStartupServices();
         }
-        serviceDebugMode = "true".equals(UtilProperties.getPropertyValue("service", "servicedispatcher.servicedebugmode", "true"));
     }
 
     protected ServiceDispatcher(Delegator delegator) {
@@ -395,13 +393,8 @@ public class ServiceDispatcher {
                     // ===== invoke the service =====
                     if (!isError && !isFailure) {
                         Map<String, Object> invokeResult = null;
-                        if (serviceDebugMode) {
-                            invokeResult = modelService.invoker.runSync(localName, engine, context);
-                            modelService.invoker.sendCallbacks(engine, context, invokeResult, null, GenericEngine.SYNC_MODE);
-                        } else {
-                            invokeResult = engine.runSync(localName, modelService, context);
-                            engine.sendCallbacks(modelService, context, invokeResult, GenericEngine.SYNC_MODE);
-                        }
+                        invokeResult = engine.runSync(localName, modelService, context);
+                        engine.sendCallbacks(modelService, context, invokeResult, GenericEngine.SYNC_MODE);
                         if (invokeResult != null) {
                             result.putAll(invokeResult);
                         } else {
@@ -515,11 +508,7 @@ public class ServiceDispatcher {
                     UtilTimer.closeTimer(localName + " / " + modelService.name, "Sync service failed...", module);
                 }
                 String errMsg = "Service [" + modelService.name + "] threw an unexpected exception/error";
-                if (serviceDebugMode) {
-                    modelService.invoker.sendCallbacks(engine, context, null, t, GenericEngine.SYNC_MODE);
-                } else {
-                    engine.sendCallbacks(modelService, context, t, GenericEngine.SYNC_MODE);
-                }
+                engine.sendCallbacks(modelService, context, t, GenericEngine.SYNC_MODE);
                 try {
                     TransactionUtil.rollback(beganTrans, errMsg, t);
                 } catch (GenericTransactionException te) {
@@ -715,17 +704,12 @@ public class ServiceDispatcher {
 
                 // run the service
                 if (!isError && !isFailure) {
-                    if (serviceDebugMode) {
-                        service.invoker.runAsync(localName, engine, context, requester, persist);
-                        service.invoker.sendCallbacks(engine, context, null, null, GenericEngine.ASYNC_MODE);
+                    if (requester != null) {
+                        engine.runAsync(localName, service, context, requester, persist);
                     } else {
-                        if (requester != null) {
-                            engine.runAsync(localName, service, context, requester, persist);
-                        } else {
-                            engine.runAsync(localName, service, context, persist);
-                        }
-                        engine.sendCallbacks(service, context, GenericEngine.ASYNC_MODE);
+                        engine.runAsync(localName, service, context, persist);
                     }
+                    engine.sendCallbacks(service, context, GenericEngine.ASYNC_MODE);
                 }
 
                 if (Debug.timingOn()) {
@@ -738,11 +722,7 @@ public class ServiceDispatcher {
                 }
                 String errMsg = "Service [" + service.name + "] threw an unexpected exception/error";
                 Debug.logError(t, errMsg, module);
-                if (serviceDebugMode) {
-                    service.invoker.sendCallbacks(engine, context, null, t, GenericEngine.ASYNC_MODE);
-                } else {
-                    engine.sendCallbacks(service, context, t, GenericEngine.ASYNC_MODE);
-                }
+                engine.sendCallbacks(service, context, t, GenericEngine.ASYNC_MODE);
                 try {
                     TransactionUtil.rollback(beganTrans, errMsg, t);
                 } catch (GenericTransactionException te) {

Modified: ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/service/src/org/ofbiz/service/engine/GroovyEngine.java Mon Mar 26 20:56:02 2012
@@ -19,31 +19,47 @@
 package org.ofbiz.service.engine;
 
 import static org.ofbiz.base.util.UtilGenerics.cast;
+
+import groovy.lang.GroovyClassLoader;
 import groovy.lang.Script;
 
 import java.util.Map;
 
 import javolution.util.FastMap;
 
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.runtime.InvokerHelper;
+import org.ofbiz.base.config.GenericConfigException;
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.GroovyUtil;
 import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.ModelService;
-import org.ofbiz.service.ServiceDispatcher;
-import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.service.*;
+import org.ofbiz.service.config.ServiceConfigUtil;
 
 /**
  * Groovy Script Service Engine
  */
 public final class GroovyEngine extends GenericAsyncEngine {
 
+    public static final String module = GroovyEngine.class.getName();
     protected static final Object[] EMPTY_ARGS = {};
 
+    GroovyClassLoader groovyClassLoader;
+
     public GroovyEngine(ServiceDispatcher dispatcher) {
         super(dispatcher);
+        try {
+            String scriptBaseClass = ServiceConfigUtil.getEngineParameter("groovy", "scriptBaseClass");
+            if (scriptBaseClass != null) {
+                CompilerConfiguration conf = new CompilerConfiguration();
+                conf.setScriptBaseClass(scriptBaseClass);
+                groovyClassLoader = new GroovyClassLoader(getClass().getClassLoader(), conf);
+            }
+        } catch (GenericConfigException gce) {
+            Debug.logWarning(gce, "Error retrieving the configuration for the groovy service engine: ", module);
+        }
     }
 
     /**
@@ -75,7 +91,7 @@ public final class GroovyEngine extends 
         context.put("dispatcher", dctx.getDispatcher());
         context.put("delegator", dispatcher.getDelegator());
         try {
-            Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService)), GroovyUtil.getBinding(context));
+            Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService), groovyClassLoader), GroovyUtil.getBinding(context));
             Object resultObj = null;
             if (UtilValidate.isEmpty(modelService.invoke)) {
                 resultObj = script.run();
@@ -87,6 +103,10 @@ public final class GroovyEngine extends 
             } else if (context.get("result") != null && context.get("result") instanceof Map<?, ?>) {
                 return cast(context.get("result"));
             }
+        } catch (GenericEntityException gee) {
+            return ServiceUtil.returnError(gee.getMessage());
+        } catch (ExecutionServiceException ese) {
+            return ServiceUtil.returnError(ese.getMessage());
         } catch (GeneralException e) {
             throw new GenericServiceException(e);
         }

Modified: ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java Mon Mar 26 20:56:02 2012
@@ -71,7 +71,7 @@ public final class InstrumenterWorker {
             e.printStackTrace();
             return srcPaths;
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
+            System.err.println("InstrumenterWorker.instrument - Code instrumentation has been disabled, unable to find instrumenter class " + instrumenterClassName);
             return srcPaths;
         }
         ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors());

Modified: ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/Start.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/Start.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/Start.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/Start.java Mon Mar 26 20:56:02 2012
@@ -236,10 +236,10 @@ public class Start {
     }
 
     private String sendSocketCommand(String command) throws IOException, ConnectException {
-    	String response = "OFBiz is Down";
-    	
-    	try {
-    	Socket socket = new Socket(config.adminAddress, config.adminPort);
+        String response = "OFBiz is Down";
+
+        try {
+        Socket socket = new Socket(config.adminAddress, config.adminPort);
 
         // send the command
         PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);

Modified: ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/test.properties
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/test.properties?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/test.properties (original)
+++ ofbiz/branches/20111205EmailHandling/framework/start/src/org/ofbiz/base/start/test.properties Mon Mar 26 20:56:02 2012
@@ -59,5 +59,8 @@ ofbiz.instrumenterFile=runtime/logs/cobe
 # --- By default we will find base/config/debug.properties and point to there
 #log4j.configuration=log4j.xml
 
+# -- The default locale for this OFBiz instance.
+ofbiz.locale.default=en
+
 # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11)
 java.awt.headless=true

Modified: ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.bat
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.bat?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.bat (original)
+++ ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.bat Mon Mar 26 20:56:02 2012
@@ -26,7 +26,7 @@ set CP=%CP%;%OFBIZ_HOME%/framework/base/
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/scripting/jython-nooro.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/junit.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/commons/commons-lang-2.3.jar
-set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.15.jar
+set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.16.jar
 
 rem echo %CP%
 

Modified: ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.sh
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.sh?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.sh (original)
+++ ofbiz/branches/20111205EmailHandling/framework/testtools/convertSeleniumIDE.sh Mon Mar 26 20:56:02 2012
@@ -26,7 +26,7 @@ export CP=$CP:$OFBIZ_HOME/framework/base
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/scripting/jython-nooro.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/junit.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/commons/commons-lang-2.3.jar
-export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.15.jar
+export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.16.jar
 
 # echo $CP
 

Modified: ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.bat
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.bat?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.bat (original)
+++ ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.bat Mon Mar 26 20:56:02 2012
@@ -26,7 +26,7 @@ set CP=%CP%;%OFBIZ_HOME%/framework/base/
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/scripting/jython-nooro.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/junit.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/commons/commons-lang-2.3.jar
-set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.15.jar
+set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.16.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/javolution-5.2.3.jar
 set CP=%CP%;%OFBIZ_HOME%/framework/base/build/lib/ofbiz-base.jar
 

Modified: ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.sh
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.sh?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.sh (original)
+++ ofbiz/branches/20111205EmailHandling/framework/testtools/runSeleniumXml.sh Mon Mar 26 20:56:02 2012
@@ -26,7 +26,7 @@ export CP=$CP:$OFBIZ_HOME/framework/base
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/scripting/jython-nooro.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/junit.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/commons/commons-lang-2.3.jar
-export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.15.jar
+export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.16.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/lib/javolution-5.4.3.jar
 export CP=$CP:$OFBIZ_HOME/framework/base/build/lib/ofbiz-base.jar
 

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/config/WebappUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/config/WebappUiLabels.xml?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/config/WebappUiLabels.xml (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/config/WebappUiLabels.xml Mon Mar 26 20:56:02 2012
@@ -218,7 +218,7 @@
     </property>
     <property key="coreEvents.service_dispatcher_exception">
         <value xml:lang="de">Der Service Dispatcher hat eine Exception geworfen</value>
-        <value xml:lang="en">Service dispatcher threw an exception</value>
+        <value xml:lang="en">Service dispatcher threw an exception: </value>
         <value xml:lang="es">Service dispatcher lanzo una excepción</value>
         <value xml:lang="fr">Le service dispatcher a envoyer une exception</value>
         <value xml:lang="it">Dispatcher servizio ha lanciato una eccezione</value>

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/ControlEventListener.java Mon Mar 26 20:56:02 2012
@@ -31,6 +31,7 @@ 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.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.serialize.XmlSerializer;
@@ -75,8 +76,12 @@ public class ControlEventListener implem
             // instead of using this message, get directly from session attribute so it won't create a new one: GenericValue visit = VisitHandler.getVisit(session);
             GenericValue visit = (GenericValue) session.getAttribute("visit");
             if (visit != null) {
-                visit.set("thruDate", new Timestamp(session.getLastAccessedTime()));
-                visit.store();
+                Delegator delegator = visit.getDelegator();
+                visit = delegator.findOne("Visit", UtilMisc.toMap("visitId", visit.get("visitId")), false);
+                if (visit != null) {
+                    visit.set("thruDate", new Timestamp(session.getLastAccessedTime()));
+                    visit.store();
+                }
             } else {
                 Debug.logWarning("Could not find visit value object in session [" + session.getId() + "] that is being destroyed", module);
             }

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Mar 26 20:56:02 2012
@@ -133,7 +133,7 @@ public class LoginWorker {
             String sesExtKey = (String) session.getAttribute(EXTERNAL_LOGIN_KEY_ATTR);
 
             if (sesExtKey != null) {
-                if (isAjax(request)) return sesExtKey; 
+                if (isAjax(request)) return sesExtKey;
 
                 externalLoginKeys.remove(sesExtKey);
             }
@@ -319,39 +319,39 @@ public class LoginWorker {
             request.setAttribute("_ERROR_MESSAGE_LIST_", unpwErrMsgList);
             return "error";
         }
-        
+
         boolean setupNewDelegatorEtc = false;
-        
+
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         Delegator delegator = (Delegator) request.getAttribute("delegator");
 
         // if a tenantId was passed in, see if the userLoginId is associated with that tenantId (can use any delegator for this, entity is not tenant-specific)
         String tenantId = request.getParameter("tenantId");
         if (UtilValidate.isNotEmpty(tenantId)) {
-            // see if we need to activate a tenant delegator, only do if the current delegatorName has a hash symbol in it, and if the passed in tenantId doesn't match the one in the delegatorName 
+            // see if we need to activate a tenant delegator, only do if the current delegatorName has a hash symbol in it, and if the passed in tenantId doesn't match the one in the delegatorName
             String oldDelegatorName = delegator.getDelegatorName();
             int delegatorNameHashIndex = oldDelegatorName.indexOf('#');
             String currentDelegatorTenantId = null;
             if (delegatorNameHashIndex > 0) {
                 currentDelegatorTenantId = oldDelegatorName.substring(delegatorNameHashIndex + 1);
-                if (currentDelegatorTenantId != null) currentDelegatorTenantId.trim();
+                if (currentDelegatorTenantId != null) currentDelegatorTenantId = currentDelegatorTenantId.trim();
             }
-            
+
             if (delegatorNameHashIndex == -1 || (currentDelegatorTenantId != null && !tenantId.equals(currentDelegatorTenantId))) {
-                /* don't require this, allow a user to authenticate inside the tenant as long as the userLoginId and 
-                 * password match what is in that tenant's database; instead just set things up below 
+                /* don't require this, allow a user to authenticate inside the tenant as long as the userLoginId and
+                 * password match what is in that tenant's database; instead just set things up below
                 try {
                     List<GenericValue> tenantUserLoginList = delegator.findList("TenantUserLogin", EntityCondition.makeCondition(EntityOperator.AND, "tenantId", tenantId, "userLoginId", username), null, null, null, false);
                     if (tenantUserLoginList != null && tenantUserLoginList.size() > 0) {
                         ServletContext servletContext = session.getServletContext();
-                        
+
                         // if so make that tenant active, setup a new delegator and a new dispatcher
                         String delegatorName = delegator.getDelegatorName() + "#" + tenantId;
-                        
+
                         // after this line the delegator is replaced with the new per-tenant delegator
                         delegator = DelegatorFactory.getDelegator(delegatorName);
                         dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator);
-                        
+
                         // NOTE: these will be local for now and set in the request and session later, after we've verified that the user
                         setupNewDelegatorEtc = true;
                     } else {
@@ -369,10 +369,10 @@ public class LoginWorker {
                 */
 
                 ServletContext servletContext = session.getServletContext();
-                
+
                 // make that tenant active, setup a new delegator and a new dispatcher
                 String delegatorName = delegator.getDelegatorBaseName() + "#" + tenantId;
-                
+
                 try {
                     // after this line the delegator is replaced with the new per-tenant delegator
                     delegator = DelegatorFactory.getDelegator(delegatorName);
@@ -384,7 +384,7 @@ public class LoginWorker {
                     request.setAttribute("_ERROR_MESSAGE_", errMsg);
                     return "error";
                 }
-                
+
                 // NOTE: these will be local for now and set in the request and session later, after we've verified that the user
                 setupNewDelegatorEtc = true;
             }
@@ -449,7 +449,7 @@ public class LoginWorker {
                 // now set the delegator and dispatcher in a bunch of places just in case they were changed
                 setWebContextObjects(request, response, delegator, dispatcher, true);
             }
-            
+
             // check to see if a password change is required for the user
             Map<String, Object> userLoginSession = checkMap(result.get("userLoginSession"), String.class, Object.class);
             if (userLogin != null && "Y".equals(userLogin.getString("requirePasswordChange"))) {
@@ -466,7 +466,7 @@ public class LoginWorker {
             } catch (GenericServiceException e) {
                 Debug.logError(e, "Error setting user preference", module);
             }
-            
+
             // finally do the main login routine to set everything else up in the session, etc
             return doMainLogin(request, response, userLogin, userLoginSession);
         } else {
@@ -476,30 +476,30 @@ public class LoginWorker {
             return "error";
         }
     }
-    
-    /*         persistSerialized is set at false in the context of a cluster when using (at least) DeltaManager. 
+
+    /*         persistSerialized is set at false in the context of a cluster when using (at least) DeltaManager.
             Because we have no easy ways to set DeltaManager.pathname to null from OFBiz
            So persistSerialized is set to true when login out. This prevent a NPE due to non serialized objects put in session*/
     private static void setWebContextObjects(HttpServletRequest request, HttpServletResponse response, Delegator delegator, LocalDispatcher dispatcher, Boolean persistSerialized) {
         HttpSession session = request.getSession();
-        
+
         // NOTE: we do NOT want to set this in the servletContet, only in the request and session
         session.setAttribute("delegatorName", delegator.getDelegatorName());
-        
+
         request.setAttribute("delegator", delegator);
         if (!persistSerialized) {
             session.setAttribute("delegator", null);
         } else {
             session.setAttribute("delegator", delegator);
         }
-        
+
         request.setAttribute("dispatcher", dispatcher);
         if (!persistSerialized) {
             session.setAttribute("dispatcher", null);
         } else {
             session.setAttribute("dispatcher", dispatcher);
         }
-        
+
         if (persistSerialized) {
             // we also need to setup the security and authz objects since they are dependent on the delegator
             try {
@@ -509,7 +509,7 @@ public class LoginWorker {
             } catch (SecurityConfigurationException e) {
                 Debug.logError(e, module);
             }
-            
+
             try {
                 Authorization authz = AuthorizationFactory.getInstance(delegator);
                 request.setAttribute("authz", authz);
@@ -518,7 +518,7 @@ public class LoginWorker {
                 Debug.logError(e, module);
             }
         }
-        
+
         // get rid of the visit info since it was pointing to the previous database, and get a new one
         session.removeAttribute("visitor");
         session.removeAttribute("visit");
@@ -641,7 +641,7 @@ public class LoginWorker {
 
         // setup some things that should always be there
         UtilHttp.setInitialRequestInfo(request);
-        
+
         if (currCatalog != null) session.setAttribute("CURRENT_CATALOG_ID", currCatalog);
         if (delegatorName != null) {
             // if there is a tenantId in the delegatorName remove it now so that tenant selection doesn't last beyond logout
@@ -652,7 +652,7 @@ public class LoginWorker {
 
             delegator = DelegatorFactory.getDelegator(delegatorName);
             LocalDispatcher dispatcher = ContextFilter.makeWebappDispatcher(session.getServletContext(), delegator);
-            // get the container configuration           
+            // get the container configuration
             String ofbizHome = System.getProperty("ofbiz.home");
             String configFile = ofbizHome + "/framework/base/config/ofbiz-containers.xml";
             ContainerConfig.Container cc = null;
@@ -669,7 +669,7 @@ public class LoginWorker {
                 setWebContextObjects(request, response, delegator, dispatcher, true);
             }
         }
-        
+
         // DON'T save the cart, causes too many problems: if (shoppingCart != null) session.setAttribute("shoppingCart", new WebShoppingCart(shoppingCart, session));
     }
 
@@ -972,7 +972,7 @@ public class LoginWorker {
 
         GenericValue userLogin = LoginWorker.externalLoginKeys.get(externalKey);
         if (userLogin != null) {
-            //to check it's the right tenant 
+            //to check it's the right tenant
             //in case username and password are the same in different tenants
             LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
             Delegator delegator = (Delegator) request.getAttribute("delegator");
@@ -1069,9 +1069,9 @@ public class LoginWorker {
         }
         return userLoginSessionMap;
     }
-    
+
     public static boolean isAjax(HttpServletRequest request) {
        return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
     }
-    
+
 }

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Mon Mar 26 20:56:02 2012
@@ -139,6 +139,18 @@ public class RequestHandler {
                 requestMap = requestMapMap.get(defaultRequest);
             }
         }
+
+        // check for override view
+        if (overrideViewUri != null) {
+            ConfigXMLReader.ViewMap viewMap = getControllerConfig().getViewMapMap().get(overrideViewUri);
+            if (viewMap == null) {
+                String defaultRequest = controllerConfig.getDefaultRequest();
+                if (defaultRequest != null) { // required! to avoid a null pointer exception and generate a requesthandler exception if default request not found.
+                    requestMap = requestMapMap.get(defaultRequest);
+                }
+            }
+        }
+
         // still not found so stop
         if (requestMap == null) {
             throw new RequestHandlerException(requestMissingErrorMessage);
@@ -916,7 +928,7 @@ public class RequestHandler {
      * @return return the query string
      */
     public String makeQueryString(HttpServletRequest request, ConfigXMLReader.RequestResponse requestResponse) {
-        if (requestResponse == null || 
+        if (requestResponse == null ||
                 (requestResponse.redirectParameterMap.size() == 0 && requestResponse.redirectParameterValueMap.size() == 0)) {
             Map<String, Object> urlParams = UtilHttp.getUrlOnlyParameterMap(request);
             String queryString = UtilHttp.urlEncodeArgs(urlParams, false);
@@ -1101,6 +1113,7 @@ public class RequestHandler {
                         newURL.insert(questionIndex, sessionId);
                     }
                 }
+
                 encodedUrl = newURL.toString();
             }
         } else {

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java Mon Mar 26 20:56:02 2012
@@ -109,12 +109,12 @@ public class CoreEvents {
 
         if (!authz.hasPermission(request.getSession(), "ENTITY_MAINT", null)) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.not_authorized_use_fct", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
         if (delegatorName == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.delegator_not_passed", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -122,7 +122,7 @@ public class CoreEvents {
 
         if (delegator == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.no_delegator_name_defined", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -133,12 +133,12 @@ public class CoreEvents {
 
         if (dispatcherName == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.dispatcher_name_null", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
         if (dctx == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.dispatcher_context_null", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -163,12 +163,12 @@ public class CoreEvents {
 
         if (!authz.hasPermission(request.getSession(), "ENTITY_MAINT", null)) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.not_authorized_use_fct", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
         if (dispatcherName == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.dispatcher_not_passed", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -177,7 +177,7 @@ public class CoreEvents {
 
         if (sd == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.no_dispachter_name_registered", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
         LocalDispatcher dispatcher = sd.getLocalContext(dispatcherName).getDispatcher();
@@ -243,7 +243,7 @@ public class CoreEvents {
         // make sure we passed a service
         if (serviceName == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.must_specify_service", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -254,12 +254,12 @@ public class CoreEvents {
         } catch (GenericServiceException e) {
             Debug.logError(e, "Error looking up ModelService for serviceName [" + serviceName + "]", module);
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.error_modelservice_for_srv_name", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + " [" + serviceName + "]: " + e.toString());
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + " [" + serviceName + "]: " + e.toString());
             return "error";
         }
         if (modelService == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_name_not_find", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + " [" + serviceName + "]");
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + " [" + serviceName + "]");
             return "error";
         }
 
@@ -308,7 +308,7 @@ public class CoreEvents {
 
         if (!modelService.export && !authz.hasPermission(request.getSession(), "SERVICE_INVOKE_ANY", null)) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.not_authorized_to_call", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -322,12 +322,12 @@ public class CoreEvents {
                     startTime = Long.parseLong(serviceTime);
                 } catch (NumberFormatException nfe) {
                     String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_time", locale);
-                    errorBuf.append("<li>" + errMsg);
+                    errorBuf.append(errMsg);
                 }
             }
             if (startTime < (new Date()).getTime()) {
                 String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_time_already_passed", locale);
-                errorBuf.append("<li>" + errMsg);
+                errorBuf.append(errMsg);
             }
         }
         if (UtilValidate.isNotEmpty(serviceEndTime)) {
@@ -339,12 +339,12 @@ public class CoreEvents {
                     endTime = Long.parseLong(serviceTime);
                 } catch (NumberFormatException nfe) {
                     String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_time", locale);
-                    errorBuf.append("<li>" + errMsg);
+                    errorBuf.append(errMsg);
                 }
             }
             if (endTime < (new Date()).getTime()) {
                 String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_time_already_passed", locale);
-                errorBuf.append("<li>" + errMsg);
+                errorBuf.append(errMsg);
             }
         }
         if (UtilValidate.isNotEmpty(serviceIntr)) {
@@ -352,7 +352,7 @@ public class CoreEvents {
                 interval = Integer.parseInt(serviceIntr);
             } catch (NumberFormatException nfe) {
                 String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_interval", locale);
-                errorBuf.append("<li>" + errMsg);
+                errorBuf.append(errMsg);
             }
         }
         if (UtilValidate.isNotEmpty(serviceCnt)) {
@@ -360,7 +360,7 @@ public class CoreEvents {
                 count = Integer.parseInt(serviceCnt);
             } catch (NumberFormatException nfe) {
                 String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_count", locale);
-                errorBuf.append("<li>" + errMsg);
+                errorBuf.append(errMsg);
             }
         }
         if (UtilValidate.isNotEmpty(serviceFreq)) {
@@ -376,7 +376,7 @@ public class CoreEvents {
             if (parsedValue == 0) {
                 if (!freqMap.containsKey(serviceFreq.toUpperCase())) {
                     String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_frequency", locale);
-                    errorBuf.append("<li>" + errMsg);
+                    errorBuf.append(errMsg);
                 } else {
                     frequency = freqMap.get(serviceFreq.toUpperCase()).intValue();
                 }
@@ -415,7 +415,7 @@ public class CoreEvents {
             }
         } catch (GenericServiceException e) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_dispatcher_exception", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + e.getMessage());
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + e.getMessage());
             return "error";
         }
 
@@ -434,7 +434,7 @@ public class CoreEvents {
         Map<String, Object> syncServiceResult = checkMap(session.getAttribute("_RUN_SYNC_RESULT_"), String.class, Object.class);
         if (null==syncServiceResult) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.no_fields_in_session", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -519,7 +519,7 @@ public class CoreEvents {
 
         if (UtilValidate.isEmpty(serviceName)) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.must_specify_service_name", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
@@ -538,18 +538,18 @@ public class CoreEvents {
         } catch (GenericServiceException e) {
             Debug.logError(e, "Error looking up ModelService for serviceName [" + serviceName + "]", module);
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.error_modelservice_for_srv_name", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "[" + serviceName + "]: " + e.toString());
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + "[" + serviceName + "]: " + e.toString());
             return "error";
         }
         if (modelService == null) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_name_not_find", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "[" + serviceName + "]");
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + "[" + serviceName + "]");
             return "error";
         }
 
         if (!modelService.export && !authz.hasPermission(request.getSession(), "SERVICE_INVOKE_ANY", null)) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.not_authorized_to_call", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + ".");
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + ".");
             return "error";
         }
 
@@ -562,7 +562,7 @@ public class CoreEvents {
             return seh.invoke(event, null, request, response);
         } catch (EventHandlerException e) {
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_eventhandler_exception", locale);
-            request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + ": " + e.getMessage());
+            request.setAttribute("_ERROR_MESSAGE_", errMsg + ": " + e.getMessage());
             return "error";
         }
     }

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java Mon Mar 26 20:56:02 2012
@@ -25,19 +25,42 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.Script;
+import org.codehaus.groovy.control.CompilerConfiguration;
+import org.codehaus.groovy.runtime.InvokerHelper;
 import javolution.util.FastMap;
 
+import org.ofbiz.base.config.GenericConfigException;
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GroovyUtil;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.service.ExecutionServiceException;
+import org.ofbiz.service.config.ServiceConfigUtil;
 import org.ofbiz.webapp.control.ConfigXMLReader.Event;
 import org.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
 
 public class GroovyEventHandler implements EventHandler {
 
     public static final String module = GroovyEventHandler.class.getName();
+    protected static final Object[] EMPTY_ARGS = {};
+    private GroovyClassLoader groovyClassLoader;
 
     public void init(ServletContext context) throws EventHandlerException {
+        try {
+            // TODO: the name of the script base class is currently retrieved from the Groovy service engine configuration
+            String scriptBaseClass = ServiceConfigUtil.getEngineParameter("groovy", "scriptBaseClass");
+            if (scriptBaseClass != null) {
+                CompilerConfiguration conf = new CompilerConfiguration();
+                conf.setScriptBaseClass(scriptBaseClass);
+                groovyClassLoader = new GroovyClassLoader(getClass().getClassLoader(), conf);
+            }
+        } catch (GenericConfigException gce) {
+            Debug.logWarning(gce, "Error retrieving the configuration for the groovy service engine: ", module);
+        }
     }
 
     public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException {
@@ -56,7 +79,19 @@ public class GroovyEventHandler implemen
             groovyContext.put("userLogin", session.getAttribute("userLogin"));
             groovyContext.put("parameters", UtilHttp.getCombinedMap(request, UtilMisc.toSet("delegator", "dispatcher", "security", "locale", "timeZone", "userLogin")));
 
-            Object result = GroovyUtil.runScriptAtLocation(event.path + event.invoke, groovyContext);
+            Object result = null;
+            try {
+                Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(event.path, groovyClassLoader), GroovyUtil.getBinding(groovyContext));
+                if (UtilValidate.isEmpty(event.invoke)) {
+                    result = script.run();
+                } else {
+                    result = script.invokeMethod(event.invoke, EMPTY_ARGS);
+                }
+            } catch (GenericEntityException gee) {
+                return "error";
+            } catch (ExecutionServiceException ese) {
+                return "error";
+            }
             // check the result
             if (result != null && !(result instanceof String)) {
                 throw new EventHandlerException("Event did not return a String result, it returned a " + result.getClass().getName());

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java Mon Mar 26 20:56:02 2012
@@ -56,7 +56,6 @@ import org.ofbiz.service.ServiceUtil;
 import org.ofbiz.service.engine.SoapSerializer;
 import org.ofbiz.webapp.control.ConfigXMLReader.Event;
 import org.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
-import org.ofbiz.webapp.control.ConfigXMLReader;
 import org.ofbiz.webapp.control.RequestHandler;
 import org.w3c.dom.Document;
 
@@ -97,7 +96,7 @@ public class SOAPEventHandler implements
                 } catch (GenericServiceException e) {
                     serviceName = null;
                 } catch (WSDLException e) {
-                    sendError(response, "Unable to obtain WSDL");
+                    sendError(response, "Unable to obtain WSDL", serviceName);
                     throw new EventHandlerException("Unable to obtain WSDL", e);
                 }
 
@@ -112,7 +111,7 @@ public class SOAPEventHandler implements
                     }
                     return null;
                 } else {
-                    sendError(response, "Unable to obtain WSDL");
+                    sendError(response, "Unable to obtain WSDL", serviceName);
                     throw new EventHandlerException("Unable to obtain WSDL");
                 }
             }
@@ -137,7 +136,7 @@ public class SOAPEventHandler implements
                     writer.flush();
                     return null;
                 } catch (Exception e) {
-                    sendError(response, "Unable to obtain WSDL");
+                    sendError(response, "Unable to obtain WSDL", null);
                     throw new EventHandlerException("Unable to obtain WSDL");
                 }
             }
@@ -163,30 +162,31 @@ public class SOAPEventHandler implements
                 }
             }
         } catch (Exception e) {
-            sendError(response, "Problem processing the service");
+            sendError(response, "Problem processing the service", null);
             throw new EventHandlerException("Cannot get the envelope", e);
         }
 
         Debug.logVerbose("[Processing]: SOAP Event", module);
 
+        String serviceName = null;
         try {
             SOAPBody reqBody = reqEnv.getBody();
             validateSOAPBody(reqBody);
             OMElement serviceElement = reqBody.getFirstElement();
-            String serviceName = serviceElement.getLocalName();
+            serviceName = serviceElement.getLocalName();
             Map<String, Object> parameters = UtilGenerics.cast(SoapSerializer.deserialize(serviceElement.toString(), delegator));
             try {
                 // verify the service is exported for remote execution and invoke it
                 ModelService model = dispatcher.getDispatchContext().getModelService(serviceName);
 
                 if (model == null) {
-                    sendError(response, "Problem processing the service");
+                    sendError(response, "Problem processing the service", serviceName);
                     Debug.logError("Could not find Service [" + serviceName + "].", module);
                     return null;
                 }
 
                 if (!model.export) {
-                    sendError(response, "Problem processing the service");
+                    sendError(response, "Problem processing the service", serviceName);
                     Debug.logError("Trying to call Service [" + serviceName + "] that is not exported.", module);
                     return null;
                 }
@@ -198,19 +198,19 @@ public class SOAPEventHandler implements
 
             } catch (GenericServiceException e) {
                 if (UtilProperties.getPropertyAsBoolean("service", "secureSoapAnswer", true)) {
-                    sendError(response, "Problem processing the service, check your parameters.");
+                    sendError(response, "Problem processing the service, check your parameters.", serviceName);
                 } else {
                     if(e.getMessageList() == null) {
-                        sendError(response, e.getMessage());
+                        sendError(response, e.getMessage(), serviceName);
                     } else {
-                        sendError(response, e.getMessageList());
+                        sendError(response, e.getMessageList(), serviceName);
                     }
                     Debug.logError(e, module);
                     return null;
                 }
             }
         } catch (Exception e) {
-            sendError(response, e.getMessage());
+            sendError(response, e.getMessage(), serviceName);
             Debug.logError(e, module);
             return null;
         }
@@ -236,6 +236,7 @@ public class SOAPEventHandler implements
         // setup the response
             Debug.logVerbose("[EventHandler] : Setting up response message", module);
             String xmlResults = SoapSerializer.serialize(serviceResults);
+            //Debug.log("xmlResults ==================" + xmlResults, module);
             XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
             StAXOMBuilder resultsBuilder = new StAXOMBuilder(reader);
             OMElement resultSer = resultsBuilder.getDocumentElement();
@@ -272,15 +273,15 @@ public class SOAPEventHandler implements
         }
     }
 
-    private void sendError(HttpServletResponse res, String errorMessage) throws EventHandlerException {
+    private void sendError(HttpServletResponse res, String errorMessage, String serviceName) throws EventHandlerException {
         // setup the response
-        sendError(res, ServiceUtil.returnError(errorMessage));
+        sendError(res, ServiceUtil.returnError(errorMessage), serviceName);
     }
 
-    private void sendError(HttpServletResponse res, List<String> errorMessages) throws EventHandlerException {
-        sendError(res, ServiceUtil.returnError(errorMessages));
+    private void sendError(HttpServletResponse res, List<String> errorMessages, String serviceName) throws EventHandlerException {
+        sendError(res, ServiceUtil.returnError(errorMessages.toString()), serviceName);
     }
-    private void sendError(HttpServletResponse res, Object object) throws EventHandlerException {
+    private void sendError(HttpServletResponse res, Object object, String serviceName) throws EventHandlerException {
         try {
             // setup the response
             res.setContentType("text/xml");
@@ -293,11 +294,18 @@ public class SOAPEventHandler implements
             SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
             SOAPEnvelope resEnv = factory.createSOAPEnvelope();
             SOAPBody resBody = factory.createSOAPBody();
-            OMElement errMsg = factory.createOMElement(new QName("Response"));
+            OMElement errMsg = factory.createOMElement(new QName((serviceName != null ? serviceName : "") + "Response"));
             errMsg.addChild(resultSer.getFirstElement());
             resBody.addChild(errMsg);
             resEnv.addChild(resBody);
 
+            // The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156)
+            // so the following doesn't work:
+            // resService.declareDefaultNamespace(ModelService.TNS);
+            // instead, create the xmlns attribute directly:
+            OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
+            errMsg.addAttribute(defaultNS);
+
             // log the response message
             if (Debug.verboseOn()) {
                 try {

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Mon Mar 26 20:56:02 2012
@@ -43,9 +43,10 @@ import org.apache.commons.fileupload.ser
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
-import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityUtilProperties;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -127,7 +128,7 @@ public class ServiceEventHandler impleme
         if (Debug.verboseOn()) Debug.logVerbose("[Using delegator]: " + dispatcher.getDelegator().getDelegatorName(), module);
 
         // get the http upload configuration
-        String maxSizeStr = UtilProperties.getPropertyValue("general.properties", "http.upload.max.size", "-1");
+        String maxSizeStr = EntityUtilProperties.getPropertyValue("general.properties", "http.upload.max.size", "-1", dctx.getDelegator());
         long maxUploadSize = -1;
         try {
             maxUploadSize = Long.parseLong(maxSizeStr);
@@ -137,7 +138,7 @@ public class ServiceEventHandler impleme
         }
         // get the http size threshold configuration - files bigger than this will be
         // temporarly stored on disk during upload
-        String sizeThresholdStr = UtilProperties.getPropertyValue("general.properties", "http.upload.max.sizethreshold", "10240");
+        String sizeThresholdStr = EntityUtilProperties.getPropertyValue("general.properties", "http.upload.max.sizethreshold", "10240", dctx.getDelegator());
         int sizeThreshold = 10240; // 10K
         try {
             sizeThreshold = Integer.parseInt(sizeThresholdStr);
@@ -146,7 +147,7 @@ public class ServiceEventHandler impleme
             sizeThreshold = -1;
         }
         // directory used to temporarily store files that are larger than the configured size threshold
-        String tmpUploadRepository = UtilProperties.getPropertyValue("general.properties", "http.upload.tmprepository", "runtime/tmp");
+        String tmpUploadRepository = EntityUtilProperties.getPropertyValue("general.properties", "http.upload.tmprepository", "runtime/tmp", dctx.getDelegator());
         String encoding = request.getCharacterEncoding();
         // check for multipart content types which may have uploaded items
         boolean isMultiPart = ServletFileUpload.isMultipartContent(request);
@@ -264,7 +265,7 @@ public class ServiceEventHandler impleme
 
                 // check the request parameters
                 if (UtilValidate.isEmpty(value)) {
-                    ServiceEventHandler.checkSecureParameter(requestMap, urlOnlyParameterNames, name, session, serviceName);
+                    ServiceEventHandler.checkSecureParameter(requestMap, urlOnlyParameterNames, name, session, serviceName, dctx.getDelegator());
 
                     // if the service modelParam has allow-html="any" then get this direct from the request instead of in the parameters Map so there will be no canonicalization possibly messing things up
                     if ("any".equals(modelParam.allowHtml)) {
@@ -391,7 +392,7 @@ public class ServiceEventHandler impleme
         return responseString;
     }
 
-    public static void checkSecureParameter(RequestMap requestMap, Set<String> urlOnlyParameterNames, String name, HttpSession session, String serviceName) throws EventHandlerException {
+    public static void checkSecureParameter(RequestMap requestMap, Set<String> urlOnlyParameterNames, String name, HttpSession session, String serviceName, Delegator delegator) throws EventHandlerException {
         // special case for security: if this is a request-map defined as secure in controller.xml then only accept body parameters coming in, ie don't allow the insecure URL parameters
         // NOTE: the RequestHandler will check the HttpSerletRequest security to make sure it is secure if the request-map -> security -> https=true, but we can't just look at the request.isSecure() method here because it is allowed to send secure requests for request-map with https=false
         if (requestMap != null && requestMap.securityHttps) {
@@ -407,7 +408,7 @@ public class ServiceEventHandler impleme
                 Debug.logError("=============== " + errMsg + "; In session [" + session.getId() + "]; Note that this can be changed using the service.http.parameters.require.encrypted property in the url.properties file", module);
 
                 // the default here is true, so anything but N/n is true
-                boolean requireEncryptedServiceWebParameters = !UtilProperties.propertyValueEqualsIgnoreCase("url.properties", "service.http.parameters.require.encrypted", "N");
+                boolean requireEncryptedServiceWebParameters = !EntityUtilProperties.propertyValueEqualsIgnoreCase("url.properties", "service.http.parameters.require.encrypted", "N", delegator);
 
                 // NOTE: this forces service call event parameters to be in the body and not in the URL! can be issues with existing links, like Delete links or whatever, and those need to be changed to forms!
                 if (requireEncryptedServiceWebParameters) {

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java Mon Mar 26 20:56:02 2012
@@ -224,7 +224,7 @@ public class ServiceMultiEventHandler im
                         if (value == null) {
                             String name = paramName + curSuffix;
 
-                            ServiceEventHandler.checkSecureParameter(requestMap, urlOnlyParameterNames, name, session, serviceName);
+                            ServiceEventHandler.checkSecureParameter(requestMap, urlOnlyParameterNames, name, session, serviceName, dctx.getDelegator());
 
                             String[] paramArr = request.getParameterValues(name);
                             if (paramArr != null) {

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizContentTransform.java Mon Mar 26 20:56:02 2012
@@ -102,7 +102,8 @@ public class OfbizContentTransform imple
                     // make the link
                     StringBuilder newURL = new StringBuilder();
                     ContentUrlTag.appendContentPrefix(request, newURL);
-                    if (newURL.length() > 0 && newURL.charAt(newURL.length() - 1) != '/' && requestUrl.charAt(0) != '/') {
+                    if ((newURL.length() > 0 && newURL.charAt(newURL.length() - 1) != '/') 
+                    		&& (requestUrl.length()> 0 && requestUrl.charAt(0) != '/')) {
                         newURL.append('/');
                     }
 

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java Mon Mar 26 20:56:02 2012
@@ -37,6 +37,9 @@ import freemarker.template.TemplateTrans
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.util.EntityUtilProperties;
 
 /**
  * OfbizCurrencyTransform - Freemarker Transform for content links
@@ -125,6 +128,22 @@ public class OfbizCurrencyTransform impl
         // rounding should be handled by the code, however some times the numbers are coming from
         // someplace else (i.e. an integration)
         Integer roundingNumber = getInteger(args, "rounding");
+        Environment env = Environment.getCurrentEnvironment();
+        BeanModel req = null;
+        try {
+            req = (BeanModel) env.getVariable("request");
+        } catch (TemplateModelException e) {
+            Debug.logError(e.getMessage(), module);
+        }
+        if (req != null) {
+            HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
+            Delegator delegator = (Delegator) request.getAttribute("delegator");
+            // Get rounding from SystemProperty
+            if (UtilValidate.isNotEmpty(delegator)) {
+                String roundingString = EntityUtilProperties.getPropertyValue("general.properties", "currency.rounding.default", "10", delegator);
+                if (UtilValidate.isInteger(roundingString)) roundingNumber = Integer.parseInt(roundingString);
+            }
+        }
         if (roundingNumber == null) roundingNumber = 10;
         final int rounding = roundingNumber;
 

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java Mon Mar 26 20:56:02 2012
@@ -18,15 +18,34 @@
  *******************************************************************************/
 package org.ofbiz.webapp.ftl;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.Writer;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
 
+import org.ofbiz.base.component.ComponentConfig;
+import org.ofbiz.base.component.ComponentConfig.WebappInfo;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
 import org.ofbiz.webapp.control.RequestHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 import freemarker.core.Environment;
 import freemarker.ext.beans.BeanModel;
@@ -62,6 +81,7 @@ public class OfbizUrlTransform implement
         final boolean fullPath = checkArg(args, "fullPath", false);
         final boolean secure = checkArg(args, "secure", false);
         final boolean encode = checkArg(args, "encode", true);
+        final String webSiteId = getArg(args, "webSiteId");
 
         return new Writer(out) {
             @Override
@@ -81,7 +101,109 @@ public class OfbizUrlTransform implement
                     BeanModel req = (BeanModel) env.getVariable("request");
                     BeanModel res = (BeanModel) env.getVariable("response");
                     Object prefix = env.getVariable("urlPrefix");
-                    if (req != null) {
+                    if (UtilValidate.isNotEmpty(webSiteId)) {
+                        HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
+                        Delegator delegator = (Delegator) request.getAttribute("delegator");
+                        String httpsPort = null;
+                        String httpsServer = null;
+                        String httpPort = null;
+                        String httpServer = null;
+                        Boolean enableHttps = null;
+                        StringBuilder newURL = new StringBuilder();
+                        // make prefix url
+                        try {
+                            GenericValue webSite = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId));
+                            if (webSite != null) {
+                                httpsPort = webSite.getString("httpsPort");
+                                httpsServer = webSite.getString("httpsHost");
+                                httpPort = webSite.getString("httpPort");
+                                httpServer = webSite.getString("httpHost");
+                                enableHttps = webSite.getBoolean("enableHttps");
+                            }
+                        } catch (GenericEntityException e) {
+                            Debug.logWarning(e, "Problems with WebSite entity; using global defaults", module);
+                        }
+                        // fill in any missing properties with fields from the global file
+                        if (UtilValidate.isEmpty(httpsPort)) {
+                            httpsPort = UtilProperties.getPropertyValue("url.properties", "port.https", "443");
+                        }
+                        if (UtilValidate.isEmpty(httpsServer)) {
+                            httpsServer = UtilProperties.getPropertyValue("url.properties", "force.https.host");
+                        }
+                        if (UtilValidate.isEmpty(httpPort)) {
+                            httpPort = UtilProperties.getPropertyValue("url.properties", "port.http", "80");
+                        }
+                        if (UtilValidate.isEmpty(httpServer)) {
+                            httpServer = UtilProperties.getPropertyValue("url.properties", "force.http.host");
+                        }
+                        if (enableHttps == null) {
+                            enableHttps = UtilProperties.propertyValueEqualsIgnoreCase("url.properties", "port.https.enabled", "Y");
+                        }
+                        if (secure && enableHttps) {
+                            String server = httpsServer;
+                            if (UtilValidate.isEmpty(server)) {
+                                server = request.getServerName();
+                            }
+                            newURL.append("https://");
+                            newURL.append(httpsServer);
+                            newURL.append(":").append(httpsPort);
+                        } else {
+                            newURL.append("http://");
+                            newURL.append(httpServer);
+                            if (!"80".equals(httpPort)) {
+                                newURL.append(":").append(httpPort);
+                            }
+                        }
+                        // make mount point
+                        String mountPoint = null;
+                        for (WebappInfo webAppInfo : ComponentConfig.getAllWebappResourceInfos()) {
+                            File file = new File(webAppInfo.getLocation() + "/WEB-INF/web.xml");
+                            if (!file.exists()) {
+                                continue;
+                            }
+                            InputStream is = new FileInputStream(file);
+                            try {
+                                Document doc = UtilXml.readXmlDocument(is, true, null);
+                                NodeList nList = doc.getElementsByTagName("context-param");
+                                for (int temp = 0; temp < nList.getLength(); temp++) {
+                                    Node nNode = nList.item(temp);
+                                    if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+                                        Element eElement = (Element) nNode;
+                                        String paramName = getTagValue("param-name",eElement);
+                                        String paramValue = getTagValue("param-value",eElement);
+                                        if ("webSiteId".equals(paramName) && webSiteId.equals(paramValue)) {
+                                            mountPoint = webAppInfo.getContextRoot();
+                                            break;
+                                        }
+                                    }
+                                }
+                            } catch (SAXException e) {
+                                Debug.logWarning(e, e.getMessage(), module);
+                            } catch (ParserConfigurationException e) {
+                                Debug.logWarning(e, e.getMessage(), module);
+                            }
+                            if (UtilValidate.isNotEmpty(mountPoint)) {
+                            if (mountPoint.length() > 1) newURL.append(mountPoint);
+                                break;
+                            }
+                        }
+                        // make the path the the control servlet
+                        String controlPath = (String) request.getAttribute("_CONTROL_PATH_");
+                        String[] patch = controlPath.split("/");
+                        String patchStr = null;
+                        if (patch.length > 0) {
+                        patchStr = patch[patch.length-1];
+                        }
+                        if (UtilValidate.isNotEmpty(patchStr)) {
+                        newURL.append("/");
+                        newURL.append(patchStr);
+                        }
+                        newURL.append("/");
+                        // make requestUrl
+                        String requestUrl = buf.toString();
+                        newURL.append(requestUrl);
+                        out.write(newURL.toString());
+                    } else if (req != null) {
                         HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
                         ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
                         HttpServletResponse response = null;
@@ -117,4 +239,32 @@ public class OfbizUrlTransform implement
             }
         };
     }
+    private static String getArg(Map args, String key) {
+        String  result = "";
+        Object o = args.get(key);
+        if (o != null) {
+            if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module);
+            if (o instanceof TemplateScalarModel) {
+                TemplateScalarModel s = (TemplateScalarModel) o;
+                try {
+                    result = s.getAsString();
+                } catch (TemplateModelException e) {
+                    Debug.logError(e, "Template Exception", module);
+                }
+            } else {
+              result = o.toString();
+            }
+        }
+        return result;
+    }
+    private static String getTagValue(String sTag, Element eElement){
+    String value = "";
+        try{
+            NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes();
+            Node nValue = (Node) nlList.item(0);
+            return value = nValue.getNodeValue();
+        } catch (Exception e) {
+            return value;
+        }
+    }
 }

Modified: ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java Mon Mar 26 20:56:02 2012
@@ -619,10 +619,16 @@ public class ServerHitBin {
             GenericValue visit = VisitHandler.getVisit(request.getSession());
             if (visit == null) {
                 // no visit info stored, so don't store the ServerHit
-                Debug.logWarning("Could not find a visitId, so not storing ServerHit. This is probably a configuration error. If you turn of persistance of visits you should also turn off persistence of hits.", module);
+                Debug.logWarning("Could not find a visitId, so not storing ServerHit. This is probably a configuration error. If you turn off persistance of visits you should also turn off persistence of hits.", module);
                 return;
             }
             String visitId = visit.getString("visitId");
+            visit = delegator.findOne("Visit", UtilMisc.toMap("visitId", visitId), true);
+            if (visit == null) {
+                // GenericValue stored in client session does not exist in database.
+                Debug.logInfo("The Visit GenericValue stored in the client session does not exist in the database, not storing server hit.", module);
+                return;
+            }
             
             Debug.logInfo("Visit delegatorName=" + visit.getDelegator().getDelegatorName() + ", ServerHitBin delegatorName=" + this.delegator.getDelegatorName(), module);
             

Modified: ofbiz/branches/20111205EmailHandling/framework/webtools/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webtools/servicedef/services.xml?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webtools/servicedef/services.xml (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webtools/servicedef/services.xml Mon Mar 26 20:56:02 2012
@@ -87,6 +87,7 @@ under the License.
         <description>Exports all entities into xml files</description>
         <permission-service service-name="entityMaintPermCheck" main-action="VIEW"/>
         <attribute name="outpath" type="String" mode="IN" optional="true"/>
+        <attribute name="fromDate" type="Timestamp" mode="IN" optional="true"/>
         <attribute name="txTimeout" type="Integer" mode="IN" optional="true"/>
         <attribute name="results" type="List" mode="OUT" optional="false"/>
     </service>

Modified: ofbiz/branches/20111205EmailHandling/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=1305581&r1=1305580&r2=1305581&view=diff
==============================================================================
--- ofbiz/branches/20111205EmailHandling/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/branches/20111205EmailHandling/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Mon Mar 26 20:56:02 2012
@@ -31,6 +31,7 @@ import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.sql.Timestamp;
 import java.text.NumberFormat;
 import java.util.Collection;
 import java.util.Iterator;
@@ -62,6 +63,8 @@ import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.DelegatorFactory;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.model.ModelFieldType;
@@ -468,6 +471,7 @@ public class WebToolsServices {
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         String outpath = (String)context.get("outpath"); // mandatory
+        Timestamp fromDate = (Timestamp)context.get("fromDate");
         Integer txTimeout = (Integer)context.get("txTimeout");
         if (txTimeout == null) {
             txTimeout = Integer.valueOf(7200);
@@ -505,7 +509,11 @@ public class WebToolsServices {
                         boolean beganTx = TransactionUtil.begin();
                         // some databases don't support cursors, or other problems may happen, so if there is an error here log it and move on to get as much as possible
                         try {
-                            values = delegator.find(curEntityName, null, null, null, me.getPkFieldNames(), null);
+                            List<EntityCondition> conds = FastList.newInstance();
+                            if (UtilValidate.isNotEmpty(fromDate)) {
+                                conds.add(EntityCondition.makeCondition("createdStamp", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
+                            }
+                            values = delegator.find(curEntityName, EntityCondition.makeCondition(conds), null, null, me.getPkFieldNames(), null);
                         } catch (Exception entityEx) {
                             results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + entityEx);
                             continue;