svn commit: r903567 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java

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

svn commit: r903567 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java

jonesde
Author: jonesde
Date: Wed Jan 27 08:48:55 2010
New Revision: 903567

URL: http://svn.apache.org/viewvc?rev=903567&view=rev
Log:
Change based on recent dev list discussion so that break-on-error acts more like an ignore error type of thing; when combined with require-new-transaction=true this will effectively result in no issues from the called service bubbling up to the calling service; with this change manually clearing out the error message and response code is no longer necessary

Modified:
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java?rev=903567&r1=903566&r2=903567&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java Wed Jan 27 08:48:55 2010
@@ -247,16 +247,20 @@
                 result = methodContext.getDispatcher().runSync(serviceName, inMap, timeout, requireNewTransaction);
             }
         } catch (GenericServiceException e) {
-            Debug.logError(e, module);
             String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem invoking the [" + serviceName + "] service with the map named [" + inMapAcsr + "] containing [" + inMap + "]: " + e.getMessage() + "]";
-            if (methodContext.getMethodType() == MethodContext.EVENT) {
-                methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getEventResponseCodeName(), errorCode);
-            } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
-                methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), errorCode);
+            Debug.logError(e, errMsg, module);
+            if (breakOnError) {
+                if (methodContext.getMethodType() == MethodContext.EVENT) {
+                    methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg);
+                    methodContext.putEnv(simpleMethod.getEventResponseCodeName(), errorCode);
+                } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
+                    methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg);
+                    methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), errorCode);
+                }
+                return false;
+            } else {
+                return true;
             }
-            return false;
         }
 
         if (resultsToMap.size() > 0) {
@@ -318,7 +322,7 @@
         String messageSuffixStr = messageSuffix.getMessage(methodContext.getLoader(), methodContext);
 
         String errorMessage = ServiceUtil.makeErrorMessage(result, messagePrefixStr, messageSuffixStr, errorPrefixStr, errorSuffixStr);
-        if (UtilValidate.isNotEmpty(errorMessage)) {
+        if (UtilValidate.isNotEmpty(errorMessage) && breakOnError) {
             errorMessage += UtilProperties.getMessage(resource, "simpleMethod.error_show_service_name", UtilMisc.toMap("serviceName", serviceName, "methodName", simpleMethod.getMethodName()), locale);
             if (methodContext.getMethodType() == MethodContext.EVENT) {
                 methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errorMessage);
@@ -350,15 +354,25 @@
 
         // handle the result
         String responseCode = result.containsKey(ModelService.RESPONSE_MESSAGE) ? (String) result.get(ModelService.RESPONSE_MESSAGE) : successCode;
-        if (methodContext.getMethodType() == MethodContext.EVENT) {
-            methodContext.putEnv(simpleMethod.getEventResponseCodeName(), responseCode);
-        } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
-            methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), responseCode);
-        }
 
-        if (errorCode.equals(responseCode) && breakOnError) {
-            return false;
+        if (errorCode.equals(responseCode)) {
+            if (breakOnError) {
+                if (methodContext.getMethodType() == MethodContext.EVENT) {
+                    methodContext.putEnv(simpleMethod.getEventResponseCodeName(), responseCode);
+                } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
+                    methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), responseCode);
+                }
+                return false;
+            } else {
+                // avoid responseCode here since we are ignoring the error
+                return true;
+            }
         } else {
+            if (methodContext.getMethodType() == MethodContext.EVENT) {
+                methodContext.putEnv(simpleMethod.getEventResponseCodeName(), responseCode);
+            } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
+                methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), responseCode);
+            }
             return true;
         }
     }