Skip to content

Commit

Permalink
Issue #KN-439 merge: Merge pull request #891 from project-sunbird/csp…
Browse files Browse the repository at this point in the history
…-migration

Issue #KN-439 feat: Handles domain agnostic for Cassandra
  • Loading branch information
AmiableAnil authored Nov 29, 2022
2 parents ee56486 + d1d6a03 commit 1414539
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GraphService {

def saveExternalProps(request: Request): Future[Response] = {
val externalProps: java.util.Map[String, AnyRef] = request.getRequest
val updatedExternalProps = if(isrRelativePathEnabled) CSPMetaUtil.updateExternalRelativePath(externalProps) else externalProps
val updatedExternalProps = if(isrRelativePathEnabled) CSPMetaUtil.saveExternalRelativePath(externalProps) else externalProps
request.setRequest(updatedExternalProps)
ExternalPropsManager.saveProps(request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ object CSPMetaUtil {
result
}

def saveExternalRelativePath(data: java.util.Map[String, AnyRef]): java.util.Map[String, AnyRef] = {
logger.info("CSPMetaUtil ::: saveExternalRelativePath util.Map[String, AnyRef] ::: data before url replace :: " + data)
val validCSPSource: List[String] = Platform.getStringList("cloudstorage.write_base_path", new java.util.ArrayList[String]()).asScala.toList
val basePaths: Array[String] = validCSPSource.map(source => source + java.io.File.separator + Platform.getString("cloud_storage_container", "")).toArray
val repArray = getReplacementData(basePaths, "CLOUD_STORAGE_BASE_PATH")

val updatedData: java.util.Map[String, AnyRef] = new java.util.HashMap[String, AnyRef]
data.asScala.map(field => {
updatedData.put(field._1, StringUtils.replaceEach(field._2.asInstanceOf[String], basePaths, repArray).asInstanceOf[AnyRef])
}).asJava

logger.info("CSPMetaUtil ::: saveExternalRelativePath util.Map[String, AnyRef] ::: data after url replace :: " + updatedData)
updatedData
}

def updateExternalRelativePath(data: java.util.Map[String, AnyRef]): java.util.Map[String, AnyRef] = {
logger.info("CSPMetaUtil ::: updateExternalRelativePath util.Map[String, AnyRef] ::: data before url replace :: " + data)

Expand Down

0 comments on commit 1414539

Please sign in to comment.