You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2020/06/03 08:51:00 UTC

[fineract] 02/02: FINERACT-933 Fixed ArrayIndexOutOfBoundsException at ClientPersonImportHandler

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

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 3521b0ed334831dbb4ab0db9216a493c532982db
Author: nnatarajan <na...@gmail.com>
AuthorDate: Mon Jun 1 20:10:10 2020 -0600

    FINERACT-933 Fixed ArrayIndexOutOfBoundsException at ClientPersonImportHandler
---
 .../client/ClientPersonImportHandler.java            | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
index 15a54d0..e52bd98 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/client/ClientPersonImportHandler.java
@@ -105,7 +105,7 @@ public class ClientPersonImportHandler implements ImportHandler {
         Long clientTypeId = null;
         if (clientType!=null) {
             String[] clientTypeAr = clientType.split("-");
-            if (clientTypeAr[1] != null) {
+            if (clientTypeAr.length > 1 && clientTypeAr[1] != null) {
                 clientTypeId = Long.parseLong(clientTypeAr[1]);
             }
         }
@@ -113,16 +113,16 @@ public class ClientPersonImportHandler implements ImportHandler {
         Long genderId = null;
         if (gender!=null) {
             String[] genderAr = gender.split("-");
-            if (genderAr[1] != null) {
+            if (genderAr.length > 1 && genderAr[1] != null) {
                 genderId = Long.parseLong(genderAr[1]);
             }
         }
         String clientClassification= ImportHandlerUtils.readAsString(ClientPersonConstants.CLIENT_CLASSIFICATION_COL, row);
-        Long clientClassicationId = null;
+        Long clientClassificationId = null;
         if (clientClassification!=null) {
             String[] clientClassificationAr = clientClassification.split("-");
-            if (clientClassificationAr[1] != null) {
-                clientClassicationId = Long.parseLong(clientClassificationAr[1]);
+            if (clientClassificationAr.length > 1 && clientClassificationAr[1] != null) {
+                clientClassificationId = Long.parseLong(clientClassificationAr[1]);
             }
         }
         Boolean isStaff = ImportHandlerUtils.readAsBoolean(ClientPersonConstants.IS_STAFF_COL, row);
@@ -135,7 +135,7 @@ public class ClientPersonImportHandler implements ImportHandler {
             if (addressType!=null) {
                 String[] addressTypeAr = addressType.split("-");
 
-                if (addressTypeAr[1] != null) {
+                if (addressTypeAr.length > 1 && addressTypeAr[1] != null) {
                     addressTypeId = Long.parseLong(addressTypeAr[1]);
                 }
             }
@@ -150,11 +150,11 @@ public class ClientPersonImportHandler implements ImportHandler {
 
             String stateProvince=ImportHandlerUtils.readAsString(ClientPersonConstants.STATE_PROVINCE_COL, row);
             Long stateProvinceId = null;
-            if (stateProvince!=null && stateProvince.isBlank()) {
+            if (stateProvince != null) {
                 String[] stateProvinceAr = stateProvince.split("-");
                 // Arkansas-AL <-- expected format of the cell
                 // but probably it's either an empty cell or it is missing a hyphen
-                if (stateProvinceAr[1] != null) {
+                if (stateProvinceAr.length > 1 && stateProvinceAr[1] != null) {
                     stateProvinceId = Long.parseLong(stateProvinceAr[1]);
                 }
             }
@@ -162,7 +162,7 @@ public class ClientPersonImportHandler implements ImportHandler {
             Long countryId=null;
             if (country!=null) {
                 String[] countryAr = country.split("-");
-                if (countryAr[1] != null) {
+                if (countryAr.length > 1 && countryAr[1] != null) {
                     countryId = Long.parseLong(countryAr[1]);
                 }
             }
@@ -171,7 +171,7 @@ public class ClientPersonImportHandler implements ImportHandler {
              addressList = new ArrayList<AddressData>(Arrays.asList(addressDataObj));
         }
         return ClientData.importClientPersonInstance(legalFormId,row.getRowNum(),firstName,lastName,middleName,submittedOn,activationDate,active,externalId,
-                officeId, staffId, mobileNo, dob, clientTypeId, genderId, clientClassicationId, isStaff,
+                officeId, staffId, mobileNo, dob, clientTypeId, genderId, clientClassificationId, isStaff,
                 addressList, locale, dateFormat);
 
     }