diff --git a/thehive/app/org/thp/thehive/IndexCleanup.scala b/thehive/app/org/thp/thehive/IndexCleanup.scala deleted file mode 100644 index b28a700b0b..0000000000 --- a/thehive/app/org/thp/thehive/IndexCleanup.scala +++ /dev/null @@ -1,43 +0,0 @@ -package org.thp.thehive - -import org.apache.tinkerpop.gremlin.structure.{Direction, Property} -import org.janusgraph.core.JanusGraph -import org.janusgraph.core.schema.{JanusGraphManagement, Parameter} -import org.janusgraph.graphdb.database.StandardJanusGraph -import org.janusgraph.graphdb.database.management.ManagementSystem -import org.janusgraph.graphdb.internal.JanusGraphSchemaCategory -import org.janusgraph.graphdb.types.TypeDefinitionDescription -import org.janusgraph.graphdb.types.system.BaseLabel -import org.thp.scalligraph.janus.JanusDatabase - -import scala.jdk.CollectionConverters._ - -class IndexCleanup(db: JanusDatabase) { - def propertyStr[A](property: Property[A]): String = { - val p = property.asInstanceOf[Property[TypeDefinitionDescription]] - def modStr(modifier: Any): String = - modifier match { - case a: Array[_] => a.map(modStr).mkString("[", ",", "]") - case p: Parameter[_] => s"${p.key()}=${p.value()}" - case _ => modifier.toString - } - s"${p.key}=${p.value.getCategory}:${modStr(p.value.getModifier)}" - } - - db.managementTransaction { mgmt => - val tx = mgmt.asInstanceOf[ManagementSystem].getWrappedTx - val indexVertex = tx.getSchemaVertex(JanusGraphSchemaCategory.GRAPHINDEX.getSchemaName("global")) - indexVertex.remove() - val edges = tx - .query(indexVertex) - .`type`(BaseLabel.SchemaDefinitionEdge) - .direction(Direction.BOTH) - .edges() - .asScala - edges - .map(e => e.edgeLabel() + ": " + e.properties().asScala.map(propertyStr).mkString("<", " - ", ">")) - .mkString("\n") - indexVertex.remove() - ??? - } -} diff --git a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala index 4e26cf9682..54875b75c6 100644 --- a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala +++ b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala @@ -110,7 +110,7 @@ class IntegrityCheckActor() extends Actor { def duplicationCheck(name: String): Map[String, Long] = { val startDate = System.currentTimeMillis() - val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.duplicationCheck()) + val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.duplicationCheck().mapValues(_.toLong)) val endDate = System.currentTimeMillis() result + ("startDate" -> startDate) + ("endDate" -> endDate) + ("duration" -> (endDate - startDate)) } @@ -137,7 +137,7 @@ class IntegrityCheckActor() extends Actor { .scheduleWithFixedDelay(initialDelay, interval) { () => logger.debug(s"Global check of ${integrityCheck.name}") val startDate = System.currentTimeMillis() - val result = integrityCheck.globalCheck() + val result = integrityCheck.globalCheck().mapValues(_.toLong) val duration = System.currentTimeMillis() - startDate self ! GlobalCheckResult(integrityCheck.name, result + ("duration" -> duration)) } @@ -159,7 +159,7 @@ class IntegrityCheckActor() extends Actor { .scheduleWithFixedDelay(initialDelay, interval) { () => logger.debug(s"Global check of ${integrityCheck.name}") val startDate = System.currentTimeMillis() - val result = integrityCheckMap.get(integrityCheck.name).fold(Map("checkNotFound" -> 1L))(_.globalCheck()) + val result = integrityCheckMap.get(integrityCheck.name).fold(Map("checkNotFound" -> 1L))(_.globalCheck().mapValues(_.toLong)) val duration = System.currentTimeMillis() - startDate self ! GlobalCheckResult(integrityCheck.name, result + ("duration" -> duration)) } @@ -187,7 +187,7 @@ class IntegrityCheckActor() extends Actor { Future { logger.debug(s"Duplication check of $name") val startDate = System.currentTimeMillis() - val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.duplicationCheck()) + val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.duplicationCheck().mapValues(_.toLong)) val duration = System.currentTimeMillis() - startDate self ! DuplicationCheckResult(name, result + ("duration" -> duration)) }(checkExecutionContext) @@ -211,7 +211,7 @@ class IntegrityCheckActor() extends Actor { Future { logger.debug(s"Global check of $name") val startDate = System.currentTimeMillis() - val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.globalCheck()) + val result = integrityCheckMap.get(name).fold(Map("checkNotFound" -> 1L))(_.globalCheck().mapValues(_.toLong)) val duration = System.currentTimeMillis() - startDate self ! GlobalCheckResult(name, result + ("duration" -> duration)) }(checkExecutionContext)