in media_remover/src/main/scala/helpers/PendingDeletionHelper.scala [21:55]
def removeDeletionPendingByMessage(msg: OnlineOutputMessage): Future[Either[String, Int]] =
(msg.mediaTier, msg.vidispineItemId, msg.nearlineId) match {
case ("NEARLINE", _, Some(nearlineId)) =>
pendingDeletionRecordDAO
.findByNearlineIdForNEARLINE(nearlineId)
.flatMap({
// The number returned in the Right is the number of affected rows.
// We always call this method when we delete an item, instead of first checking
// if there exists a pending deletion => if none is found, that's not an
// error, but obviously no rows are updated, hence Right(0) in that case.
case Some(existingRecord) =>
deleteExistingPendingDeletionRecord(existingRecord)
case None =>
Future(Right(0))
})
case ("NEARLINE", _, _) =>
Future.failed(new RuntimeException("NEARLINE but no nearlineId"))
case ("ONLINE", Some(vsItemId), _) =>
pendingDeletionRecordDAO
.findByOnlineIdForONLINE(vsItemId)
.flatMap({
case Some(existingRecord) =>
deleteExistingPendingDeletionRecord(existingRecord)
case None =>
Future(Right(0))
})
case ("ONLINE", _, _) =>
Future.failed(new RuntimeException("ONLINE but no vsItemId"))
case (_, _, _) =>
Future.failed(new RuntimeException("This should not happen!"))
}