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

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

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

mbrohl
Author: mbrohl
Date: Mon Dec 18 13:00:59 2017
New Revision: 1818564

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

Thanks Julian Leichert for reporting and providing the patches.

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

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java?rev=1818564&r1=1818563&r2=1818564&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java Mon Dec 18 13:00:59 2017
@@ -62,11 +62,13 @@ public class BillingAccountWorker {
         rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
 
         // set zero to the proper scale
-        if (decimals != -1) ZERO = ZERO.setScale(decimals);
+        if (decimals != -1) {
+            ZERO = ZERO.setScale(decimals);
+        }
     }
 
     public static List<Map<String, Object>> makePartyBillingAccountList(GenericValue userLogin, String currencyUomId, String partyId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException {
-        List<Map<String, Object>> billingAccountList = new LinkedList<Map<String,Object>>();
+        List<Map<String, Object>> billingAccountList = new LinkedList<>();
 
         Map<String, Object> agentResult = dispatcher.runSync("getRelatedParties", UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyIdFrom", partyId,
                 "roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyRelationshipTypeId", "AGENT", "includeFromToSwitched", "Y"));
@@ -87,12 +89,14 @@ public class BillingAccountWorker {
 
                 // skip accounts that have thruDate < nowTimestamp
                 java.sql.Timestamp thruDate = billingAccountVO.getTimestamp("thruDate");
-                if ((thruDate != null) && UtilDateTime.nowTimestamp().after(thruDate)) continue;
+                if ((thruDate != null) && UtilDateTime.nowTimestamp().after(thruDate)) {
+                    continue;
+                }
 
                 if (currencyUomId.equals(billingAccountVO.getString("accountCurrencyUomId"))) {
                     BigDecimal accountBalance = OrderReadHelper.getBillingAccountBalance(billingAccountVO);
 
-                    Map<String, Object> billingAccount = new HashMap<String, Object>(billingAccountVO);
+                    Map<String, Object> billingAccount = new HashMap<>(billingAccountVO);
                     BigDecimal accountLimit = OrderReadHelper.getAccountLimit(billingAccountVO);
 
                     billingAccount.put("accountBalance", accountBalance);
@@ -130,10 +134,9 @@ public class BillingAccountWorker {
             BigDecimal accountLimit = billingAccount.getBigDecimal("accountLimit");
             BigDecimal availableBalance = accountLimit.subtract(OrderReadHelper.getBillingAccountBalance(billingAccount)).setScale(decimals, rounding);
             return availableBalance;
-        } else {
-            Debug.logWarning("Available balance requested for null billing account, returning zero", module);
-            return ZERO;
         }
+        Debug.logWarning("Available balance requested for null billing account, returning zero", module);
+        return ZERO;
     }
 
     public static BigDecimal getBillingAccountAvailableBalance(Delegator delegator, String billingAccountId) throws GenericEntityException {
@@ -154,8 +157,7 @@ public class BillingAccountWorker {
 
         // search through all PaymentApplications and add the amount that was applied to invoice and subtract the amount applied from payments
         List<GenericValue> paymentAppls = EntityQuery.use(delegator).from("PaymentApplication").where("billingAccountId", billingAccountId).queryList();
-        for (Iterator<GenericValue> pAi = paymentAppls.iterator(); pAi.hasNext();) {
-            GenericValue paymentAppl = pAi.next();
+        for (GenericValue paymentAppl : paymentAppls) {
             BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied");
             GenericValue invoice = paymentAppl.getRelatedOne("Invoice", false);
             if (invoice != null) {

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=1818564&r1=1818563&r2=1818564&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 Mon Dec 18 13:00:59 2017
@@ -115,7 +115,7 @@ public class GiftCertificateServices {
                 }
                 
             } else {
-                Map<String, Object> createAccountCtx = new HashMap<String, Object>();
+                Map<String, Object> createAccountCtx = new HashMap<>();
                 createAccountCtx.put("ownerPartyId", partyId);
                 createAccountCtx.put("finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId);
                 createAccountCtx.put("productStoreId", productStoreId);
@@ -141,11 +141,7 @@ public class GiftCertificateServices {
             refNum = createTransaction(delegator, dispatcher, permUserLogin, initialAmount, productStoreId,
                     partyId, currencyUom, deposit, finAccountId, locale);
 
-        } catch (GenericEntityException e) {
-            Debug.logError(e, module);
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                    "AccountingGiftCerticateNumberCreationError", locale));
-        } catch (GenericServiceException e) {
+        } catch (GenericEntityException | GenericServiceException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                     "AccountingGiftCerticateNumberCreationError", locale));
@@ -418,7 +414,7 @@ public class GiftCertificateServices {
             // obtain the order information
             OrderReadHelper orh = new OrderReadHelper(delegator, orderPaymentPreference.getString("orderId"));
 
-            Map<String, Object> redeemCtx = new HashMap<String, Object>();
+            Map<String, Object> redeemCtx = new HashMap<>();
             redeemCtx.put("userLogin", userLogin);
             redeemCtx.put("productStoreId", orh.getProductStoreId());
             redeemCtx.put("cardNumber", giftCard.get("finAccountId"));
@@ -456,11 +452,7 @@ public class GiftCertificateServices {
 
             return result;
 
-        } catch (GenericEntityException ex) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                    "AccountingGiftCerticateNumberCannotProcess",
-                    UtilMisc.toMap("errorString", ex.getMessage()), locale));
-        } catch (GenericServiceException ex) {
+        } catch (GenericEntityException | GenericServiceException ex) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                     "AccountingGiftCerticateNumberCannotProcess",
                     UtilMisc.toMap("errorString", ex.getMessage()), locale));
@@ -568,12 +560,7 @@ public class GiftCertificateServices {
             result.put("authRefNum", refNum);
 
             return result;
-        } catch (GenericEntityException ex) {
-            Debug.logError(ex, "Cannot authorize gift certificate", module);
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                    "AccountingGiftCerticateNumberCannotAuthorize",
-                    UtilMisc.toMap("errorString", ex.getMessage()), locale));
-        } catch (GenericServiceException ex) {
+        } catch (GenericEntityException | GenericServiceException ex) {
             Debug.logError(ex, "Cannot authorize gift certificate", module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                     "AccountingGiftCerticateNumberCannotAuthorize",
@@ -661,7 +648,7 @@ public class GiftCertificateServices {
             currency = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator);
         }
 
-        Map<String, Object> refundCtx = new HashMap<String, Object>();
+        Map<String, Object> refundCtx = new HashMap<>();
         refundCtx.put("productStoreId", productStoreId);
         refundCtx.put("currency", currency);
         refundCtx.put("partyId", partyId);
@@ -806,7 +793,7 @@ public class GiftCertificateServices {
         }
 
         // make a map of answer info
-        Map<String, Object> answerMap = new HashMap<String, Object>();
+        Map<String, Object> answerMap = new HashMap<>();
         if (responseAnswers != null) {
             for (GenericValue answer : responseAnswers) {
                 GenericValue question = null;
@@ -839,7 +826,7 @@ public class GiftCertificateServices {
         int qtyLoop = quantity.intValue();
         for (int i = 0; i < qtyLoop; i++) {
             // create a gift certificate
-            Map<String, Object> createGcCtx = new HashMap<String, Object>();
+            Map<String, Object> createGcCtx = new HashMap<>();
             createGcCtx.put("productStoreId", productStoreId);
             createGcCtx.put("currency", currency);
             createGcCtx.put("partyId", partyId);
@@ -861,7 +848,7 @@ public class GiftCertificateServices {
             }
 
             // create the fulfillment record
-            Map<String, Object> gcFulFill = new HashMap<String, Object>();
+            Map<String, Object> gcFulFill = new HashMap<>();
             gcFulFill.put("typeEnumId", "GC_ACTIVATE");
             gcFulFill.put("partyId", partyId);
             gcFulFill.put("orderId", orderId);
@@ -909,7 +896,7 @@ public class GiftCertificateServices {
                         bcc = orderEmails;
                     }
                 }
-                Map<String, Object> emailCtx = new HashMap<String, Object>();
+                Map<String, Object> emailCtx = new HashMap<>();
                 String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
                 if (UtilValidate.isEmpty(bodyScreenLocation)) {
                     bodyScreenLocation = ProductStoreWorker.getDefaultProductStoreEmailScreenLocation(emailType);
@@ -1035,7 +1022,7 @@ public class GiftCertificateServices {
         }
 
         // make a map of answer info
-        Map<String, Object> answerMap = new HashMap<String, Object>();
+        Map<String, Object> answerMap = new HashMap<>();
         if (responseAnswers != null) {
             for (GenericValue answer : responseAnswers) {
                 GenericValue question = null;
@@ -1060,7 +1047,7 @@ public class GiftCertificateServices {
         String pinNumber = (String) answerMap.get(pinNumberKey);
 
         // reload the gift card
-        Map<String, Object> reloadCtx = new HashMap<String, Object>();
+        Map<String, Object> reloadCtx = new HashMap<>();
         reloadCtx.put("productStoreId", productStoreId);
         reloadCtx.put("currency", currency);
         reloadCtx.put("partyId", partyId);
@@ -1082,7 +1069,7 @@ public class GiftCertificateServices {
         }
 
         // create the fulfillment record
-        Map<String, Object> gcFulFill = new HashMap<String, Object>();
+        Map<String, Object> gcFulFill = new HashMap<>();
         gcFulFill.put("typeEnumId", "GC_RELOAD");
         gcFulFill.put("userLogin", userLogin);
         gcFulFill.put("partyId", partyId);
@@ -1140,7 +1127,7 @@ public class GiftCertificateServices {
         } else {
             answerMap.put("locale", locale);
 
-            Map<String, Object> emailCtx = new HashMap<String, Object>();
+            Map<String, Object> emailCtx = new HashMap<>();
             String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
             if (UtilValidate.isEmpty(bodyScreenLocation)) {
                 bodyScreenLocation = ProductStoreWorker.getDefaultProductStoreEmailScreenLocation(emailType);
@@ -1237,7 +1224,7 @@ public class GiftCertificateServices {
             Debug.logInfo("Returnable INFO : " + returnableQuantity + " @ " + returnablePrice + " :: " + orderItem, module);
 
             // create the return header
-            Map<String, Object> returnHeaderInfo = new HashMap<String, Object>();
+            Map<String, Object> returnHeaderInfo = new HashMap<>();
             returnHeaderInfo.put("fromPartyId", partyId);
             returnHeaderInfo.put("userLogin", userLogin);
             Map<String, Object> returnHeaderResp = null;
@@ -1261,7 +1248,7 @@ public class GiftCertificateServices {
             }
 
             // create the return item
-            Map<String, Object> returnItemInfo = new HashMap<String, Object>();
+            Map<String, Object> returnItemInfo = new HashMap<>();
             returnItemInfo.put("returnId", returnId);
             returnItemInfo.put("returnReasonId", "RTN_DIG_FILL_FAIL");
             returnItemInfo.put("returnTypeId", "RTN_REFUND");
@@ -1290,8 +1277,9 @@ public class GiftCertificateServices {
             if (returnItemSeqId == null) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
                         "OrderErrorCreateReturnItemWithoutId", locale));
-            } else {
-                if (Debug.verboseOn()) Debug.logVerbose("Created return item : " + returnId + " / " + returnItemSeqId, module);
+            }
+            if (Debug.verboseOn()) {
+                Debug.logVerbose("Created return item : " + returnId + " / " + returnItemSeqId, module);
             }
 
             // need the system userLogin to "fake" out the update service
@@ -1305,7 +1293,7 @@ public class GiftCertificateServices {
             }
 
             // update the status to received so it can process
-            Map<String, Object> updateReturnInfo = new HashMap<String, Object>();
+            Map<String, Object> updateReturnInfo = new HashMap<>();
             updateReturnInfo.put("returnId", returnId);
             updateReturnInfo.put("statusId", "RETURN_RECEIVED");
             updateReturnInfo.put("currentStatusId", "RETURN_REQUESTED");
@@ -1337,11 +1325,14 @@ public class GiftCertificateServices {
         }
         if (finAccount != null) {
             String dbPin = finAccount.getString("finAccountCode");
-            Debug.logInfo("GC Pin Validation: [Sent: " + pinNumber + "] [Actual: " + dbPin + "]", module);
+            if (Debug.infoOn()) {
+                Debug.logInfo("GC Pin Validation: [Sent: " + pinNumber + "] [Actual: " + dbPin + "]", module);
+            }
             if (dbPin != null && dbPin.equals(pinNumber)) {
                 return true;
             }
-        } else {
+        }
+        if (Debug.infoOn()) {
             Debug.logInfo("GC FinAccount record not found (" + cardNumber + ")", module);
         }
         return false;
@@ -1396,9 +1387,9 @@ public class GiftCertificateServices {
         }
         if (ServiceUtil.isError(payResult)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(payResult));
-        } else {
-            paymentId = (String) payResult.get("paymentId");
-        }
+        }
+
+        paymentId = (String) payResult.get("paymentId");
 
         // create the initial transaction
         Map<String, Object> transCtx = UtilMisc.<String, Object>toMap("finAccountTransTypeId", txType);

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=1818564&r1=1818563&r2=1818564&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java Mon Dec 18 13:00:59 2017
@@ -93,7 +93,9 @@ public class PaymentGatewayServices {
         rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
 
         // set zero to the proper scale
-        if (decimals != -1) ZERO = ZERO.setScale(decimals);
+        if (decimals != -1) {
+            ZERO = ZERO.setScale(decimals);
+        }
     }
 
     /**
@@ -321,7 +323,7 @@ public class PaymentGatewayServices {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         String orderId = (String) context.get("orderId");
         Locale locale = (Locale) context.get("locale");
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         boolean reAuth = false;
         if (context.get("reAuth") != null) {
             reAuth = ((Boolean)context.get("reAuth")).booleanValue();
@@ -363,7 +365,7 @@ public class PaymentGatewayServices {
         // loop through and auth each order payment preference
         int finished = 0;
         int hadError = 0;
-        List<String> messages = new LinkedList<String>();
+        List<String> messages = new LinkedList<>();
         for (GenericValue paymentPref : paymentPrefs) {
             if (reAuth && "PAYMENT_AUTHORIZED".equals(paymentPref.getString("statusId"))) {
                 String paymentConfig = null;
@@ -381,7 +383,7 @@ public class PaymentGatewayServices {
                     continue;
                 }
             }
-            Map<String, Object> authContext = new HashMap<String, Object>();
+            Map<String, Object> authContext = new HashMap<>();
             authContext.put("orderPaymentPreferenceId", paymentPref.getString("orderPaymentPreferenceId"));
             authContext.put("userLogin", context.get("userLogin"));
 
@@ -477,7 +479,7 @@ public class PaymentGatewayServices {
         }
 
         // make the process context
-        Map<String, Object> processContext = new HashMap<String, Object>();
+        Map<String, Object> processContext = new HashMap<>();
 
         // get the visit record to obtain the client's IP address
         GenericValue orderHeader = orh.getOrderHeader();
@@ -533,7 +535,9 @@ public class PaymentGatewayServices {
         // format the decimal
         processAmount = processAmount.setScale(decimals, rounding);
 
-        if (Debug.verboseOn()) Debug.logVerbose("Charging amount: " + processAmount, module);
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Charging amount: " + processAmount, module);
+        }
         processContext.put("processAmount", processAmount);
 
         // invoke the processor
@@ -771,7 +775,7 @@ public class PaymentGatewayServices {
         }
 
         // iterate over the prefs and release each one
-        List<GenericValue> finished = new LinkedList<GenericValue>();
+        List<GenericValue> finished = new LinkedList<>();
         for (GenericValue pPref : paymentPrefs) {
             Map<String, Object> releaseContext = UtilMisc.toMap("userLogin", userLogin, "orderPaymentPreferenceId", pPref.getString("orderPaymentPreferenceId"));
             Map<String, Object> releaseResult = null;
@@ -828,7 +832,7 @@ public class PaymentGatewayServices {
         pgCredit.set("transactionDate", UtilDateTime.nowTimestamp());
         pgCredit.set("currencyUomId", currencyUomId);
         // create the internal messages
-        List<GenericValue> messageEntities = new LinkedList<GenericValue>();
+        List<GenericValue> messageEntities = new LinkedList<>();
         List<String> messages = UtilGenerics.cast(context.get("internalRespMsgs"));
         if (UtilValidate.isNotEmpty(messages)) {
             for (String message : messages) {
@@ -963,7 +967,7 @@ public class PaymentGatewayServices {
             paymentConfig = "payment.properties";
         }
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(paymentPref);
-        Map<String, Object> releaseContext = new HashMap<String, Object>();
+        Map<String, Object> releaseContext = new HashMap<>();
         releaseContext.put("orderPaymentPreference", paymentPref);
         releaseContext.put("releaseAmount", authTransaction.getBigDecimal("amount"));
         releaseContext.put("currency", currency);
@@ -1154,7 +1158,9 @@ public class PaymentGatewayServices {
 
         // get the invoice amount (amount to bill)
         BigDecimal invoiceTotal = InvoiceWorker.getInvoiceNotApplied(invoice);
-        if (Debug.infoOn()) Debug.logInfo("(Capture) Invoice [#" + invoiceId + "] total: " + invoiceTotal, module);
+        if (Debug.infoOn()) {
+            Debug.logInfo("(Capture) Invoice [#" + invoiceId + "] total: " + invoiceTotal, module);
+        }
 
         // now capture the order
         Map<String, Object> serviceContext = UtilMisc.toMap("userLogin", userLogin, "orderId", testOrderId, "invoiceId", invoiceId, "captureAmount", invoiceTotal);
@@ -1241,7 +1247,9 @@ public class PaymentGatewayServices {
                 GenericValue paymentPref = paymentsBa.next();
 
                 BigDecimal authAmount = paymentPref.getBigDecimal("maxAmount");
-                if (authAmount == null) authAmount = ZERO;
+                if (authAmount == null) {
+                    authAmount = ZERO;
+                }
                 authAmount = authAmount.setScale(decimals, rounding);
 
                 if (authAmount.compareTo(ZERO) == 0) {
@@ -1274,7 +1282,9 @@ public class PaymentGatewayServices {
                     if (captureResult != null) {
 
                         BigDecimal amountCaptured = (BigDecimal) captureResult.get("captureAmount");
-                        if (Debug.infoOn()) Debug.logInfo("Amount captured for order [" + orderId + "] from unapplied payments associated to billing account [" + billingAccountId + "] is: " + amountCaptured, module);
+                        if (Debug.infoOn()) {
+                            Debug.logInfo("Amount captured for order [" + orderId + "] from unapplied payments associated to billing account [" + billingAccountId + "] is: " + amountCaptured, module);
+                        }
 
                         amountCaptured = amountCaptured.setScale(decimals, rounding);
 
@@ -1310,7 +1320,9 @@ public class PaymentGatewayServices {
                             } catch (GenericServiceException e) {
                                 Debug.logWarning(e, "Problem processing the capture split payment", module);
                             }
-                            if (Debug.infoOn()) Debug.logInfo("Captured: " + amountThisCapture + " Remaining (re-auth): " + splitAmount, module);
+                            if (Debug.infoOn()) {
+                                Debug.logInfo("Captured: " + amountThisCapture + " Remaining (re-auth): " + splitAmount, module);
+                            }
                         }
                     } else {
                         Debug.logError("Payment not captured for order [" + orderId + "] from billing account [" + billingAccountId + "]", module);
@@ -1339,7 +1351,9 @@ public class PaymentGatewayServices {
                 }
 
                 BigDecimal authAmount = authTrans.getBigDecimal("amount");
-                if (authAmount == null) authAmount = ZERO;
+                if (authAmount == null) {
+                    authAmount = ZERO;
+                }
                 authAmount = authAmount.setScale(decimals, rounding);
 
                 if (authAmount.compareTo(ZERO) == 0) {
@@ -1406,7 +1420,9 @@ public class PaymentGatewayServices {
                         } catch (GenericServiceException e) {
                             Debug.logWarning(e, "Problem processing the capture split payment", module);
                         }
-                        if (Debug.infoOn()) Debug.logInfo("Captured: " + amountThisCapture + " Remaining (re-auth): " + splitAmount, module);
+                        if (Debug.infoOn()) {
+                            Debug.logInfo("Captured: " + amountThisCapture + " Remaining (re-auth): " + splitAmount, module);
+                        }
                     }
                 } else {
                     Debug.logError("Payment not captured", module);
@@ -1465,7 +1481,9 @@ public class PaymentGatewayServices {
         if (userLogin != null) {
             newPref.set("createdByUserLogin", userLogin.getString("userLoginId"));
         }
-        if (Debug.verboseOn()) Debug.logVerbose("New preference : " + newPref, module);
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("New preference : " + newPref, module);
+        }
 
         Map<String, Object> processorResult = null;
         try {
@@ -1587,9 +1605,7 @@ public class PaymentGatewayServices {
                     }
                 }
             }
-        } catch (GenericEntityException ex) {
-            return ServiceUtil.returnError(ex.getMessage());
-        } catch (GenericServiceException ex) {
+        } catch (GenericEntityException | GenericServiceException ex) {
             return ServiceUtil.returnError(ex.getMessage());
         }
 
@@ -1729,7 +1745,7 @@ public class PaymentGatewayServices {
         }
 
         // prepare the context for the capture service (must follow the ccCaptureInterface
-        Map<String, Object> captureContext = new HashMap<String, Object>();
+        Map<String, Object> captureContext = new HashMap<>();
         captureContext.put("userLogin", userLogin);
         captureContext.put("orderPaymentPreference", paymentPref);
         captureContext.put("paymentConfig", paymentConfig);
@@ -1760,7 +1776,9 @@ public class PaymentGatewayServices {
             captureContext.put("authTrans", authTrans);
         }
 
-        if (Debug.infoOn()) Debug.logInfo("Capture [" + serviceName + "] : " + captureContext, module);
+        if (Debug.infoOn()) {
+            Debug.logInfo("Capture [" + serviceName + "] : " + captureContext, module);
+        }
         try {
             String paymentMethodTypeId = paymentPref.getString("paymentMethodTypeId");
             if (paymentMethodTypeId != null && "GIFT_CARD".equals(paymentMethodTypeId)) {
@@ -1806,7 +1824,7 @@ public class PaymentGatewayServices {
     }
 
     private static void saveError(LocalDispatcher dispatcher, GenericValue userLogin, GenericValue paymentPref, Map<String, Object> result, String serviceType, String transactionCode) {
-        Map<String, Object> serviceContext = new HashMap<String, Object>();
+        Map<String, Object> serviceContext = new HashMap<>();
         serviceContext.put("paymentServiceTypeEnumId", serviceType);
         serviceContext.put("orderPaymentPreference", paymentPref);
         serviceContext.put("transCodeEnumId", transactionCode);
@@ -1870,8 +1888,9 @@ public class PaymentGatewayServices {
         }
         if (captureResult != null) {
             processCaptureResult(dctx, result, userLogin, paymentPreference, authServiceType, locale);
-            if (!resultPassed)
+            if (!resultPassed) {
                 resultPassed = captureResult.booleanValue();
+            }
         }
         return resultPassed;
     }
@@ -1961,13 +1980,21 @@ public class PaymentGatewayServices {
             response.set("gatewayMessage", context.get("authMessage"));
             response.set("transactionDate", UtilDateTime.nowTimestamp());
 
-            if (Boolean.TRUE.equals(context.get("resultDeclined"))) response.set("resultDeclined", "Y");
-            if (Boolean.TRUE.equals(context.get("resultNsf"))) response.set("resultNsf", "Y");
-            if (Boolean.TRUE.equals(context.get("resultBadExpire"))) response.set("resultBadExpire", "Y");
-            if (Boolean.TRUE.equals(context.get("resultBadCardNumber"))) response.set("resultBadCardNumber", "Y");
+            if (Boolean.TRUE.equals(context.get("resultDeclined"))) {
+                response.set("resultDeclined", "Y");
+            }
+            if (Boolean.TRUE.equals(context.get("resultNsf"))) {
+                response.set("resultNsf", "Y");
+            }
+            if (Boolean.TRUE.equals(context.get("resultBadExpire"))) {
+                response.set("resultBadExpire", "Y");
+            }
+            if (Boolean.TRUE.equals(context.get("resultBadCardNumber"))) {
+                response.set("resultBadCardNumber", "Y");
+            }
 
             // create the internal messages
-            List<GenericValue> messageEntities = new LinkedList<GenericValue>();
+            List<GenericValue> messageEntities = new LinkedList<>();
             List<String> messages = UtilGenerics.cast(context.get("internalRespMsgs"));
             if (UtilValidate.isNotEmpty(messages)) {
                 Iterator<String> i = messages.iterator();
@@ -2151,8 +2178,9 @@ public class PaymentGatewayServices {
         OrderReadHelper orh = null;
         try {
             GenericValue orderHeader = paymentPreference.getRelatedOne("OrderHeader", false);
-            if (orderHeader != null)
+            if (orderHeader != null) {
                 orh = new OrderReadHelper(orderHeader);
+            }
         } catch (GenericEntityException e) {
             throw new GeneralException("Problems getting OrderHeader; cannot re-auth the payment", e);
         }
@@ -2411,7 +2439,7 @@ public class PaymentGatewayServices {
         // call the service refundPayment
         Map<String, Object> refundResponse = null;
         try {
-            Map<String, Object> serviceContext = new HashMap<String, Object>();
+            Map<String, Object> serviceContext = new HashMap<>();
             serviceContext.put("orderPaymentPreference", orderPaymentPreference);
             serviceContext.put("refundAmount", amount);
             serviceContext.put("userLogin", userLogin);
@@ -2467,7 +2495,7 @@ public class PaymentGatewayServices {
             paymentGatewayConfigId = paymentSettings.getString("paymentGatewayConfigId");
 
             if (serviceName != null) {
-                Map<String, Object> serviceContext = new HashMap<String, Object>();
+                Map<String, Object> serviceContext = new HashMap<>();
                 serviceContext.put("orderPaymentPreference", paymentPref);
                 serviceContext.put("paymentConfig", paymentConfig);
                 serviceContext.put("paymentGatewayConfigId", paymentGatewayConfigId);
@@ -2728,7 +2756,7 @@ public class PaymentGatewayServices {
                 .orderBy("orderId");
 
         try (EntityListIterator eli = eq.queryIterator()) {
-            List<String> processList = new LinkedList<String>();
+            List<String> processList = new LinkedList<>();
             if (eli != null) {
                 Debug.logInfo("Processing failed order re-auth(s)", module);
                 GenericValue value = null;
@@ -2770,7 +2798,7 @@ public class PaymentGatewayServices {
                 .orderBy("orderId");
         
         try (EntityListIterator eli = eq.queryIterator()) {
-            List<String> processList = new LinkedList<String>();
+            List<String> processList = new LinkedList<>();
             if (eli != null) {
                 Debug.logInfo("Processing failed order re-auth(s)", module);
                 GenericValue value = null;
@@ -2930,7 +2958,7 @@ public class PaymentGatewayServices {
         try {
             dispatcher.addRollbackService("savePaymentGatewayResponse", context, true);
             delegator.create(pgr);
-        } catch (GenericEntityException|GenericServiceException ge) {
+        } catch (GenericEntityException | GenericServiceException ge) {
             Debug.logError(ge, module);
         } catch (Exception e) {
             Debug.logError(e, module);
@@ -2948,7 +2976,7 @@ public class PaymentGatewayServices {
             for (GenericValue message : messages) {
                 delegator.create(message);
             }
-        } catch (GenericEntityException|GenericServiceException ge) {
+        } catch (GenericEntityException | GenericServiceException ge) {
             Debug.logError(ge, module);
         } catch (Exception e) {
             Debug.logError(e, module);
@@ -3094,7 +3122,7 @@ public class PaymentGatewayServices {
         String currency = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator);
 
         // prepare the auth context
-        Map<String, Object> authContext = new HashMap<String, Object>();
+        Map<String, Object> authContext = new HashMap<>();
         authContext.put("orderId", "_NA_");
         authContext.put("orderItems", new LinkedList());
         authContext.put("orderPaymentPreference", orderPaymentPref);
@@ -3195,7 +3223,7 @@ public class PaymentGatewayServices {
                     "AccountingPaymentTransactionNotYetSupported",    locale));
         }
         // transaction request context
-        Map<String, Object> requestContext = new HashMap<String, Object>();
+        Map<String, Object> requestContext = new HashMap<>();
         String paymentService = null;
         String paymentConfig = null;
         String paymentGatewayConfigId = null;
@@ -3323,7 +3351,9 @@ public class PaymentGatewayServices {
         String paymentMethodId = (String) context.get("paymentMethodId");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
-        if (Debug.infoOn()) Debug.logInfo("Running verifyCreditCard [ " + paymentMethodId + "] for store: " + productStoreId, module);
+        if (Debug.infoOn()) {
+            Debug.logInfo("Running verifyCreditCard [ " + paymentMethodId + "] for store: " + productStoreId, module);
+        }
 
         GenericValue productStore = null;
         productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
@@ -3339,12 +3369,14 @@ public class PaymentGatewayServices {
         } else if ("UPDATE".equalsIgnoreCase(mode)) {
             amount = EntityUtilProperties.getPropertyValue(productStorePaymentProperties, "payment.general.cc_update.auth", delegator);
         }
-        if (Debug.infoOn()) Debug.logInfo("Running credit card verification [" + paymentMethodId + "] (" + amount + ") : " + productStorePaymentProperties + " : " + mode, module);
+        if (Debug.infoOn()) {
+            Debug.logInfo("Running credit card verification [" + paymentMethodId + "] (" + amount + ") : " + productStorePaymentProperties + " : " + mode, module);
+        }
 
         if (UtilValidate.isNotEmpty(amount)) {
             BigDecimal authAmount = new BigDecimal(amount);
             if (authAmount.compareTo(BigDecimal.ZERO) > 0) {
-                Map<String, Object> ccAuthContext = new HashMap<String, Object>();
+                Map<String, Object> ccAuthContext = new HashMap<>();
                 ccAuthContext.put("paymentMethodId", paymentMethodId);
                 ccAuthContext.put("productStoreId", productStoreId);
                 ccAuthContext.put("amount", authAmount);
@@ -3377,17 +3409,20 @@ public class PaymentGatewayServices {
      */
     public static Map<String, Object> testProcessor(DispatchContext dctx, Map<String, ? extends Object> context) {
         Locale locale = (Locale) context.get("locale");
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         BigDecimal processAmount = (BigDecimal) context.get("processAmount");
 
-        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) >= 0)
+        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) >= 0) {
             result.put("authResult", Boolean.TRUE);
-        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0)
+        }
+        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0) {
             result.put("authResult", Boolean.FALSE);
+        }
             result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(resource,
                     "AccountingPaymentTestProcessorMinimumPurchase", locale)));
-        if (processAmount == null)
+        if (processAmount == null) {
             result.put("authResult", null);
+        }
 
         String refNum = UtilDateTime.nowAsString();
 
@@ -3407,19 +3442,22 @@ public class PaymentGatewayServices {
      */
     public static Map<String, Object> testProcessorWithCapture(DispatchContext dctx, Map<String, ? extends Object> context) {
         Locale locale = (Locale) context.get("locale");
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         BigDecimal processAmount = (BigDecimal) context.get("processAmount");
 
-        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) >= 0)
+        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) >= 0) {
             result.put("authResult", Boolean.TRUE);
+        }
             result.put("captureResult", Boolean.TRUE);
-        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0)
+        if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0) {
             result.put("authResult", Boolean.FALSE);
+        }
             result.put("captureResult", Boolean.FALSE);
             result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(resource,
                     "AccountingPaymentTestProcessorMinimumPurchase", locale)));
-        if (processAmount == null)
+        if (processAmount == null) {
             result.put("authResult", null);
+        }
 
         String refNum = UtilDateTime.nowAsString();
 
@@ -3470,7 +3508,7 @@ public class PaymentGatewayServices {
      */
     public static Map<String, Object> alwaysApproveProcessor(DispatchContext dctx, Map<String, ? extends Object> context) {
         Locale locale = (Locale) context.get("locale");
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Debug.logInfo("Test Processor Approving Credit Card", module);
 
         String refNum = UtilDateTime.nowAsString();
@@ -3488,7 +3526,7 @@ public class PaymentGatewayServices {
 
     public static Map<String, Object> alwaysApproveWithCapture(DispatchContext dctx, Map<String, ? extends Object> context) {
         Locale locale = (Locale) context.get("locale");
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         String refNum = UtilDateTime.nowAsString();
         Debug.logInfo("Test Processor Approving Credit Card with Capture", module);
 
@@ -3698,7 +3736,9 @@ public class PaymentGatewayServices {
         cal.setTimeInMillis(txStamp.getTime());
         cal.add(Calendar.MINUTE, 2);
         Timestamp twoMinAfter = new Timestamp(cal.getTimeInMillis());
-        if (Debug.infoOn()) Debug.logInfo("Re-Auth Capture Test : Tx Date - " + txStamp + " : 2 Min - " + twoMinAfter + " : Now - " + nowStamp, module);
+        if (Debug.infoOn()) {
+            Debug.logInfo("Re-Auth Capture Test : Tx Date - " + txStamp + " : 2 Min - " + twoMinAfter + " : Now - " + nowStamp, module);
+        }
 
         if (nowStamp.after(twoMinAfter)) {
             result.put("captureResult", Boolean.FALSE);
@@ -3759,7 +3799,7 @@ public class PaymentGatewayServices {
     public static boolean isReplacementOrder(GenericValue orderHeader) {
         boolean replacementOrderFlag = false;
 
-        List<GenericValue> returnItemResponses = new LinkedList<GenericValue>();
+        List<GenericValue> returnItemResponses = new LinkedList<>();
         try {
             returnItemResponses = orderHeader.getRelated("ReplacementReturnItemResponse", null, null, false);
         } catch (GenericEntityException e) {

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java?rev=1818564&r1=1818563&r2=1818564&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java Mon Dec 18 13:00:59 2017
@@ -60,7 +60,7 @@ public class PaymentMethodServices {
      * @return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> deletePaymentMethod(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -110,7 +110,7 @@ public class PaymentMethodServices {
     }
 
     public static Map<String, Object> makeExpireDate(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         String expMonth = (String) context.get("expMonth");
         String expYear = (String) context.get("expYear");
 
@@ -131,7 +131,7 @@ public class PaymentMethodServices {
      * @return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createCreditCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -141,10 +141,12 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE");
 
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
         // do some more complicated/critical validation...
-        List<String> messages = new LinkedList<String>();
+        List<String> messages = new LinkedList<>();
 
         // first remove all spaces from the credit card number
         context.put("cardNumber", StringUtil.removeSpaces((String) context.get("cardNumber")));
@@ -165,7 +167,7 @@ public class PaymentMethodServices {
             return ServiceUtil.returnError(messages);
         }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
 
         toBeStored.add(newPm);
@@ -230,7 +232,9 @@ public class PaymentMethodServices {
             }
         }
 
-        if (newPartyContactMechPurpose != null) toBeStored.add(newPartyContactMechPurpose);
+        if (newPartyContactMechPurpose != null) {
+            toBeStored.add(newPartyContactMechPurpose);
+        }
 
         try {
             delegator.storeAll(toBeStored);
@@ -253,7 +257,7 @@ public class PaymentMethodServices {
      * @return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> updateCreditCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -263,9 +267,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE");
 
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -294,7 +300,7 @@ public class PaymentMethodServices {
         }
 
         // do some more complicated/critical validation...
-        List<String> messages = new LinkedList<String>();
+        List<String> messages = new LinkedList<>();
 
         // first remove all spaces from the credit card number
         String updatedCardNumber = StringUtil.removeSpaces((String) context.get("cardNumber"));
@@ -409,7 +415,9 @@ public class PaymentMethodServices {
         }
 
         if (isModified) {
-            if (newPartyContactMechPurpose != null) toBeStored.add(newPartyContactMechPurpose);
+            if (newPartyContactMechPurpose != null) {
+                toBeStored.add(newPartyContactMechPurpose);
+            }
 
             // set thru date on old paymentMethod
             paymentMethod.set("thruDate", now);
@@ -484,7 +492,7 @@ public class PaymentMethodServices {
     }
 
     public static Map<String, Object> createGiftCard(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -494,10 +502,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE");
 
-        if (result.size() > 0)
+        if (result.size() > 0) {
             return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
         toBeStored.add(newPm);
         GenericValue newGc = delegator.makeValue("GiftCard");
@@ -541,7 +550,7 @@ public class PaymentMethodServices {
     }
 
     public static Map<String, Object> updateGiftCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -551,10 +560,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE");
 
-        if (result.size() > 0)
+        if (result.size() > 0) {
             return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -675,7 +685,7 @@ public class PaymentMethodServices {
      * @return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createEftAccount(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -685,9 +695,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE");
 
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
 
         toBeStored.add(newPm);
@@ -749,8 +761,9 @@ public class PaymentMethodServices {
             }
         }
 
-        if (newPartyContactMechPurpose != null)
+        if (newPartyContactMechPurpose != null) {
             toBeStored.add(newPartyContactMechPurpose);
+        }
 
         try {
             delegator.storeAll(toBeStored);
@@ -774,7 +787,7 @@ public class PaymentMethodServices {
      * @return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> updateEftAccount(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -784,9 +797,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE");
 
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -879,8 +894,9 @@ public class PaymentMethodServices {
 
         if (isModified) {
             // Debug.logInfo("yes, is modified", module);
-            if (newPartyContactMechPurpose != null)
+            if (newPartyContactMechPurpose != null) {
                 toBeStored.add(newPartyContactMechPurpose);
+            }
 
             // set thru date on old paymentMethod
             paymentMethod.set("thruDate", now);
@@ -910,7 +926,7 @@ public class PaymentMethodServices {
         return result;
     }
     public static Map<String, Object> createCheckAccount(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
                 GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -918,9 +934,11 @@ public class PaymentMethodServices {
         Timestamp now = UtilDateTime.nowTimestamp();
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE");
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
         toBeStored.add(newPm);
 
@@ -979,8 +997,9 @@ public class PaymentMethodServices {
             }
         }
 
-        if (newPartyContactMechPurpose != null)
+        if (newPartyContactMechPurpose != null) {
             toBeStored.add(newPartyContactMechPurpose);
+        }
 
         try {
             delegator.storeAll(toBeStored);
@@ -995,7 +1014,7 @@ public class PaymentMethodServices {
     }
 
     public static Map<String, Object> updateCheckAccount(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -1005,9 +1024,11 @@ public class PaymentMethodServices {
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE");
 
-        if (result.size() > 0) return result;
+        if (result.size() > 0) {
+            return result;
+        }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -1100,8 +1121,9 @@ public class PaymentMethodServices {
 
         if (isModified) {
             // Debug.logInfo("yes, is modified", module);
-            if (newPartyContactMechPurpose != null)
+            if (newPartyContactMechPurpose != null) {
                 toBeStored.add(newPartyContactMechPurpose);
+            }
 
             // set thru date on old paymentMethod
             paymentMethod.set("thruDate", now);

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java?rev=1818564&r1=1818563&r2=1818564&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java Mon Dec 18 13:00:59 2017
@@ -59,35 +59,49 @@ public final class PaymentWorker {
     }
 
     public static List<Map<String, GenericValue>> getPartyPaymentMethodValueMaps(Delegator delegator, String partyId, Boolean showOld) {
-        List<Map<String, GenericValue>> paymentMethodValueMaps = new LinkedList<Map<String,GenericValue>>();
+        List<Map<String, GenericValue>> paymentMethodValueMaps = new LinkedList<>();
         try {
             List<GenericValue> paymentMethods = EntityQuery.use(delegator).from("PaymentMethod").where("partyId", partyId).queryList();
 
-            if (!showOld) paymentMethods = EntityUtil.filterByDate(paymentMethods, true);
+            if (!showOld) {
+                paymentMethods = EntityUtil.filterByDate(paymentMethods, true);
+            }
 
             for (GenericValue paymentMethod : paymentMethods) {
-                Map<String, GenericValue> valueMap = new HashMap<String, GenericValue>();
+                Map<String, GenericValue> valueMap = new HashMap<>();
 
                 paymentMethodValueMaps.add(valueMap);
                 valueMap.put("paymentMethod", paymentMethod);
                 if ("CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard", false);
-                    if (creditCard != null) valueMap.put("creditCard", creditCard);
+                    if (creditCard != null) {
+                        valueMap.put("creditCard", creditCard);
+                    }
                 } else if ("GIFT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue giftCard = paymentMethod.getRelatedOne("GiftCard", false);
-                    if (giftCard != null) valueMap.put("giftCard", giftCard);
+                    if (giftCard != null) {
+                        valueMap.put("giftCard", giftCard);
+                    }
                 } else if ("EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount", false);
-                    if (eftAccount != null) valueMap.put("eftAccount", eftAccount);
+                    if (eftAccount != null) {
+                        valueMap.put("eftAccount", eftAccount);
+                    }
                 } else if ("COMPANY_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue companyCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false);
-                    if (companyCheckAccount != null) valueMap.put("companyCheckAccount", companyCheckAccount);
+                    if (companyCheckAccount != null) {
+                        valueMap.put("companyCheckAccount", companyCheckAccount);
+                    }
                 } else if ("PERSONAL_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue personalCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false);
-                    if (personalCheckAccount != null) valueMap.put("personalCheckAccount", personalCheckAccount);
+                    if (personalCheckAccount != null) {
+                        valueMap.put("personalCheckAccount", personalCheckAccount);
+                    }
                 } else if ("CERTIFIED_CHECK".equals(paymentMethod.getString("paymentMethodTypeId"))) {
                     GenericValue certifiedCheckAccount = paymentMethod.getRelatedOne("CheckAccount", false);
-                    if (certifiedCheckAccount != null) valueMap.put("certifiedCheckAccount", certifiedCheckAccount);
+                    if (certifiedCheckAccount != null) {
+                        valueMap.put("certifiedCheckAccount", certifiedCheckAccount);
+                    }
                 }
             }
         } catch (GenericEntityException e) {
@@ -98,14 +112,17 @@ public final class PaymentWorker {
 
     public static Map<String, Object> getPaymentMethodAndRelated(ServletRequest request, String partyId) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
-        Map<String, Object> results = new HashMap<String, Object>();
+        Map<String, Object> results = new HashMap<>();
 
         Boolean tryEntity = true;
-        if (request.getAttribute("_ERROR_MESSAGE_") != null) tryEntity = false;
+        if (request.getAttribute("_ERROR_MESSAGE_") != null) {
+            tryEntity = false;
+        }
 
         String donePage = request.getParameter("DONE_PAGE");
-        if (UtilValidate.isEmpty(donePage))
+        if (UtilValidate.isEmpty(donePage)) {
             donePage = "viewprofile";
+        }
         results.put("donePage", donePage);
 
         String paymentMethodId = request.getParameter("paymentMethodId");
@@ -325,7 +342,7 @@ public final class PaymentWorker {
         if (actual.equals(Boolean.TRUE) && UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) {
             return payment.getBigDecimal("actualCurrencyAmount").subtract(getPaymentApplied(payment, actual)).setScale(decimals,rounding);
         }
-            return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(decimals,rounding);
+        return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(decimals,rounding);
     }
 
     public static BigDecimal getPaymentNotApplied(Delegator delegator, String paymentId) {