svn commit: r591241 - in /ofbiz/trunk/framework/service: dtd/service-eca.xsd src/org/ofbiz/service/ModelService.java src/org/ofbiz/service/ServiceDispatcher.java src/org/ofbiz/service/eca/ServiceEcaAction.java

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

svn commit: r591241 - in /ofbiz/trunk/framework/service: dtd/service-eca.xsd src/org/ofbiz/service/ModelService.java src/org/ofbiz/service/ServiceDispatcher.java src/org/ofbiz/service/eca/ServiceEcaAction.java

jonesde
Author: jonesde
Date: Thu Nov  1 23:42:53 2007
New Revision: 591241

URL: http://svn.apache.org/viewvc?rev=591241&view=rev
Log:
Applied patch from Adrian Crum in Jira #OFBIZ-1245, fixes some inconsistencies in previous handling of failure and error messages, a handling of failure and error messages and cleanes up some things related to the recent result-to-result changes

Modified:
    ofbiz/trunk/framework/service/dtd/service-eca.xsd
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java

Modified: ofbiz/trunk/framework/service/dtd/service-eca.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/dtd/service-eca.xsd?rev=591241&r1=591240&r2=591241&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/dtd/service-eca.xsd (original)
+++ ofbiz/trunk/framework/service/dtd/service-eca.xsd Thu Nov  1 23:42:53 2007
@@ -230,7 +230,7 @@
             </xs:simpleType>
         </xs:attribute>
         <xs:attribute name="result-to-result" default="false">
-            <xs:annotation><xs:documentation>If true, and the action is successful, copies the action's result Map into the service's result Map.</xs:documentation></xs:annotation>
+            <xs:annotation><xs:documentation>If true, copies the action's result Map into the service's result Map.</xs:documentation></xs:annotation>
             <xs:simpleType>
                 <xs:restriction base="xs:token">
                     <xs:enumeration value="true"/>

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?rev=591241&r1=591240&r2=591241&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Thu Nov  1 23:42:53 2007
@@ -858,7 +858,11 @@
                 if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) {
                     Map<String, Object> result = ServiceUtil.returnSuccess();
                     result.put("hasPermission", Boolean.FALSE);
-                    result.put("failMessage", ServiceUtil.getErrorMessage(resp));
+                    String failMessage = (String) resp.get("failMessage");
+                    if (UtilValidate.isEmpty(failMessage)) {
+                        failMessage = ServiceUtil.getErrorMessage(resp);
+                    }
+                    result.put("failMessage", failMessage);
                     return result;
                 }
                 return resp;

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=591241&r1=591240&r2=591241&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Thu Nov  1 23:42:53 2007
@@ -888,6 +888,9 @@
             } else {
                 String message = (String) permResp.get("failMessage");
                 if (UtilValidate.isEmpty(message)) {
+                    message = ServiceUtil.getErrorMessage(permResp);
+                }
+                if (UtilValidate.isEmpty(message)) {
                     message = "You do not have permission to invoke the service [" + origService.name + "]";
                 }
                 throw new ServiceAuthException(message);

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java?rev=591241&r1=591240&r2=591241&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java Thu Nov  1 23:42:53 2007
@@ -139,6 +139,7 @@
          normalizedActionResult.remove(ModelService.ERROR_MESSAGE);
          normalizedActionResult.remove(ModelService.ERROR_MESSAGE_LIST);
          normalizedActionResult.remove(ModelService.ERROR_MESSAGE_MAP);
+            normalizedActionResult.remove("failMessage");
             result.putAll(normalizedActionResult);
         }
 
@@ -167,6 +168,7 @@
         // copy/combine error messages on error/failure (!success) or on resultToResult to combine any error info coming out, regardless of success status
         if (!success || resultToResult) {
             String errorMessage = (String) actionResult.get(ModelService.ERROR_MESSAGE);
+            String failMessage = (String) actionResult.get("failMessage");
             List<? extends Object> errorMessageList = UtilGenerics.checkList(actionResult.get(ModelService.ERROR_MESSAGE_LIST));
             Map<String, ? extends Object> errorMessageMap = UtilGenerics.checkMap(actionResult.get(ModelService.ERROR_MESSAGE_MAP));
 
@@ -199,6 +201,15 @@
                     result.put(ModelService.ERROR_MESSAGE_MAP, errorMessageMap);
                 } else {
                     origErrorMessageMap.putAll(errorMessageMap);
+                }
+            }
+            // do something with the fail message
+            if (UtilValidate.isNotEmpty(failMessage)) {
+                String origFailMessage = (String) result.get("failMessage");
+                if (UtilValidate.isEmpty(origFailMessage)) {
+                    result.put("failMessage", failMessage);
+                } else {
+                    result.put("failMessage", origFailMessage + ", " + failMessage);
                 }
             }
         }