package uk.org.floop.msc.rest import net.liftweb.http._ import net.liftweb.util._ import uk.org.floop.msc.rrd._ object Graph { def apply(args: List[String]): Can[ResponseIt] = { args match { case arg1 :: arg2 :: Nil => { val timePeriod = arg1 match { case "hour" => Some(TimePeriod.HOUR) case "day" => Some(TimePeriod.DAY) case "week" => Some(TimePeriod.WEEK) case "month" => Some(TimePeriod.MONTH) case "year" => Some(TimePeriod.YEAR) case _ => None } timePeriod match { case Some(p) => DataStore !? GenerateGraph("/" + arg2 + ".xml", p) match { case Some(ImageGenerated(bytes)) => Full(Response(bytes, List(("Content-Type", "image/png")), Nil, 200)) case None => println("Unable to generate graph.") Empty } case _ => println("Unrecognised time period.") Empty } } case _ => println("Undefined graph type or period.") Empty } } }