This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3d751a0  Improved:  Fix some bugs Spotbugs reports (OFBIZ-12386)
3d751a0 is described below

commit 3d751a0d4dba76fb2da53dc891c9aba87b982195
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Mon Nov 29 09:27:09 2021 +0100

    Improved:  Fix some bugs Spotbugs reports (OFBIZ-12386)
    
    Removes generateRandomFinNumber and checkIsNumberInDatabase methods
    
    There is no OOTB usage and they were put in almost 15 years ago with
    http://svn.apache.org/viewvc?view=revision&revision=522738
---
 .../ofbiz/order/finaccount/FinAccountHelper.java   | 45 ----------------------
 1 file changed, 45 deletions(-)

diff --git 
a/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
 
b/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
index 3447c1f..ee33a8d 100644
--- 
a/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
+++ 
b/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
@@ -273,51 +273,6 @@ public final class FinAccountHelper {
         return false;
     }
 
-    /**
-     * Generate a random financial number
-     * @param delegator the delegator
-     * @param length    length of the number to generate (up to 19 digits)
-     * @param isId      to be used as an ID (will check the DB to make sure it 
doesn't already exist)
-     * @return Generated number
-     * @throws GenericEntityException
-     */
-    public static String generateRandomFinNumber(Delegator delegator, int 
length, boolean isId) throws GenericEntityException {
-        if (length > 19) {
-            length = 19;
-        }
-
-        Random rand = new Random();
-        boolean isValid = false;
-        String number = null;
-        StringBuilder numberBuilder = new StringBuilder();
-        while (!isValid) {
-            for (int i = 0; i < length; i++) {
-                int randInt = rand.nextInt(9);
-                numberBuilder.append(randInt);
-            }
-
-            if (isId) {
-                // FIXME number is null!
-                int check = UtilValidate.getLuhnCheckDigit(number);
-                numberBuilder.append(check);
-                number = numberBuilder.toString();
-                // validate the number
-                if (checkFinAccountNumber(number)) {
-                    // make sure this number doens't already exist
-                    isValid = checkIsNumberInDatabase(delegator, number);
-                }
-            } else {
-                isValid = true;
-            }
-        }
-        return number;
-    }
-
-    private static boolean checkIsNumberInDatabase(Delegator delegator, String 
number) throws GenericEntityException {
-        GenericValue finAccount = 
EntityQuery.use(delegator).from("FinAccount").where("finAccountId", 
number).queryOne();
-        return finAccount == null;
-    }
-
     public static boolean checkFinAccountNumber(String number) {
         number = number.replaceAll("\\D", "");
         return UtilValidate.sumIsMod10(UtilValidate.getLuhnSum(number));

Reply via email to