@@ -17,6 +17,7 @@ package nl.nlportal.product.service
17
17
18
18
import com.fasterxml.jackson.databind.node.ObjectNode
19
19
import io.github.oshai.kotlinlogging.KotlinLogging
20
+ import nl.nlportal.commonground.authentication.AuthenticationMachtigingsDienstService
20
21
import nl.nlportal.commonground.authentication.CommonGroundAuthentication
21
22
import nl.nlportal.core.util.Mapper
22
23
import nl.nlportal.product.client.DmnClient
@@ -50,6 +51,7 @@ class ProductService(
50
51
val taakObjectConfig : TaakObjectConfig ,
51
52
val objectsApiTaskConfig : TaakObjectConfig ,
52
53
val dmnClient : DmnClient ,
54
+ val authenticationMachtigingsDienstService : AuthenticationMachtigingsDienstService ,
53
55
) {
54
56
suspend fun getProduct (
55
57
authentication : CommonGroundAuthentication ,
@@ -154,17 +156,30 @@ class ProductService(
154
156
return emptyList()
155
157
}
156
158
159
+ // val zaakTypes = mutableSetOf<UUID>()
160
+ val zaakTypes = productType.zaaktypen
157
161
val request =
158
162
zakenApiClient.zoeken()
159
163
.search()
160
164
.page(pageNumber)
161
165
.withAuthentication(authentication)
162
- .ofZaakTypes(productType.zaaktypen.map { it })
163
166
pageSize?.let { request.pageSize(it) }
164
167
isOpen?.let {
165
168
request.isOpen(isOpen)
166
169
}
167
170
171
+ /* authenticationMachtigingsDienstService.zaakTypes(authentication)?.let {
172
+ zaakTypes.addAll(it)
173
+ }*/
174
+
175
+ if (! authenticationMachtigingsDienstService.isAllowedZaakTypes(authentication, zaakTypes)) {
176
+ return emptyList()
177
+ }
178
+
179
+ if (zaakTypes.isNotEmpty()) {
180
+ request.ofZaakTypes(zaakTypes.toList())
181
+ }
182
+
168
183
authentication.getVestigingsNummer()?.let {
169
184
request.ofVestigingsNummer(it)
170
185
}
@@ -346,12 +361,16 @@ class ProductService(
346
361
pageSize : Int ,
347
362
): List <TaakV2 > {
348
363
val objectSearchParameters =
349
- listOf (
364
+ mutableListOf (
350
365
ObjectSearchParameter (" identificatie__type" , Comparator .EQUAL_TO , authentication.userType),
351
366
ObjectSearchParameter (" identificatie__value" , Comparator .EQUAL_TO , authentication.userId),
352
367
ObjectSearchParameter (" status" , Comparator .EQUAL_TO , " open" ),
353
368
)
354
369
370
+ authenticationMachtigingsDienstService.taakTypes(authentication)?.let {
371
+ objectSearchParameters.add(ObjectSearchParameter (" eigenaar" , Comparator .IN_LIST , it.joinToString(" |" )))
372
+ }
373
+
355
374
return getObjectsApiObjectResultPage<TaakObjectV2 >(
356
375
objectsApiTaskConfig.typeUrlV2,
357
376
objectSearchParameters,
@@ -442,4 +461,4 @@ class ProductService(
442
461
443
462
val logger = KotlinLogging .logger {}
444
463
}
445
- }
464
+ }
0 commit comments