svn commit: r1801208 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

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

svn commit: r1801208 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

mbrohl
Author: mbrohl
Date: Fri Jul  7 20:14:20 2017
New Revision: 1801208

URL: http://svn.apache.org/viewvc?rev=1801208&view=rev
Log:
Improved: Checking service results errors using ServiceUtil.isError instead of
null checking the error message.

I think this class needs further refactoring, I only checked the code modified
the last changes from OFBIZ-9451.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java?rev=1801208&r1=1801207&r2=1801208&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java Fri Jul  7 20:14:20 2017
@@ -1238,15 +1238,13 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToCreateReturnHeader", locale));
             }
 
-            String errorMessage = ServiceUtil.getErrorMessage(returnHeaderResp);
-            if (errorMessage != null) {
-                return ServiceUtil.returnError(errorMessage);
+            if (ServiceUtil.isError(returnHeaderResp)) {
+                return ServiceUtil.returnError(ServiceUtil.getErrorMessage(returnHeaderResp));
             }
             
             String returnId = (String) returnHeaderResp.get("returnId");
-
             
-            if (returnId == null) {
+            if (UtilValidate.isEmpty(returnId)) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
                         "OrderErrorCreateReturnHeaderWithoutId", locale));
             }
@@ -1272,9 +1270,8 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToCreateReturnItem", locale));
             }
 
-            errorMessage = ServiceUtil.getErrorMessage(returnItemResp);
-            if (errorMessage != null) {
-                return ServiceUtil.returnError(errorMessage);
+            if (ServiceUtil.isError(returnItemResp)) {
+                return ServiceUtil.returnError(ServiceUtil.getErrorMessage(returnItemResp));
             }
 
             String returnItemSeqId = (String) returnItemResp.get("returnItemSeqId");
@@ -1311,9 +1308,8 @@ public class GiftCertificateServices {
                         "OrderErrorUnableToUpdateReturnHeaderStatus", locale));
             }
 
-            errorMessage = ServiceUtil.getErrorMessage(updateReturnResp);
-            if (errorMessage != null) {
-                return ServiceUtil.returnError(errorMessage);
+            if (ServiceUtil.isError(updateReturnResp)) {
+                return ServiceUtil.returnError(ServiceUtil.getErrorMessage(updateReturnResp));
             }
         }