in media_remover/src/main/scala/OnlineNearlineMessageProcessor.scala [131:161]
def handleInternalArchiveCompleteForOnline(internalArchiveVault: Vault, nearlineRecord: NearlineRecord): Future[Either[String, MessageProcessorReturnValue]] = {
nearlineRecord.vidispineItemId match {
case None => throw new RuntimeException("Internal archive completed for online, but no online id!")
case Some(vsItemId) =>
pendingDeletionRecordDAO.findByOnlineIdForONLINE(vsItemId).flatMap({
case Some(rec) =>
onlineHelper.getOnlineSize(vsItemId).flatMap({
case Some(onlineSize) =>
val filePathBack = nearlineHelper.putItBack(rec.originalFilePath)
onlineExistsInVault(internalArchiveVault, vsItemId, filePathBack, onlineSize).flatMap({
case true =>
for {
mediaRemovedMessage <- onlineHelper.deleteMediaFromOnline(rec)
_ <- pendingDeletionRecordDAO.deleteRecord(rec)
} yield mediaRemovedMessage
case false =>
if (rec.attempt >= selfHealRetryLimit) {
Future.failed(new RuntimeException(s"Too many self-heal retries for ${MediaTiers.ONLINE} ${vsItemId}, ${rec.originalFilePath}, see logs for details"))
} else {
pendingDeletionRecordDAO.updateAttemptCount(rec.id.get, rec.attempt + 1)
nearlineHelper.outputInternalArchiveCopyRequiredForOnline(vsItemId, rec.originalFilePath)
}
})
case _ =>
logger.info(s"Could not get online size from Vidispine, retrying")
Future(Left(s"Could not get online size from Vidispine, retrying"))
})
case None => throw SilentDropMessage(Some(s"ignoring internal archive confirmation, no pending deletion for this ${MediaTiers.ONLINE.toString} item with ${nearlineRecord.originalFilePath}"))
})
}
}