def restoreDestinations()

in app/controllers/Restore.scala [57:77]


  def restoreDestinations(contentId: String) = AuthAction.async {
    val destinations = config.allStacks.map { stack =>
      val destination = Destination(stack.id, stack.displayName, stack.stage, stack.stack,
          stack.composerPrefix, stack.isSecondary, None, None, available = false)

      try {
        val changeDetails = Await.ready(flexibleApi.changeDetails(stack, contentId), 3 seconds)
        changeDetails.map { cdOption =>
          destination.withApiStatus(cdOption, available = true)
        } recover {
          // if we fail to talk to the stack's API for any reason then provide a destination with available set to false
          case NonFatal(e) =>
            logger.warn(s"Couldn't communicate with Flexible stack at ${stack.apiPrefix}", e)
            destination
        }
      } catch {
        case e:TimeoutException => Future.successful(destination)
      }
    }
    Future.sequence(destinations).map(d => Ok(Json.toJson(d)))
  }