diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index a65541647..9f3b9eab6 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -1097,6 +1097,8 @@ public class Constants { public static final String SEARCH_COMPETENCY_SUB_THEMES = "competencySubTheme"; public static final String MCQ_MCA_W = "mcq-mca-w"; public static final String MCQ_SCA_TF = "mcq-sca-tf"; + public static final String CSV_FILE = ".csv"; + public static final String XLSX_FILE = ".xlsx"; private Constants() { throw new IllegalStateException("Utility class"); diff --git a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java index 710f75f5a..89d8a4c8e 100644 --- a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java +++ b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java @@ -69,9 +69,19 @@ public void initiateUserBulkUploadProcess(String inputData) { if (errList.isEmpty()) { updateUserBulkUploadStatus(inputDataMap.get(Constants.ROOT_ORG_ID), inputDataMap.get(Constants.IDENTIFIER), Constants.STATUS_IN_PROGRESS_UPPERCASE, 0, 0, 0); - storageService.downloadFile(inputDataMap.get(Constants.FILE_NAME)); - //processBulkUpload(inputDataMap); - processCSVBulkUploadV2(inputDataMap); + String fileName = inputDataMap.get(Constants.FILE_NAME); + logger.info("fileName {} ", fileName); + storageService.downloadFile(fileName); + switch (getFileExtension(fileName)) { + case Constants.CSV_FILE: + processCSVBulkUploadV2(inputDataMap); + break; + case Constants.XLSX_FILE: + processBulkUpload(inputDataMap); + break; + default: + logger.error("Unsupported file type: {}", fileName); + } } else { logger.error(String.format("Error in the Kafka Message Received : %s", errList)); } @@ -788,5 +798,9 @@ private boolean validateFieldValue(String fieldKey, String fieldValue) { return !designationsSet.contains(fieldValue); } } + private String getFileExtension(String fileName) { + int lastIndexOfDot= fileName.lastIndexOf('.'); + return lastIndexOfDot == -1 ? "" : fileName.substring(lastIndexOfDot); + } } \ No newline at end of file