svn commit: r1818552 - in /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware: PcChargeApi.java PcChargeServices.java RitaApi.java RitaServices.java

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

svn commit: r1818552 - in /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware: PcChargeApi.java PcChargeServices.java RitaApi.java RitaServices.java

mbrohl
Author: mbrohl
Date: Mon Dec 18 11:12:10 2017
New Revision: 1818552

URL: http://svn.apache.org/viewvc?rev=1818552&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.accounting.thirdparty.gosoftware.
(OFBIZ-9882)

Thanks Julian Leichert for reporting and providing the patches.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java?rev=1818552&r1=1818551&r2=1818552&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeApi.java Mon Dec 18 11:12:10 2017
@@ -33,7 +33,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-
 public class PcChargeApi {
 
     public static final String module = PcChargeApi.class.getName();
@@ -139,10 +138,7 @@ public class PcChargeApi {
         String objString = null;
         try {
             objString = (String) ObjectType.simpleTypeConvert(value, "java.lang.String", null, null);
-        } catch (GeneralException e) {
-            Debug.logError(e, module);
-            throw new IllegalArgumentException("Unable to convert value to String");
-        } catch (ClassCastException e) {
+        } catch (GeneralException | ClassCastException e) {
             Debug.logError(e, module);
             throw new IllegalArgumentException("Unable to convert value to String");
         }
@@ -188,7 +184,7 @@ public class PcChargeApi {
             try (Socket sock = new Socket(host, port);
                     PrintStream ps = new PrintStream(sock.getOutputStream(), false, "UTF-8");
                     DataInputStream dis = new DataInputStream(sock.getInputStream())) {
-            
+
                 ps.print(this.toString());
                 ps.flush();
 
@@ -200,23 +196,20 @@ public class PcChargeApi {
                 Document outDoc = null;
                 try {
                     outDoc = UtilXml.readXmlDocument(buf.toString(), false);
-                } catch (ParserConfigurationException e) {
-                    throw new GeneralException(e);
-                } catch (SAXException e) {
+                } catch (ParserConfigurationException | SAXException e) {
                     throw new GeneralException(e);
                 }
                 PcChargeApi out = new PcChargeApi(outDoc);
                 return out;
             }
-        } else {
-            throw new IllegalStateException("Cannot send output object");
         }
-        
+        throw new IllegalStateException("Cannot send output object");
+
     }
 
     private boolean checkIn(String name) {
-        for (int i = 0; i < validOut.length; i++) {
-            if (name.equals(validOut[i])) {
+        for (String element : validOut) {
+            if (name.equals(element)) {
                 return false;
             }
         }
@@ -224,8 +217,8 @@ public class PcChargeApi {
     }
 
     private boolean checkOut(String name) {
-        for (int i = 0; i < validIn.length; i++) {
-            if (name.equals(validIn[i])) {
+        for (String element : validIn) {
+            if (name.equals(element)) {
                 return false;
             }
         }

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java?rev=1818552&r1=1818551&r2=1818552&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java Mon Dec 18 11:12:10 2017
@@ -39,7 +39,6 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.service.DispatchContext;
 import org.apache.ofbiz.service.ServiceUtil;
 
-
 public class PcChargeServices {
 
     public static final String module = PcChargeServices.class.getName();
@@ -54,7 +53,7 @@ public class PcChargeServices {
         Properties props = buildPccProperties(context, delegator);
         PcChargeApi api = getApi(props);
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPcChargeErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -83,10 +82,7 @@ public class PcChargeServices {
         PcChargeApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (IOException | GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -137,7 +133,7 @@ public class PcChargeServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Locale locale = (Locale) context.get("locale");
         Delegator delegator = dctx.getDelegator();
-        //lets see if there is a auth transaction already in context
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
 
         if (authTransaction == null) {
@@ -145,7 +141,7 @@ public class PcChargeServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
         }
 
@@ -153,7 +149,7 @@ public class PcChargeServices {
         Properties props = buildPccProperties(context, delegator);
         PcChargeApi api = getApi(props);
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPcChargeErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -164,10 +160,7 @@ public class PcChargeServices {
         PcChargeApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (IOException | GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -191,7 +184,7 @@ public class PcChargeServices {
     public static Map<String, Object> ccRelease(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Delegator delegator = dctx.getDelegator();
-        //lets see if there is a auth transaction already in context
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
         Locale locale = (Locale) context.get("locale");
 
@@ -200,7 +193,7 @@ public class PcChargeServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
@@ -208,7 +201,7 @@ public class PcChargeServices {
         Properties props = buildPccProperties(context, delegator);
         PcChargeApi api = getApi(props);
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPcChargeErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -217,7 +210,7 @@ public class PcChargeServices {
 
         // check to make sure we are configured for SALE mode
         if (!"true".equalsIgnoreCase(props.getProperty("autoBill"))) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPcChargeCannotSupportReleasingPreAuth", locale));
         }
 
@@ -225,10 +218,7 @@ public class PcChargeServices {
         PcChargeApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (IOException | GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -252,7 +242,7 @@ public class PcChargeServices {
     public static Map<String, Object> ccRefund(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Delegator delegator = dctx.getDelegator();
-        //lets see if there is a auth transaction already in context
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
         Locale locale = (Locale) context.get("locale");
 
@@ -261,7 +251,7 @@ public class PcChargeServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
 
@@ -269,7 +259,7 @@ public class PcChargeServices {
         Properties props = buildPccProperties(context, delegator);
         PcChargeApi api = getApi(props);
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPcChargeErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -280,10 +270,7 @@ public class PcChargeServices {
         PcChargeApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (IOException | GeneralException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -371,7 +358,7 @@ public class PcChargeServices {
         int port = 0;
         try {
             port = Integer.parseInt(props.getProperty("port"));
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             Debug.logError(e, module);
         }
         PcChargeApi api = null;

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java?rev=1818552&r1=1818551&r2=1818552&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java Mon Dec 18 11:12:10 2017
@@ -28,7 +28,6 @@ import org.apache.ofbiz.base.util.HttpCl
 import org.apache.ofbiz.base.util.HttpClientException;
 import org.apache.ofbiz.base.util.ObjectType;
 
-
 public class RitaApi {
 
     public static final String module = RitaApi.class.getName();
@@ -78,13 +77,13 @@ public class RitaApi {
 
     // IN/OUT validation array
     private static final String[] validOut = { TERMINATION_STATUS, INTRN_SEQ_NUM, RESULT, RESULT_CODE, RESPONSE_TEXT,
-                                                 AUTH_CODE, AVS_CODE, CVV2_CODE, REFERENCE, TRANS_DATE, TRANS_TIME,
-                                                 ORIG_TRANS_AMOUNT };
+            AUTH_CODE, AVS_CODE, CVV2_CODE, REFERENCE, TRANS_DATE, TRANS_TIME,
+            ORIG_TRANS_AMOUNT };
 
     private static final String[] validIn = { FUNCTION_TYPE, PAYMENT_TYPE, USER_ID, USER_PW, COMMAND, CLIENT_ID,
-                                                ACCT_NUM, EXP_MONTH, EXP_YEAR, TRANS_AMOUNT, CARDHOLDER, TRACK_DATA,
-                                                INVOICE, PRESENT_FLAG, CUSTOMER_STREET, CUSTOMER_ZIP, CVV2, TAX_AMOUNT,
-                                                PURCHASE_ID, FORCE_FLAG, ORIG_TRANS_AMOUNT, ORIG_SEQ_NUM };
+            ACCT_NUM, EXP_MONTH, EXP_YEAR, TRANS_AMOUNT, CARDHOLDER, TRACK_DATA,
+            INVOICE, PRESENT_FLAG, CUSTOMER_STREET, CUSTOMER_ZIP, CVV2, TAX_AMOUNT,
+            PURCHASE_ID, FORCE_FLAG, ORIG_TRANS_AMOUNT, ORIG_SEQ_NUM };
 
     // mode definition
     protected static final int MODE_OUT = 20;
@@ -98,13 +97,13 @@ public class RitaApi {
     protected int mode = 0;
 
     public RitaApi(Map<String, String> document) {
-        this.document = new HashMap<String, String>();
+        this.document = new HashMap<>();
         this.document.putAll(document);
         this.mode = MODE_OUT;
     }
 
     public RitaApi() {
-        this.document = new HashMap<String, String>();
+        this.document = new HashMap<>();
         this.mode = MODE_IN;
     }
 
@@ -123,10 +122,7 @@ public class RitaApi {
         String objString = null;
         try {
             objString = (String) ObjectType.simpleTypeConvert(value, "java.lang.String", null, null);
-        } catch (GeneralException e) {
-            Debug.logError(e, module);
-            throw new IllegalArgumentException("Unable to convert value to String");
-        } catch (ClassCastException e) {
+        } catch (GeneralException | ClassCastException e) {
             Debug.logError(e, module);
             throw new IllegalArgumentException("Unable to convert value to String");
         }
@@ -179,7 +175,7 @@ public class RitaApi {
             HttpClient http = new HttpClient(urlString);
             http.setDebug(true);
 
-            Map<String, String> docMap = new HashMap<String, String>();
+            Map<String, String> docMap = new HashMap<>();
             String resp = null;
             try {
                 resp = http.post(stream);
@@ -204,14 +200,13 @@ public class RitaApi {
             }
             RitaApi out = new RitaApi(docMap);
             return out;
-        } else {
-            throw new IllegalStateException("Cannot send output object");
         }
+        throw new IllegalStateException("Cannot send output object");
     }
 
     private boolean checkIn(String name) {
-        for (int i = 0; i < validOut.length; i++) {
-            if (name.equals(validOut[i])) {
+        for (String element : validOut) {
+            if (name.equals(element)) {
                 return false;
             }
         }
@@ -219,8 +214,8 @@ public class RitaApi {
     }
 
     private boolean checkOut(String name) {
-        for (int i = 0; i < validIn.length; i++) {
-            if (name.equals(validIn[i])) {
+        for (String element : validIn) {
+            if (name.equals(element)) {
                 return false;
             }
         }

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java?rev=1818552&r1=1818551&r2=1818552&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java Mon Dec 18 11:12:10 2017
@@ -44,7 +44,6 @@ import org.apache.ofbiz.service.GenericS
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ServiceUtil;
 
-
 public class RitaServices {
 
     public static final String module = RitaServices.class.getName();
@@ -59,7 +58,7 @@ public class RitaServices {
         Properties props = buildPccProperties(context, delegator);
         RitaApi api = getApi(props, "CREDIT");
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingRitaErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -87,10 +86,7 @@ public class RitaServices {
         try {
             Debug.logInfo("Sending request to RiTA", module);
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (GeneralException | IOException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -139,8 +135,8 @@ public class RitaServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Locale locale = (Locale) context.get("locale");
         Delegator delegator = dctx.getDelegator();
-        
-        //lets see if there is a auth transaction already in context
+
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
 
         if (authTransaction == null) {
@@ -148,7 +144,7 @@ public class RitaServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
         }
 
@@ -156,7 +152,7 @@ public class RitaServices {
         Properties props = buildPccProperties(context, delegator);
         RitaApi api = getApi(props, "CREDIT");
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingRitaErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -167,10 +163,7 @@ public class RitaServices {
         RitaApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (GeneralException | IOException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -203,8 +196,8 @@ public class RitaServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Locale locale = (Locale) context.get("locale");
         Delegator delegator = dctx.getDelegator();
-        
-        //lets see if there is a auth transaction already in context
+
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
 
         if (authTransaction == null) {
@@ -212,7 +205,7 @@ public class RitaServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
@@ -220,7 +213,7 @@ public class RitaServices {
         Properties props = buildPccProperties(context, delegator);
         RitaApi api = getApi(props, "CREDIT");
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingRitaErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -230,7 +223,7 @@ public class RitaServices {
 
         // check to make sure we are configured for SALE mode
         if (!"1".equals(props.getProperty("autoBill"))) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingRitaCannotSupportReleasingPreAuth", locale));
         }
 
@@ -238,10 +231,7 @@ public class RitaServices {
         RitaApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (GeneralException | IOException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -268,8 +258,8 @@ public class RitaServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         Locale locale = (Locale) context.get("locale");
         Delegator delegator = dctx.getDelegator();
-        
-        //lets see if there is a auth transaction already in context
+
+        // lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
 
         if (authTransaction == null) {
@@ -277,7 +267,7 @@ public class RitaServices {
         }
 
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
 
@@ -285,7 +275,7 @@ public class RitaServices {
         Properties props = buildPccProperties(context, delegator);
         RitaApi api = getApi(props, "CREDIT");
         if (api == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingRitaErrorGettingPaymentGatewayConfig", locale));
         }
 
@@ -304,10 +294,7 @@ public class RitaServices {
         RitaApi out = null;
         try {
             out = api.send();
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(e.getMessage());
-        } catch (GeneralException e) {
+        } catch (GeneralException | IOException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
         }
@@ -338,7 +325,7 @@ public class RitaServices {
             orderHeader = orderPaymentPreference.getRelatedOne("OrderHeader", false);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
                     "OrderOrderNotFound", UtilMisc.toMap("orderId", orderPaymentPreference.getString("orderId")), locale));
         }
 
@@ -375,14 +362,13 @@ public class RitaServices {
                 }
             } catch (GenericServiceException e) {
                 Debug.logError(e, module);
-                return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
+                return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
                         "AccountingRitaErrorServiceException", locale));
             }
             return refundResp;
-        } else {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
-                    "OrderOrderNotFound", UtilMisc.toMap("orderId", orderPaymentPreference.getString("orderId")), locale));
         }
+        return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
+                "OrderOrderNotFound", UtilMisc.toMap("orderId", orderPaymentPreference.getString("orderId")), locale));
     }
 
     private static void setCreditCardInfo(RitaApi api, Delegator delegator, Map<String, ? extends Object> context) throws GeneralException {
@@ -462,7 +448,7 @@ public class RitaServices {
         int port = 0;
         try {
             port = Integer.parseInt(props.getProperty("port"));
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             Debug.logError(e, module);
         }
         boolean ssl = "Y".equals(props.getProperty("ssl", "N")) ? true : false;