in online_nearline/src/main/scala/VidispineMessageProcessor.scala [395:425]
def copyShapeIfRequired(vault: Vault, mediaIngested: VidispineMediaIngested,
itemId: String, shapeId: String,
nearlineRecord: NearlineRecord): Future[Either[String, MessageProcessorReturnValue]] = {
vidispineCommunicator.findItemShape(itemId, shapeId).flatMap({
case None=>
logger.error(s"Shape $shapeId does not exist on item $itemId despite a notification informing us that it does.")
Future.failed(new RuntimeException(s"Shape $shapeId does not exist"))
case Some(shapeDoc)=>
shapeDoc.getLikelyFile match {
case None =>
Future(Left(s"No file exists on shape $shapeId for item $itemId yet"))
case Some(fileInfo) =>
getFilePathForShape(shapeDoc, itemId, shapeId).flatMap({
case Left(err) =>
logger.error(s"Can't find filePath for Shape with id $shapeId - err ${err}")
Future.failed(new RuntimeException(s"Shape $shapeId does not exist"))
case Right(filePath) =>
val copyFut = for {
copyResult <- uploadShapeIfRequired(vault, filePath, mediaIngested, nearlineRecord, fileInfo)
} yield copyResult
//the future will fail if we can't copy to MatrixStore, but treat this as a retryable failure
copyFut.recover({
case err: Throwable =>
logger.error(s"Could not copy ${filePath.toString} to MatrixStore: ${err.getMessage}", err)
Left(s"Could not copy ${filePath.toString} to MatrixStore")
})
})
}
})
}