svn commit: r1802798 - /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

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

svn commit: r1802798 - /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

nmalin
Author: nmalin
Date: Mon Jul 24 12:17:01 2017
New Revision: 1802798

URL: http://svn.apache.org/viewvc?rev=1802798&view=rev
Log:
Improved: Improve groovy DSL, runService call makeValidContext (OFBIZ-9523)
When you call run service with groovy, you need to be sure that all parametes are good for the service call.
This improvement simplify this dsl with an automatic parameters check so you can call directly like that
run service : createProduct, with: context

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy?rev=1802798&r1=1802797&r2=1802798&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy Mon Jul 24 12:17:01 2017
@@ -20,6 +20,9 @@ package org.apache.ofbiz.service.engine
 
 import org.apache.ofbiz.base.util.Debug
 import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.DispatchContext
+import org.apache.ofbiz.service.LocalDispatcher
+import org.apache.ofbiz.service.ModelService
 import org.apache.ofbiz.service.ServiceUtil
 import org.apache.ofbiz.service.ExecutionServiceException
 
@@ -27,6 +30,8 @@ abstract class GroovyBaseScript extends
     public static final String module = GroovyBaseScript.class.getName()
 
     Map runService(String serviceName, Map inputMap) throws ExecutionServiceException {
+        LocalDispatcher dispatcher = binding.getVariable('dispatcher');
+        DispatchContext dctx = dispatcher.getDispatchContext();
         if (!inputMap.userLogin) {
             inputMap.userLogin = this.binding.getVariable('parameters').userLogin
         }
@@ -36,7 +41,8 @@ abstract class GroovyBaseScript extends
         if (!inputMap.locale) {
             inputMap.locale = this.binding.getVariable('parameters').locale
         }
-        Map result = binding.getVariable('dispatcher').runSync(serviceName, inputMap)
+        Map serviceContext = dctx.makeValidContext(serviceName, ModelService.IN_PARAM, inputMap)
+        Map result = dispatcher.runSync(serviceName, serviceContext)
         if (ServiceUtil.isError(result)) {
             throw new ExecutionServiceException(ServiceUtil.getErrorMessage(result))
         }