FINERACT-933 Fixed ArrayIndexOutOfBoundsException at ClientPersonImportHandler

This commit is contained in:
nnatarajan
2020-06-03 10:50:48 +02:00
committed by Michael Vorburger ⛑️
parent 8d7fa73b46
commit 3521b0ed33
@@ -105,7 +105,7 @@ public class ClientPersonImportHandler implements ImportHandler {
Long clientTypeId = null; Long clientTypeId = null;
if (clientType!=null) { if (clientType!=null) {
String[] clientTypeAr = clientType.split("-"); String[] clientTypeAr = clientType.split("-");
if (clientTypeAr[1] != null) { if (clientTypeAr.length > 1 && clientTypeAr[1] != null) {
clientTypeId = Long.parseLong(clientTypeAr[1]); clientTypeId = Long.parseLong(clientTypeAr[1]);
} }
} }
@@ -113,16 +113,16 @@ public class ClientPersonImportHandler implements ImportHandler {
Long genderId = null; Long genderId = null;
if (gender!=null) { if (gender!=null) {
String[] genderAr = gender.split("-"); String[] genderAr = gender.split("-");
if (genderAr[1] != null) { if (genderAr.length > 1 && genderAr[1] != null) {
genderId = Long.parseLong(genderAr[1]); genderId = Long.parseLong(genderAr[1]);
} }
} }
String clientClassification= ImportHandlerUtils.readAsString(ClientPersonConstants.CLIENT_CLASSIFICATION_COL, row); String clientClassification= ImportHandlerUtils.readAsString(ClientPersonConstants.CLIENT_CLASSIFICATION_COL, row);
Long clientClassicationId = null; Long clientClassificationId = null;
if (clientClassification!=null) { if (clientClassification!=null) {
String[] clientClassificationAr = clientClassification.split("-"); String[] clientClassificationAr = clientClassification.split("-");
if (clientClassificationAr[1] != null) { if (clientClassificationAr.length > 1 && clientClassificationAr[1] != null) {
clientClassicationId = Long.parseLong(clientClassificationAr[1]); clientClassificationId = Long.parseLong(clientClassificationAr[1]);
} }
} }
Boolean isStaff = ImportHandlerUtils.readAsBoolean(ClientPersonConstants.IS_STAFF_COL, row); Boolean isStaff = ImportHandlerUtils.readAsBoolean(ClientPersonConstants.IS_STAFF_COL, row);
@@ -135,7 +135,7 @@ public class ClientPersonImportHandler implements ImportHandler {
if (addressType!=null) { if (addressType!=null) {
String[] addressTypeAr = addressType.split("-"); String[] addressTypeAr = addressType.split("-");
if (addressTypeAr[1] != null) { if (addressTypeAr.length > 1 && addressTypeAr[1] != null) {
addressTypeId = Long.parseLong(addressTypeAr[1]); addressTypeId = Long.parseLong(addressTypeAr[1]);
} }
} }
@@ -150,11 +150,11 @@ public class ClientPersonImportHandler implements ImportHandler {
String stateProvince=ImportHandlerUtils.readAsString(ClientPersonConstants.STATE_PROVINCE_COL, row); String stateProvince=ImportHandlerUtils.readAsString(ClientPersonConstants.STATE_PROVINCE_COL, row);
Long stateProvinceId = null; Long stateProvinceId = null;
if (stateProvince!=null && stateProvince.isBlank()) { if (stateProvince != null) {
String[] stateProvinceAr = stateProvince.split("-"); String[] stateProvinceAr = stateProvince.split("-");
// Arkansas-AL <-- expected format of the cell // Arkansas-AL <-- expected format of the cell
// but probably it's either an empty cell or it is missing a hyphen // 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]); stateProvinceId = Long.parseLong(stateProvinceAr[1]);
} }
} }
@@ -162,7 +162,7 @@ public class ClientPersonImportHandler implements ImportHandler {
Long countryId=null; Long countryId=null;
if (country!=null) { if (country!=null) {
String[] countryAr = country.split("-"); String[] countryAr = country.split("-");
if (countryAr[1] != null) { if (countryAr.length > 1 && countryAr[1] != null) {
countryId = Long.parseLong(countryAr[1]); countryId = Long.parseLong(countryAr[1]);
} }
} }
@@ -171,7 +171,7 @@ public class ClientPersonImportHandler implements ImportHandler {
addressList = new ArrayList<AddressData>(Arrays.asList(addressDataObj)); addressList = new ArrayList<AddressData>(Arrays.asList(addressDataObj));
} }
return ClientData.importClientPersonInstance(legalFormId,row.getRowNum(),firstName,lastName,middleName,submittedOn,activationDate,active,externalId, 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); addressList, locale, dateFormat);
} }