svn commit: r1817455 - in /ofbiz/ofbiz-framework/trunk/framework: common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java

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

svn commit: r1817455 - in /ofbiz/ofbiz-framework/trunk/framework: common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java

jleroux@apache.org
Author: jleroux
Date: Fri Dec  8 05:04:23 2017
New Revision: 1817455

URL: http://svn.apache.org/viewvc?rev=1817455&view=rev
Log:
Implemented: Handle service response effectively
(OFBIZ-9981)
Included Debug.logError in ServiceUtil.returnProblem so that in case of any
error occurred and handled, it will always be logged on the console.
jleroux: I put a toString() there, Debug.logError() does not work with maps

Also no functional change (better code) in QRCodeEvents
jleroux: I also replaced tabs by spaces there
            and put debug info in exceptions

Thanks: Suraj Khurana

Modified:
    ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java

Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java?rev=1817455&r1=1817454&r2=1817455&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeEvents.java Fri Dec  8 05:04:23 2017
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.UtilHttp;
 import org.apache.ofbiz.base.util.UtilMisc;
 import org.apache.ofbiz.base.util.UtilProperties;
@@ -76,55 +77,55 @@ public class QRCodeEvents {
             OutputStream os = response.getOutputStream();
             Map<String, Object> context = UtilMisc.<String, Object>toMap("message", message, "format", format, "userLogin", userLogin, "locale", locale);
             if (UtilValidate.isNotEmpty(width)) {
-             try {
+                try {
                     context.put("width", Integer.parseInt(width));
-             } catch (NumberFormatException e) {
-             // do nothing
-             }
+                } catch (NumberFormatException e) {
+                    Debug.logWarning(e, e.getMessage(), module);
+                }
                 if (UtilValidate.isEmpty(height)) {
-                 try {
+                    try {
                         context.put("height", Integer.parseInt(width));
-                 } catch (NumberFormatException e) {
-                 // do nothing
-                 }
+                    } catch (NumberFormatException e) {
+                        Debug.logWarning(e, e.getMessage(), module);
+                    }
                 }
             }
             if (UtilValidate.isNotEmpty(height)) {
-             try {
+                try {
                     context.put("height", Integer.parseInt(height));
-             } catch (NumberFormatException e) {
-             // do nothing
-             }
+                } catch (NumberFormatException e) {
+                    Debug.logWarning(e, e.getMessage(), module);
+                }
                 if (UtilValidate.isEmpty(width)) {
-                 try {
+                    try {
                         context.put("width", Integer.parseInt(height));
-                 } catch (NumberFormatException e) {
-                 // do nothing
-                 }
+                    } catch (NumberFormatException e) {
+                        Debug.logWarning(e, e.getMessage(), module);
+                    }
                 }
             }
             if (UtilValidate.isNotEmpty(encoding)) {
                 context.put("encoding", encoding);
             }
             if (UtilValidate.isNotEmpty(verifyOutput) && verifyOutput.booleanValue()) {
-             context.put("verifyOutput", verifyOutput);
+                context.put("verifyOutput", verifyOutput);
             }
             if (UtilValidate.isNotEmpty(logoImageMaxWidth)) {
-             try {
+                try {
                     context.put("logoImageMaxWidth", Integer.parseInt(logoImageMaxWidth));
-             } catch (NumberFormatException e) {
-             // do nothing
-             }
+                } catch (NumberFormatException e) {
+                    Debug.logWarning(e, e.getMessage(), module);
+                }
             }
             if (UtilValidate.isNotEmpty(logoImageMaxHeight)) {
-             try {
+                try {
                     context.put("logoImageMaxHeight", Integer.parseInt(logoImageMaxHeight));
-             } catch (NumberFormatException e) {
-             // do nothing
-             }
+                } catch (NumberFormatException e) {
+                    Debug.logWarning(e, e.getMessage(), module);
+                }
             }
             Map<String, Object> results = dispatcher.runSync("generateQRCodeImage", context);
-            if (!ServiceUtil.isError(results)) {
+            if (ServiceUtil.isSuccess(results)) {
                 BufferedImage bufferedImage = (BufferedImage) results.get("bufferedImage");
                 if (!ImageIO.write(bufferedImage, format, os)) {
                     String errMsg = UtilProperties.getMessage("QRCodeUiLabels", "ErrorWriteFormatToFile", new Object[] { format }, locale);

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java?rev=1817455&r1=1817454&r2=1817455&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceUtil.java Fri Dec  8 05:04:23 2017
@@ -152,6 +152,7 @@ public final class ServiceUtil {
         if (errorMap.size() > 0) {
             result.put(ModelService.ERROR_MESSAGE_MAP, errorMap);
         }
+        Debug.logError(result.toString(), module);
         return result;
     }