protected def newCorrelationId: String = UUID.randomUUID()

in online_nearline/src/main/scala/AssetSweeperMessageProcessor.scala [34:79]


  protected def newCorrelationId: String = UUID.randomUUID().toString

  def copyFile(vault: Vault, file: AssetSweeperNewFile, maybeNearlineRecord: Option[NearlineRecord]): Future[Either[String, Json]] = {
    val fullPath = Paths.get(file.filepath, file.filename)

    fileCopier.copyFileToMatrixStore(vault, file.filename, fullPath)
      .flatMap({
        case Right(objectId) =>
          val record = maybeNearlineRecord match {
            case Some(rec) => rec
            case None => NearlineRecord(objectId, fullPath.toString, newCorrelationId)
          }

          MDC.put("correlationId", record.correlationId)

          nearlineRecordDAO
            .writeRecord(record)
            .map(recId=>
              Right(
                record
                  .copy(id=Some(recId), originalFilePath = fullPath.toString, expectingVidispineId = !file.ignore)
                  .asJson
              )
            )
        case Left(error) => Future(Left(error))
      }).recoverWith({
        case err:BailOutException=>
          logger.warn(s"A permanent exception occurred when trying to copy $fullPath: ${err.getMessage}")
          Future.failed(err)
        case err:Throwable=>
          val attemptCount = attemptCountFromMDC() match {
            case Some(count)=>count
            case None=>
              logger.warn(s"Could not get attempt count from logging context for $fullPath, creating failure report with attempt 1")
              1
          }

          val rec = FailureRecord(id = None,
            originalFilePath = fullPath.toString,
            attempt = attemptCount,
            errorMessage = err.getMessage,
            errorComponent = ErrorComponents.Internal,
            retryState = RetryStates.WillRetry)
          failureRecordDAO.writeRecord(rec).map(_=>Left(err.getMessage))
    })
  }