Commit cd4351f8 authored by Mahesh Kumar Gangula's avatar Mahesh Kumar Gangula
Browse files

Issue #000 fix: update action list for relation cache update.

No related merge requests found
Showing with 5 additions and 11 deletions
+5 -11
......@@ -48,8 +48,7 @@ class PostPublishEventRouter(config: PostPublishProcessorConfig)
val action = eData.getOrDefault("action", "").asInstanceOf[String]
val mimeType = eData.getOrDefault("mimeType", "").asInstanceOf[String]
val identifier = eData.getOrDefault("identifier", "").asInstanceOf[String]
val manualSync = eData.getOrDefault("manual-sync", false.asInstanceOf[AnyRef]).asInstanceOf[Boolean]
if (validEvent(mimeType, action, manualSync)) {
if (StringUtils.equals("application/vnd.ekstep.content-collection", mimeType) && StringUtils.equals(action, "post-publish-process")) {
// Check shallow copied contents and publish.
val shallowCopied = getShallowCopiedContents(identifier)
logger.info("Shallow copied by this content - " + identifier + " are: " + shallowCopied.size)
......@@ -89,12 +88,6 @@ class PostPublishEventRouter(config: PostPublishProcessorConfig)
List(config.successEventCount, config.failedEventCount, config.skippedEventCount, config.totalEventsCount)
}
def validEvent(mimeType: String, action: String, manualSync: Boolean): Boolean = {
(StringUtils.equals("application/vnd.ekstep.content-collection", mimeType)
&& StringUtils.equals(action, "post-publish-process")
&& !manualSync)
}
def getShallowCopiedContents(identifier: String): List[PublishMetadata] = {
val httpRequest = s"""{"request":{"filters":{"status":["Draft","Review","Live","Unlisted","Failed"],"origin":"${identifier}"},"fields":["identifier","mimeType","contentType","versionKey","channel","status","pkgVersion","lastPublishedBy","origin","originData"]}}"""
val httpResponse = PPPStreamTask.httpUtil.post(config.searchBaseUrl + "/v3/search", httpRequest)
......
......@@ -29,6 +29,7 @@ class RelationCacheUpdater(config: RelationCacheUpdaterConfig)
private var dataCache: DataCache = _
private var collectionCache: DataCache = _
lazy private val mapper: ObjectMapper = new ObjectMapper()
private val actions: List[String] = List("post-publish-process", "relation-cache-update")
override def open(parameters: Configuration): Unit = {
......@@ -90,9 +91,9 @@ class RelationCacheUpdater(config: RelationCacheUpdaterConfig)
val mimeType = eData.getOrDefault("mimeType", "").asInstanceOf[String]
val identifier = eData.getOrDefault("identifier", "").asInstanceOf[String]
StringUtils.equalsIgnoreCase(action, "post-publish-process") &&
StringUtils.equalsIgnoreCase(mimeType, "application/vnd.ekstep.content-collection") &&
StringUtils.isNotBlank(identifier)
actions.contains(action) && StringUtils.isNotBlank(identifier) &&
StringUtils.equalsIgnoreCase(mimeType, "application/vnd.ekstep.content-collection")
}
private def getHierarchy(identifier: String)(implicit metrics: Metrics): java.util.Map[String, AnyRef] = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment