Skip to content

Commit

Permalink
santization of org names before creating zips
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamahuli97 committed Aug 11, 2024
1 parent 067b3ca commit c8e3b7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1940,10 +1940,11 @@ object DataUtil extends Serializable {
val orgsL3DF = joinedDF.filter((col("l3mapid").isNull) && col("l2mapid").isNotNull && col("l1mapid").isNotNull).select(col("sborgid").alias("organisationID"))
val orgsDF = processOrgsL3(orgsL3DF, userOrgDF, orgHierarchyCompleteDF)
val combinedMinistryMetricsDF = ministryOrgDF.union(deptOrgDF).union(orgsDF)
val updatedDF = combinedMinistryMetricsDF.withColumn("allIDs", when(col("allIDs").isNull || trim(col("allIDs")) === "", concat(lit("$"), col("ministryID"))).otherwise(col("allIDs")))
val updatedDF = combinedMinistryMetricsDF.withColumn("allIDs", when(col("allIDs").isNull || trim(col("allIDs")) === "", col("ministryID")).otherwise(col("allIDs")))
show(updatedDF, "This will be the final hierarchy")
updatedDF
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ object ZipReportsWithSecurityModel extends AbsDashboardModel {
val folderName = mdoidFolder.getName
val orgID = folderName.split("=")(1)
val orgFileName = getOrgName(orgID, orgNamesDF)
val sanitizedOrgFileName = orgFileName.replaceAll("[/\\\\]", "_")
val zipFilePath = s"${mdoidFolder}"
// Create a password-protected zip file for the mdoid folder
val zipFile = new ZipFile(zipFilePath+"/"+orgFileName+".zip")
val zipFile = new ZipFile(zipFilePath+"/"+sanitizedOrgFileName+".zip")
val parameters = new ZipParameters()
parameters.setCompressionMethod(CompressionMethod.DEFLATE)
// Add all files within the mdoid folder to the zip file
Expand Down Expand Up @@ -179,8 +180,9 @@ object ZipReportsWithSecurityModel extends AbsDashboardModel {
.filter(id => id != null && id.trim.nonEmpty)
.foreach { id =>
val orgFileName = getOrgName(id, orgNamesDF)
val sourceZipFilePath = s"$baseDir/mdoid=$id/$orgFileName.zip"
val destinationZipFilePath = s"$ministryDir/$orgFileName.zip"
val sanitizedOrgFileName = orgFileName.replaceAll("[/\\\\]", "_")
val sourceZipFilePath = s"$baseDir/mdoid=$id/$sanitizedOrgFileName.zip"
val destinationZipFilePath = s"$ministryDir/$sanitizedOrgFileName.zip"

// Copy the zip file
val sourceFile = new File(sourceZipFilePath)
Expand Down

0 comments on commit c8e3b7d

Please sign in to comment.