diff --git a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
index 9f73e4b0bc..56a930f86c 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
@@ -381,12 +381,12 @@ class PublicAlert @Inject() (
"getAlert",
(idOrName, graph, authContext) => alertSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[Alert], IteratorOutput](
"page",
(range, alertSteps, _) =>
alertSteps
- .richPage(range.from, range.to, withTotal = true) { alerts =>
+ .richPage(range.from, range.to, withTotal = true, limitedCountThreshold) { alerts =>
alerts.project(_.by(_.richAlert).by(_.observables.richObservable.fold))
}
)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala
index 1062143f3e..05d6a83d32 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala
@@ -75,10 +75,10 @@ class PublicAudit @Inject() (auditSrv: AuditSrv, organisationSrv: OrganisationSr
override val initialQuery: Query =
Query.init[Traversal.V[Audit]]("listAudit", (graph, authContext) => auditSrv.startTraversal(graph).visible(organisationSrv)(authContext))
- override val pageQuery: ParamQuery[org.thp.thehive.controllers.v0.OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[org.thp.thehive.controllers.v0.OutputParam] =
Query.withParam[OutputParam, Traversal.V[Audit], IteratorOutput](
"page",
- (range, auditSteps, _) => auditSteps.richPage(range.from, range.to, withTotal = true)(_.richAudit)
+ (range, auditSteps, _) => auditSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(_.richAudit)
)
override val outputQuery: Query = Query.output[RichAudit, Traversal.V[Audit]](_.richAudit)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala
index ed3cd16585..b31d81f81b 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala
@@ -195,13 +195,13 @@ class PublicCase @Inject() (
"getCase",
(idOrName, graph, authContext) => caseSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[Case], IteratorOutput](
"page",
{
case (OutputParam(from, to, withStats, _), caseSteps, authContext) =>
caseSteps
- .richPage(from, to, withTotal = true) {
+ .richPage(from, to, withTotal = true, limitedCountThreshold) {
case c if withStats =>
c.richCaseWithCustomRenderer(caseStatsRenderer(authContext))(authContext)
case c =>
diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala
index 832b808f56..706cf37f29 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala
@@ -104,10 +104,11 @@ class PublicCaseTemplate @Inject() (
"getCaseTemplate",
(idOrName, graph, authContext) => caseTemplateSrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[CaseTemplate], IteratorOutput](
- "page",
- (range, caseTemplateSteps, _) => caseTemplateSteps.richPage(range.from, range.to, withTotal = true)(_.richCaseTemplate)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[CaseTemplate], IteratorOutput](
+ "page",
+ (range, caseTemplateSteps, _) => caseTemplateSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(_.richCaseTemplate)
+ )
override val outputQuery: Query = Query.output[RichCaseTemplate, Traversal.V[CaseTemplate]](_.richCaseTemplate)
override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query[Traversal.V[CaseTemplate], Traversal.V[Task]]("tasks", (caseTemplateSteps, _) => caseTemplateSteps.tasks)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala
index 6ff80b0a9c..7efc43df94 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala
@@ -90,13 +90,14 @@ class CustomFieldCtrl @Inject() (
class PublicCustomField @Inject() (customFieldSrv: CustomFieldSrv) extends PublicData {
override val entityName: String = "CustomField"
override val initialQuery: Query = Query.init[Traversal.V[CustomField]]("listCustomField", (graph, _) => customFieldSrv.startTraversal(graph))
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[CustomField], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, _, _), customFieldSteps, _) =>
- customFieldSteps.page(from, to, withTotal = true)
- }
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[CustomField], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, _, _), customFieldSteps, _) =>
+ customFieldSteps.page(from, to, withTotal = true, limitedCountThreshold)
+ }
+ )
override val outputQuery: Query = Query.output[CustomField with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[CustomField]](
"getCustomField",
diff --git a/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala
index 8e0289c44d..627932169a 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala
@@ -105,10 +105,12 @@ class PublicDashboard @Inject() (
(idOrName, graph, authContext) => dashboardSrv.get(idOrName)(graph).visible(authContext)
)
- val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Dashboard], IteratorOutput](
- "page",
- (range, dashboardSteps, authContext) => dashboardSteps.richPage(range.from, range.to, withTotal = true)(_.richDashboard(authContext))
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Dashboard], IteratorOutput](
+ "page",
+ (range, dashboardSteps, authContext) =>
+ dashboardSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(_.richDashboard(authContext))
+ )
override val outputQuery: Query = Query.outputWithContext[RichDashboard, Traversal.V[Dashboard]](_.richDashboard(_))
val publicProperties: PublicProperties = PublicPropertyListBuilder[Dashboard]
.property("title", UMapping.string)(_.field.updatable)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala
index d15aa34020..8f641a9b68 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala
@@ -81,21 +81,22 @@ class PublicLog @Inject() (logSrv: LogSrv, organisationSrv: OrganisationSrv) ext
"getLog",
(idOrName, graph, authContext) => logSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Log], IteratorOutput](
- "page",
- {
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Log], IteratorOutput](
+ "page",
+ {
- case (OutputParam(from, to, _, 0), logSteps, _) => logSteps.richPage(from, to, withTotal = true)(_.richLog)
- case (OutputParam(from, to, _, _), logSteps, authContext) =>
- logSteps.richPage(from, to, withTotal = true)(
- _.richLogWithCustomRenderer(
- _.task.richTaskWithCustomRenderer(
- _.`case`.richCase(authContext).option
+ case (OutputParam(from, to, _, 0), logSteps, _) => logSteps.richPage(from, to, withTotal = true, limitedCountThreshold)(_.richLog)
+ case (OutputParam(from, to, _, _), logSteps, authContext) =>
+ logSteps.richPage(from, to, withTotal = true, limitedCountThreshold)(
+ _.richLogWithCustomRenderer(
+ _.task.richTaskWithCustomRenderer(
+ _.`case`.richCase(authContext).option
+ )
)
)
- )
- }
- )
+ }
+ )
override val outputQuery: Query = Query.output[RichLog, Traversal.V[Log]](_.richLog)
override val publicProperties: PublicProperties =
diff --git a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala
index 26b6257dda..0ef5aceb1d 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala
@@ -372,13 +372,13 @@ class PublicObservable @Inject() (
"getObservable",
(idOrName, graph, authContext) => observableSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[Observable], IteratorOutput](
"page",
{
case (OutputParam(from, to, withStats, 0), observableSteps, authContext) =>
observableSteps
- .richPage(from, to, withTotal = true) {
+ .richPage(from, to, withTotal = true, limitedCountThreshold) {
case o if withStats =>
o.richObservableWithCustomRenderer(organisationSrv, observableStatsRenderer(organisationSrv)(authContext))(authContext)
.domainMap(ros => (ros._1, ros._2, None: Option[Either[RichCase, RichAlert]]))
@@ -386,7 +386,7 @@ class PublicObservable @Inject() (
o.richObservable.domainMap(ro => (ro, JsObject.empty, None))
}
case (OutputParam(from, to, _, _), observableSteps, authContext) =>
- observableSteps.richPage(from, to, withTotal = true)(
+ observableSteps.richPage(from, to, withTotal = true, limitedCountThreshold)(
_.richObservableWithCustomRenderer(
organisationSrv,
o => o.project(_.by(_.`case`.richCase(authContext).option).by(_.alert.richAlert.option))
diff --git a/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala
index 942027274d..2cc0285682 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala
@@ -52,10 +52,10 @@ class PublicObservableType @Inject() (observableTypeSrv: ObservableTypeSrv) exte
override val entityName: String = "ObservableType"
override val initialQuery: Query =
Query.init[Traversal.V[ObservableType]]("listObservableType", (graph, _) => observableTypeSrv.startTraversal(graph))
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[ObservableType], IteratorOutput](
"page",
- (range, observableTypeSteps, _) => observableTypeSteps.richPage(range.from, range.to, withTotal = true)(identity)
+ (range, observableTypeSteps, _) => observableTypeSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(identity)
)
override val outputQuery: Query = Query.output[ObservableType with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[ObservableType]](
diff --git a/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala
index 3ddfa951f2..ca0dcc9435 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala
@@ -131,10 +131,11 @@ class PublicOrganisation @Inject() (organisationSrv: OrganisationSrv) extends Pu
override val initialQuery: Query =
Query.init[Traversal.V[Organisation]]("listOrganisation", (graph, authContext) => organisationSrv.startTraversal(graph).visible(authContext))
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Organisation], IteratorOutput](
- "page",
- (range, organisationSteps, _) => organisationSteps.page(range.from, range.to, withTotal = true)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Organisation], IteratorOutput](
+ "page",
+ (range, organisationSteps, _) => organisationSteps.page(range.from, range.to, withTotal = true, limitedCountThreshold)
+ )
override val outputQuery: Query = Query.output[Organisation with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Organisation]](
"getOrganisation",
diff --git a/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala
index c8485a390a..319ce2c86a 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala
@@ -76,10 +76,11 @@ class PublicPage @Inject() (pageSrv: PageSrv, organisationSrv: OrganisationSrv)
"getPage",
(idOrName, graph, authContext) => pageSrv.get(idOrName)(graph).visible(authContext)
)
- val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Page], IteratorOutput](
- "page",
- (range, pageSteps, _) => pageSteps.page(range.from, range.to, withTotal = true)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Page], IteratorOutput](
+ "page",
+ (range, pageSteps, _) => pageSteps.page(range.from, range.to, withTotal = true, limitedCountThreshold)
+ )
override val outputQuery: Query = Query.output[Page with Entity]
override val publicProperties: PublicProperties = PublicPropertyListBuilder[Page]
.property("title", UMapping.string)(_.field.updatable)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala
index 5a7d98d8af..0bd0135c69 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala
@@ -80,10 +80,11 @@ class PublicProfile @Inject() (profileSrv: ProfileSrv) extends PublicData {
val initialQuery: Query =
Query.init[Traversal.V[Profile]]("listProfile", (graph, _) => profileSrv.startTraversal(graph))
- val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Profile], IteratorOutput](
- "page",
- (range, profileSteps, _) => profileSteps.page(range.from, range.to, withTotal = true)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Profile], IteratorOutput](
+ "page",
+ (range, profileSteps, _) => profileSteps.page(range.from, range.to, withTotal = true, limitedCountThreshold)
+ )
override val outputQuery: Query = Query.output[Profile with Entity]
val publicProperties: PublicProperties = PublicPropertyListBuilder[Profile]
.property("name", UMapping.string)(_.field.updatable)
diff --git a/thehive/app/org/thp/thehive/controllers/v0/QueryCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/QueryCtrl.scala
index 936be7426d..2c67065ef8 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/QueryCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/QueryCtrl.scala
@@ -21,7 +21,7 @@ trait PublicData {
val entityName: String
val publicProperties: PublicProperties
val initialQuery: Query
- val pageQuery: ParamQuery[OutputParam]
+ def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam]
val outputQuery: Query
val getQuery: ParamQuery[EntityIdOrName]
val extraQueries: Seq[ParamQuery[_]] = Nil
@@ -105,7 +105,7 @@ trait QueryCtrl {
inputSort <- sortParser(field.get("sort"))
sortedQuery = filteredQuery andThen new SortQuery(queryExecutor.publicProperties).toQuery(inputSort)
outputParam <- outputParamParser.optional(field).map(_.getOrElse(OutputParam(0, 10, withStats = false, withParents = 0)))
- outputQuery = publicData.pageQuery.toQuery(outputParam)
+ outputQuery = publicData.pageQuery(queryExecutor.limitedCountThreshold).toQuery(outputParam)
} yield sortedQuery andThen outputQuery
}
diff --git a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
index 2f0cff7889..71220d4ec2 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
@@ -43,10 +43,11 @@ class PublicTag @Inject() (tagSrv: TagSrv, organisationSrv: OrganisationSrv) ext
override val entityName: String = "tag"
override val initialQuery: Query =
Query.init[Traversal.V[Tag]]("listTag", (graph, authContext) => tagSrv.startTraversal(graph).visible(authContext))
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Tag], IteratorOutput](
- "page",
- (range, tagSteps, _) => tagSteps.page(range.from, range.to, withTotal = true)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Tag], IteratorOutput](
+ "page",
+ (range, tagSteps, _) => tagSteps.page(range.from, range.to, withTotal = true, limitedCountThreshold)
+ )
override val outputQuery: Query = Query.output[Tag with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Tag]](
"getTag",
diff --git a/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala
index ee76571452..b75748a4dd 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala
@@ -102,19 +102,20 @@ class PublicTask @Inject() (taskSrv: TaskSrv, organisationSrv: OrganisationSrv,
(graph, authContext) => taskSrv.startTraversal(graph).visible(organisationSrv)(authContext)
)
//organisationSrv.get(authContext.organisation)(graph).shares.tasks)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Task], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, _, 0), taskSteps, _) =>
- taskSteps.richPage(from, to, withTotal = true)(_.richTask.domainMap(_ -> (None: Option[RichCase])))
- case (OutputParam(from, to, _, _), taskSteps, authContext) =>
- taskSteps.richPage(from, to, withTotal = true)(
- _.richTaskWithCustomRenderer(
- _.`case`.richCase(authContext).domainMap(c => Some(c): Option[RichCase])
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Task], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, _, 0), taskSteps, _) =>
+ taskSteps.richPage(from, to, withTotal = true, limitedCountThreshold)(_.richTask.domainMap(_ -> (None: Option[RichCase])))
+ case (OutputParam(from, to, _, _), taskSteps, authContext) =>
+ taskSteps.richPage(from, to, withTotal = true, limitedCountThreshold)(
+ _.richTaskWithCustomRenderer(
+ _.`case`.richCase(authContext).domainMap(c => Some(c): Option[RichCase])
+ )
)
- )
- }
- )
+ }
+ )
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Task]](
"getTask",
(idOrName, graph, authContext) => taskSrv.get(idOrName)(graph).inOrganisation(organisationSrv.currentId(graph, authContext))
diff --git a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala
index 2c4e1b2c5c..9969b348ee 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala
@@ -101,7 +101,7 @@ class TheHiveQueryExecutor @Inject() (
override lazy val queries: Seq[ParamQuery[_]] =
publicDatas.map(_.initialQuery) ++
publicDatas.map(_.getQuery) ++
- publicDatas.map(_.pageQuery) ++
+ publicDatas.map(_.pageQuery(limitedCountThreshold)) ++ // FIXME the value of limitedCountThreshold is read only once. The value is not updated.
publicDatas.map(_.outputQuery) ++
publicDatas.flatMap(_.extraQueries)
override val version: (Int, Int) = 0 -> 0
diff --git a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala
index 3a8483ffdf..b596985a57 100644
--- a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala
@@ -235,10 +235,11 @@ class PublicUser @Inject() (userSrv: UserSrv, organisationSrv: OrganisationSrv)
"getUser",
(idOrName, graph, authContext) => userSrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[User], IteratorOutput](
- "page",
- (range, userSteps, authContext) => userSteps.richUser(authContext).page(range.from, range.to, withTotal = true)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[User], IteratorOutput](
+ "page",
+ (range, userSteps, authContext) => userSteps.richUser(authContext).page(range.from, range.to, withTotal = true, limitedCountThreshold)
+ )
override val outputQuery: Query =
Query.outputWithContext[RichUser, Traversal.V[User]]((userSteps, authContext) => userSteps.richUser(authContext))
override val extraQueries: Seq[ParamQuery[_]] = Seq()
diff --git a/thehive/app/org/thp/thehive/controllers/v1/AlertCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/AlertCtrl.scala
index 968af3f663..901aacdab7 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/AlertCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/AlertCtrl.scala
@@ -44,14 +44,15 @@ class AlertCtrl @Inject() (
"getAlert",
(idOrName, graph, authContext) => alertSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Alert], IteratorOutput](
- "page",
- (range, alertSteps, authContext) =>
- alertSteps
- .richPage(range.from, range.to, range.extraData.contains("total"))(
- _.richAlertWithCustomRenderer(alertStatsRenderer(organisationSrv, range.extraData)(authContext))
- )
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Alert], IteratorOutput](
+ "page",
+ (range, alertSteps, authContext) =>
+ alertSteps
+ .richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(
+ _.richAlertWithCustomRenderer(alertStatsRenderer(organisationSrv, range.extraData)(authContext))
+ )
+ )
override val outputQuery: Query = Query.output[RichAlert, Traversal.V[Alert]](_.richAlert)
val caseProperties: PublicProperties = properties.`case` ++ properties.metaProperties
implicit val caseFilterParser: FieldsParser[Option[InputQuery[Traversal.Unk, Traversal.Unk]]] =
diff --git a/thehive/app/org/thp/thehive/controllers/v1/AuditCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/AuditCtrl.scala
index 9d389a7720..8b2b619d0a 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/AuditCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/AuditCtrl.scala
@@ -35,10 +35,10 @@ class AuditCtrl @Inject() (
(idOrName, graph, authContext) => auditSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[Audit], IteratorOutput](
"page",
- (range, auditSteps, _) => auditSteps.richPage(range.from, range.to, range.extraData.contains("total"))(_.richAudit)
+ (range, auditSteps, _) => auditSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(_.richAudit)
)
override val outputQuery: Query = Query.output[RichAudit, Traversal.V[Audit]](_.richAudit)
diff --git a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
index a1c4a292b4..8a16af3b6f 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
@@ -53,15 +53,16 @@ class CaseCtrl @Inject() (
"getCase",
(idOrName, graph, authContext) => caseSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Case], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, extraData), caseSteps, authContext) =>
- caseSteps.richPage(from, to, extraData.contains("total")) {
- _.richCaseWithCustomRenderer(caseStatsRenderer(extraData - "total")(authContext))(authContext)
- }
- }
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Case], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, extraData), caseSteps, authContext) =>
+ caseSteps.richPage(from, to, extraData.contains("total"), limitedCountThreshold) {
+ _.richCaseWithCustomRenderer(caseStatsRenderer(extraData - "total")(authContext))(authContext)
+ }
+ }
+ )
override val outputQuery: Query = Query.outputWithContext[RichCase, Traversal.V[Case]]((caseSteps, authContext) => caseSteps.richCase(authContext))
override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query.init[Long](
diff --git a/thehive/app/org/thp/thehive/controllers/v1/CaseTemplateCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CaseTemplateCtrl.scala
index 3e78ea966f..942a241cce 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/CaseTemplateCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/CaseTemplateCtrl.scala
@@ -35,10 +35,12 @@ class CaseTemplateCtrl @Inject() (
"getCaseTemplate",
(idOrName, graph, authContext) => caseTemplateSrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[CaseTemplate], IteratorOutput](
- "page",
- (range, caseTemplateSteps, _) => caseTemplateSteps.richPage(range.from, range.to, range.extraData.contains("total"))(_.richCaseTemplate)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[CaseTemplate], IteratorOutput](
+ "page",
+ (range, caseTemplateSteps, _) =>
+ caseTemplateSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(_.richCaseTemplate)
+ )
override val outputQuery: Query = Query.output[RichCaseTemplate, Traversal.V[CaseTemplate]](_.richCaseTemplate)
override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query[Traversal.V[CaseTemplate], Traversal.V[Task]]("tasks", (caseTemplateSteps, _) => caseTemplateSteps.tasks)
diff --git a/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala
index 344755ea12..33ee7b0ad0 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala
@@ -19,13 +19,14 @@ class CustomFieldCtrl @Inject() (entrypoint: Entrypoint, db: Database, customFie
override val entityName: String = "CustomField"
override val initialQuery: Query = Query.init[Traversal.V[CustomField]]("listCustomField", (graph, _) => customFieldSrv.startTraversal(graph))
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[CustomField], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, _), customFieldSteps, _) =>
- customFieldSteps.page(from, to, withTotal = true)
- }
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[CustomField], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, _), customFieldSteps, _) =>
+ customFieldSteps.page(from, to, withTotal = true, limitedCountThreshold)
+ }
+ )
override val outputQuery: Query = Query.output[CustomField with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[CustomField]](
"getCustomField",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/DashboardCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/DashboardCtrl.scala
index 3f358942bd..5d0e454734 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/DashboardCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/DashboardCtrl.scala
@@ -47,10 +47,12 @@ class DashboardCtrl @Inject() (
(idOrName, graph, authContext) => dashboardSrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Dashboard], IteratorOutput](
- "page",
- (range, dashboardSteps, authContext) => dashboardSteps.richPage(range.from, range.to, withTotal = true)(_.richDashboard(authContext))
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Dashboard], IteratorOutput](
+ "page",
+ (range, dashboardSteps, authContext) =>
+ dashboardSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(_.richDashboard(authContext))
+ )
override val outputQuery: Query = Query.outputWithContext[RichDashboard, Traversal.V[Dashboard]](_.richDashboard(_))
def create: Action[AnyContent] =
diff --git a/thehive/app/org/thp/thehive/controllers/v1/LogCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/LogCtrl.scala
index 7679720d7e..ca8d7c882d 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/LogCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/LogCtrl.scala
@@ -36,13 +36,14 @@ class LogCtrl @Inject() (
"getLog",
(idOrName, graph, authContext) => logSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Log], IteratorOutput](
- "page",
- (range, logSteps, authContext) =>
- logSteps.richPage(range.from, range.to, range.extraData.contains("total"))(
- _.richLogWithCustomRenderer(logStatsRenderer(range.extraData - "total")(authContext))
- )
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Log], IteratorOutput](
+ "page",
+ (range, logSteps, authContext) =>
+ logSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(
+ _.richLogWithCustomRenderer(logStatsRenderer(range.extraData - "total")(authContext))
+ )
+ )
override val outputQuery: Query = Query.output[RichLog, Traversal.V[Log]](_.richLog)
def create(taskId: String): Action[AnyContent] =
diff --git a/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala
index a20098d721..3e822e74dd 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala
@@ -63,15 +63,18 @@ class ObservableCtrl @Inject() (
"getObservable",
(idOrName, graph, authContext) => observableSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Observable], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, extraData), observableSteps, authContext) =>
- observableSteps.richPage(from, to, extraData.contains("total")) {
- _.richObservableWithCustomRenderer(organisationSrv, observableStatsRenderer(organisationSrv, extraData - "total")(authContext))(authContext)
- }
- }
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Observable], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, extraData), observableSteps, authContext) =>
+ observableSteps.richPage(from, to, extraData.contains("total"), limitedCountThreshold) {
+ _.richObservableWithCustomRenderer(organisationSrv, observableStatsRenderer(organisationSrv, extraData - "total")(authContext))(
+ authContext
+ )
+ }
+ }
+ )
override val outputQuery: Query = Query.output[RichObservable, Traversal.V[Observable]](_.richObservable)
override val extraQueries: Seq[ParamQuery[_]] = Seq(
diff --git a/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala
index e88f7ad107..287d406ac4 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala
@@ -23,10 +23,10 @@ class ObservableTypeCtrl @Inject() (
override val entityName: String = "ObservableType"
override val initialQuery: Query =
Query.init[Traversal.V[ObservableType]]("listObservableType", (graph, _) => observableTypeSrv.startTraversal(graph))
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[ObservableType], IteratorOutput](
"page",
- (range, observableTypeSteps, _) => observableTypeSteps.richPage(range.from, range.to, withTotal = true)(identity)
+ (range, observableTypeSteps, _) => observableTypeSteps.richPage(range.from, range.to, withTotal = true, limitedCountThreshold)(identity)
)
override val outputQuery: Query = Query.output[ObservableType with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[ObservableType]](
diff --git a/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala
index 131402b763..6f52383e1a 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala
@@ -35,10 +35,12 @@ class OrganisationCtrl @Inject() (
.startTraversal(graph)
.visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Organisation], IteratorOutput](
- "page",
- (range, organisationSteps, _) => organisationSteps.richPage(range.from, range.to, range.extraData.contains("total"))(_.richOrganisation)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Organisation], IteratorOutput](
+ "page",
+ (range, organisationSteps, _) =>
+ organisationSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(_.richOrganisation)
+ )
override val outputQuery: Query = Query.output[RichOrganisation, Traversal.V[Organisation]](_.richOrganisation)
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Organisation]](
"getOrganisation",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala
index 03b1615796..9c6bf1ed15 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/PatternCtrl.scala
@@ -35,13 +35,16 @@ class PatternCtrl @Inject() (
patternSrv
.startTraversal(graph)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Pattern], IteratorOutput](
- "page",
- {
- case (OutputParam(from, to, extraData), patternSteps, _) =>
- patternSteps.richPage(from, to, extraData.contains("total"))(_.richPatternWithCustomRenderer(patternRenderer(extraData - "total")))
- }
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Pattern], IteratorOutput](
+ "page",
+ {
+ case (OutputParam(from, to, extraData), patternSteps, _) =>
+ patternSteps.richPage(from, to, extraData.contains("total"), limitedCountThreshold)(
+ _.richPatternWithCustomRenderer(patternRenderer(extraData - "total"))
+ )
+ }
+ )
override val outputQuery: Query = Query.output[RichPattern, Traversal.V[Pattern]](_.richPattern)
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Pattern]](
"getPattern",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/ProcedureCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ProcedureCtrl.scala
index 491bb636df..c522f4b582 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/ProcedureCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/ProcedureCtrl.scala
@@ -31,13 +31,14 @@ class ProcedureCtrl @Inject() (
procedureSrv
.startTraversal(graph)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Procedure], IteratorOutput](
- "page",
- (range, procedureSteps, _) =>
- procedureSteps.richPage(range.from, range.to, range.extraData.contains("total"))(
- _.richProcedureWithCustomRenderer(procedureStatsRenderer(range.extraData - "total"))
- )
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Procedure], IteratorOutput](
+ "page",
+ (range, procedureSteps, _) =>
+ procedureSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(
+ _.richProcedureWithCustomRenderer(procedureStatsRenderer(range.extraData - "total"))
+ )
+ )
override val outputQuery: Query = Query.output[RichProcedure, Traversal.V[Procedure]](_.richProcedure)
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Procedure]](
"getProcedure",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala
index 778074801d..87eb1c82b4 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala
@@ -34,10 +34,11 @@ class ProfileCtrl @Inject() (
val initialQuery: Query =
Query.init[Traversal.V[Profile]]("listProfile", (graph, _) => profileSrv.startTraversal(graph))
- val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Profile], IteratorOutput](
- "page",
- (range, profileSteps, _) => profileSteps.page(range.from, range.to, range.extraData.contains("total"))
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Profile], IteratorOutput](
+ "page",
+ (range, profileSteps, _) => profileSteps.page(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)
+ )
override val outputQuery: Query = Query.output[Profile with Entity]
def create: Action[AnyContent] =
diff --git a/thehive/app/org/thp/thehive/controllers/v1/QueryableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/QueryableCtrl.scala
index bc1a6833b8..e5afb41d66 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/QueryableCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/QueryableCtrl.scala
@@ -7,7 +7,7 @@ trait QueryableCtrl {
val entityName: String
val publicProperties: PublicProperties
val initialQuery: Query
- val pageQuery: ParamQuery[_]
+ def pageQuery(limitedCountThreshold: Long): ParamQuery[_]
val outputQuery: Query
val getQuery: ParamQuery[EntityIdOrName]
val extraQueries: Seq[ParamQuery[_]] = Nil
diff --git a/thehive/app/org/thp/thehive/controllers/v1/ShareCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ShareCtrl.scala
index afccb39d9a..80e54c98c1 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/ShareCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/ShareCtrl.scala
@@ -36,10 +36,11 @@ class ShareCtrl @Inject() (
override val publicProperties: PublicProperties = properties.share
override val initialQuery: Query =
Query.init[Traversal.V[Share]]("listShare", (graph, authContext) => organisationSrv.startTraversal(graph).visible(authContext).shares)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Share], IteratorOutput](
- "page",
- (range, shareSteps, _) => shareSteps.richPage(range.from, range.to, range.extraData.contains("total"))(_.richShare)
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Share], IteratorOutput](
+ "page",
+ (range, shareSteps, _) => shareSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(_.richShare)
+ )
override val outputQuery: Query = Query.outputWithContext[RichShare, Traversal.V[Share]]((shareSteps, _) => shareSteps.richShare)
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Share]](
"getShare",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/TagCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/TagCtrl.scala
index 5f0fa4698b..d387d7c681 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/TagCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/TagCtrl.scala
@@ -37,13 +37,14 @@ class TagCtrl @Inject() (
override val publicProperties: PublicProperties = properties.tag
override val initialQuery: Query =
Query.init[Traversal.V[Tag]]("listTag", (graph, authContext) => tagSrv.startTraversal(graph).visible(authContext))
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Tag], IteratorOutput](
- "page",
- (params, tagSteps, authContext) =>
- tagSteps.richPage(params.from, params.to, params.extraData.contains("total"))(
- _.withCustomRenderer(tagStatsRenderer(params.extraData - "total")(authContext))
- )
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Tag], IteratorOutput](
+ "page",
+ (params, tagSteps, authContext) =>
+ tagSteps.richPage(params.from, params.to, params.extraData.contains("total"), limitedCountThreshold)(
+ _.withCustomRenderer(tagStatsRenderer(params.extraData - "total")(authContext))
+ )
+ )
override val outputQuery: Query = Query.output[Tag with Entity]
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Tag]](
"getTag",
diff --git a/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala
index d2f19169f6..d66056d34a 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala
@@ -39,13 +39,14 @@ class TaskCtrl @Inject() (
(graph, authContext) => taskSrv.startTraversal(graph).visible(organisationSrv)(authContext)
// organisationSrv.get(authContext.organisation)(graph).shares.tasks)
)
- override val pageQuery: ParamQuery[OutputParam] = Query.withParam[OutputParam, Traversal.V[Task], IteratorOutput](
- "page",
- (range, taskSteps, authContext) =>
- taskSteps.richPage(range.from, range.to, range.extraData.contains("total"))(
- _.richTaskWithCustomRenderer(taskStatsRenderer(range.extraData)(authContext))
- )
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
+ Query.withParam[OutputParam, Traversal.V[Task], IteratorOutput](
+ "page",
+ (range, taskSteps, authContext) =>
+ taskSteps.richPage(range.from, range.to, range.extraData.contains("total"), limitedCountThreshold)(
+ _.richTaskWithCustomRenderer(taskStatsRenderer(range.extraData)(authContext))
+ )
+ )
override val getQuery: ParamQuery[EntityIdOrName] = Query.initWithParam[EntityIdOrName, Traversal.V[Task]](
"getTask",
(idOrName, graph, authContext) => taskSrv.get(idOrName)(graph).visible(organisationSrv)(authContext)
diff --git a/thehive/app/org/thp/thehive/controllers/v1/TaxonomyCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/TaxonomyCtrl.scala
index 0bc454d5f7..0d3249d34d 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/TaxonomyCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/TaxonomyCtrl.scala
@@ -39,12 +39,14 @@ class TaxonomyCtrl @Inject() (
"getTaxonomy",
(idOrName, graph, authContext) => taxonomySrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[OutputParam] =
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[OutputParam] =
Query.withParam[OutputParam, Traversal.V[Taxonomy], IteratorOutput](
"page",
{
case (OutputParam(from, to, extraData), taxoSteps, _) =>
- taxoSteps.richPage(from, to, extraData.contains("total"))(_.richTaxonomyWithCustomRenderer(taxoStatsRenderer(extraData - "total")))
+ taxoSteps.richPage(from, to, extraData.contains("total"), limitedCountThreshold)(
+ _.richTaxonomyWithCustomRenderer(taxoStatsRenderer(extraData - "total"))
+ )
}
)
override val outputQuery: Query =
diff --git a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala
index 0909c32dbc..a1c45e2df8 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala
@@ -82,7 +82,7 @@ class TheHiveQueryExecutor @Inject() (
override lazy val queries: Seq[ParamQuery[_]] =
controllers.map(_.initialQuery) ++
controllers.map(_.getQuery) ++
- controllers.map(_.pageQuery) ++
+ controllers.map(_.pageQuery(limitedCountThreshold)) ++ // FIXME the value of limitedCountThreshold is read only once. The value is not updated.
controllers.map(_.outputQuery) ++
controllers.flatMap(_.extraQueries)
}
diff --git a/thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
index f4eed475f9..deb05d1af2 100644
--- a/thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
+++ b/thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
@@ -50,14 +50,15 @@ class UserCtrl @Inject() (
(idOrName, graph, authContext) => userSrv.get(idOrName)(graph).visible(authContext)
)
- override val pageQuery: ParamQuery[UserOutputParam] = Query.withParam[UserOutputParam, Traversal.V[User], IteratorOutput](
- "page",
- (params, userSteps, authContext) =>
- params
- .organisation
- .fold(userSteps.richUser(authContext))(org => userSteps.richUser(authContext, EntityIdOrName(org)))
- .page(params.from, params.to, params.extraData.contains("total"))
- )
+ override def pageQuery(limitedCountThreshold: Long): ParamQuery[UserOutputParam] =
+ Query.withParam[UserOutputParam, Traversal.V[User], IteratorOutput](
+ "page",
+ (params, userSteps, authContext) =>
+ params
+ .organisation
+ .fold(userSteps.richUser(authContext))(org => userSteps.richUser(authContext, EntityIdOrName(org)))
+ .page(params.from, params.to, params.extraData.contains("total"), limitedCountThreshold)
+ )
override val outputQuery: Query =
Query.outputWithContext[RichUser, Traversal.V[User]]((userSteps, authContext) => userSteps.richUser(authContext))