def fromXml()

in app/models/FCInfo.scala [36:59]


  def fromXml(xml:NodeSeq):Either[String,FCInfo] = try {
    val domains = xml.head.child.map({
      case e: Elem =>
        if(e.label.startsWith("Domain")){
          Some(FCDomain.fromXml(e))
        } else {
          None
        }
      case _=>
        None
    }).collect({
      case Some(dom)=>dom
    })

    val failedDoms = domains.collect({case Left(err)=>err})
    if(failedDoms.nonEmpty){
      Left(s"Could not parse FC domains: $failedDoms")
    } else {
      Right(new FCInfo(domains.collect({case Right(dom)=>dom}), xml \@"Product"))
    }
  } catch {
    case ex:Throwable=>
      Left(ex.toString)
  }