Skip to content

Commit

Permalink
#1766 removed log error when wrong pattern type
Browse files Browse the repository at this point in the history
  • Loading branch information
rriclet committed Feb 23, 2021
1 parent 3fc35f8 commit 5ce17d1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ class PatternCtrl @Inject() (
inputPatterns
.sortBy(_.external_id.length) // sort to create sub-patterns after their parent
.foldLeft[JsArray](JsArray.empty) { (array, inputPattern) =>
val res = db.tryTransaction { implicit graph =>
createFromInput(inputPattern)
} match {
case Failure(e) =>
Json.obj("status" -> "Failure", "message" -> e.getMessage)
case Success(t) =>
Json.obj("status" -> "Success", "mitreId" -> t.patternId, "patternName" -> t.name)
}
array :+ res
array :+ db.tryTransaction { implicit graph =>
createFromInput(inputPattern).transform(
t => Success(Json.obj("status" -> "Success", "mitreId" -> t.patternId, "patternName" -> t.name)),
e => Success(Json.obj("status" -> "Failure", "message" -> e.getMessage))
)
}.get
}
} yield Results.Created(importedPatterns)
}
Expand Down

0 comments on commit 5ce17d1

Please sign in to comment.