From a03ac68329a2bde79093ef362de179b6f12a7ec5 Mon Sep 17 00:00:00 2001 From: Robin Riclet Date: Thu, 18 Feb 2021 17:41:37 +0100 Subject: [PATCH] #1766 removed log error when wrong pattern type --- .../thp/thehive/controllers/v1/PatternCtrl.scala | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala index 2d884a8e20..717ffb9d8d 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala @@ -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) }