def handleReplayStageTwo()

in online_archive/src/main/scala/OwnMessageProcessor.scala [188:216]


  def handleReplayStageTwo(msg:Json) = {
    msg.as[AssetSweeperNewFile] match {
      case Right(newFile) =>
        newFile.imported_id match {
          case Some(vidispineItemId) =>
            val filePathString = Paths.get(newFile.filepath, newFile.filename).toString
            val validationResult = for {
              maybeArchivedRecord <- archivedRecordDAO.findBySourceFilename(filePathString)
              maybeArchiveHunterValidated <- maybeArchivedRecord match {
                case Some(archivedRecord)=>handleArchivehunterValidation(archivedRecord)
                case None=>
                  Future.failed(new RuntimeException(s"The given asset sweeper record for ${newFile.filepath}/${newFile.filename} is not imported yet"))
              }
            } yield maybeArchiveHunterValidated

            validationResult.flatMap({
              case Left(retryableErr)=>
                Future(Left(retryableErr))
              case Right(updatedArchivedRecord)=>
                handleReplayUpload(newFile, vidispineItemId, filePathString, updatedArchivedRecord)
            })
          case None =>
            logger.info(s"The item at ${newFile.filepath}/${newFile.filename} is not ingested to Vidispine yet.")
            Future.failed(SilentDropMessage())
        }
      case Left(err)=>
        Future(Left(s"Could not parse incoming message: $err"))
    }
  }