From b30a53c60ac70a883ddbf9dec252f4a01fb5a175 Mon Sep 17 00:00:00 2001
From: Jayaprakash8887 <jayaprakash.narayanaswamy@tarento.com>
Date: Tue, 20 Jul 2021 15:43:08 +0530
Subject: [PATCH] Issue #SB-22862 feat: Collection CSV Hierarchy feature API -
 SB-25836 Issue fix

---
 .../validator/CollectionCSVValidator.scala             | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/content-api/collection-csv-actors/src/main/scala/org.sunbird/collectioncsv/validator/CollectionCSVValidator.scala b/content-api/collection-csv-actors/src/main/scala/org.sunbird/collectioncsv/validator/CollectionCSVValidator.scala
index 7df8c8e17..e665b21d8 100644
--- a/content-api/collection-csv-actors/src/main/scala/org.sunbird/collectioncsv/validator/CollectionCSVValidator.scala
+++ b/content-api/collection-csv-actors/src/main/scala/org.sunbird/collectioncsv/validator/CollectionCSVValidator.scala
@@ -305,6 +305,16 @@ object CollectionCSVValidator {
 
     if (invalidCollectionNodeIDErrorMessage.trim.nonEmpty)
       throw new ClientException("CSV_INVALID_COLLECTION_NODE_ID", "Following rows have invalid “Folder Identifier”. Please correct and upload again: " + invalidCollectionNodeIDErrorMessage)
+
+    val folderIdentifierList  = csvRecords.flatMap(csvRecord => {
+      csvRecord.toMap.asScala.toMap.map(colData => {
+        if (collectionNodeIdentifierHeader.contains(colData._1) && collectionChildNodes.contains(colData._2.trim)) colData._2.trim else ""
+      })
+    }).filter(msg => msg.nonEmpty)
+
+    if(folderIdentifierList.size>folderIdentifierList.distinct.size)
+      throw new ClientException("DUPLICATE_FOLDER_IDENTIFIERS", "Duplicate “Folder Identifier” found. Please correct and upload again.")
+
     // validate Folder Identifier column in CSV - END
     TelemetryManager.log("CollectionCSVActor --> validateCSVRecordsDataAuthenticity --> after validating Folder Identifier column in CSV")
   }
-- 
GitLab