Actions
Architecture #16603
closedClarify code of rollback events parsing
Status:
Released
Priority:
N/A
Assignee:
Category:
Architecture - Code maintenance
Target version:
Fix check:
Checked
Regression:
Description
Something is fishy in parsing of rollback events
def getRollbackDetails(xml:NodeSeq) : Box[RollbackInfo] = {
def getEvents(xml:NodeSeq)= {
for{
event <- xml
eventlogs <- event.child
entry <- eventlogs \ "rollbackedEvent"
id <- (entry \ "id").headOption.map(_.text.toInt) ?~! ("Entry type is not a 'rollback': %s".format(entry))
evtType <-(entry \ "type").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
author <-(entry \ "author").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
date <-(entry \ "date").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
} yield {
RollbackedEvent(id,date,evtType,author)
}
}
val rollbackInfo = for{
event <- xml
eventlogs <- event.child
entry <- (eventlogs \ "main").headOption
id <- (entry \ "id").headOption.map(_.text.toInt) ?~! ("Entry type is not a 'rollback': %s".format(entry))
evtType <- (entry \ "type").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
author <- (entry \ "author").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
date <- (entry \ "date").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
rollbackType <- (entry \ "rollbackType").headOption.map(_.text) ?~! ("Entry type is not a 'rollback': %s".format(entry))
} yield {
val target = RollbackedEvent(id,date,evtType,author)
RollbackInfo(target,rollbackType,getEvents(xml))
}
rollbackInfo.headOption
}
rollbackinfo is a Seq, that we take head, andwe implictly convert to box, it should directlybe a box
getEvents should be a Box[Seq[RollbackedEvents]]
moreover, identation is broken, and error message useless
Actions