def handleNearlineCompleteForOnline()

in media_remover/src/main/scala/OnlineNearlineMessageProcessor.scala [163:194]


  def handleNearlineCompleteForOnline(vault: Vault, nearlineRecord: NearlineRecord): Future[Either[String, MessageProcessorReturnValue]] = {
    nearlineRecord.vidispineItemId match {
      case None => throw new RuntimeException("Nearline newfile received 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(vault, 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} ${rec.nearlineId.get}, $vsItemId, size $onlineSize, ${rec.originalFilePath}, see logs for details"))
                    } else {
                      pendingDeletionRecordDAO.updateAttemptCount(rec.id.get, rec.attempt + 1)
                      logger.debug(s"Could not find exact match in nearline vault for $vsItemId, size $onlineSize, ${rec.originalFilePath}, wait for next newfile.success")
                      throw SilentDropMessage(Some("Could not find exact match in nearline vault, wait for next newfile.success"))
                    }
                })
              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 nearline newfile confirmation, no pending deletion for this ${MediaTiers.ONLINE.toString} item with ${nearlineRecord.originalFilePath}"))
        })
    }
  }