From 507888a85d6aa93586e33ae038780cc8ad4654c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Thu, 2 May 2024 10:09:25 +0200 Subject: [PATCH] refactor: Move components to AdminModule (#3227) --- .../org/knora/webapi/core/LayersTest.scala | 9 +-------- .../service/KnoraUserToUserConverterSpec.scala | 18 +++++++++--------- .../org/knora/webapi/core/LayersLive.scala | 9 +-------- .../knora/webapi/slice/admin/AdminModule.scala | 6 +++++- .../slice/admin/domain/AdminDomainModule.scala | 6 +++++- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala b/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala index 983cec8a1d..8e2223db98 100644 --- a/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala +++ b/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala @@ -42,7 +42,6 @@ import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageService import org.knora.webapi.slice.admin.domain.service._ import org.knora.webapi.slice.common.api._ import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper -import org.knora.webapi.slice.infrastructure.CacheManager import org.knora.webapi.slice.infrastructure.JwtService import org.knora.webapi.slice.infrastructure.JwtServiceLive import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints @@ -87,26 +86,24 @@ object LayersTest { type CommonR = AdminApiEndpoints & + AdminModule.Provided & ApiRoutes & ApiV2Endpoints & AppRouter & AssetPermissionsResponder & Authenticator & AuthorizationRestService & - CacheManager & CardinalityHandler & ConstructResponseUtilV2 & DspIngestClient & GravsearchTypeInspectionRunner & GroupRestService & - GroupService & HttpServer & IIIFRequestMessageHandler & InferenceOptimizationService & InvalidTokenCache & IriConverter & JwtService & - KnoraUserToUserConverter & ListsResponder & ListsResponderV2 & MessageRelay & @@ -122,7 +119,6 @@ object LayersTest { ProjectExportStorageService & ProjectImportService & ProjectRestService & - ProjectService & QueryTraverser & RepositoryUpdater & ResourceUtilV2 & @@ -138,7 +134,6 @@ object LayersTest { TestClientService & TriplestoreService & UserRestService & - UserService & ValuesResponderV2 private val commonLayersForAllIntegrationTests = @@ -167,7 +162,6 @@ object LayersTest { IriService.layer, JwtServiceLive.layer, KnoraResponseRenderer.layer, - KnoraUserToUserConverter.layer, ListsResponder.layer, ListsResponderV2.layer, ManagementEndpoints.layer, @@ -202,7 +196,6 @@ object LayersTest { TapirToPekkoInterpreter.layer, TestClientService.layer, TriplestoreServiceLive.layer, - UserService.layer, ValuesResponderV2Live.layer, ) diff --git a/integration/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraUserToUserConverterSpec.scala b/integration/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraUserToUserConverterSpec.scala index 20496a1b25..a6c10f6623 100644 --- a/integration/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraUserToUserConverterSpec.scala +++ b/integration/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraUserToUserConverterSpec.scala @@ -50,7 +50,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { isInProjectAdminGroup.map(ProjectIri.unsafeFrom).toChunk, ) - private val KnoraUserToUserConverter = ZIO.serviceWithZIO[KnoraUserToUserConverter] + private val knoraUserToUserConverter = ZIO.serviceWithZIO[KnoraUserToUserConverter] override def e2eSpec = suite("KnoraUserToUserConverter, given a KnoraUser")( @@ -62,7 +62,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk.empty, ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.rootUser.permissionData) }, test("return the permissions profile (multi group user)") { @@ -73,7 +73,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk(SharedTestDataADM.incunabulaProjectIri, imagesProjectIri), ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.multiuserUser.permissionData) }, test("return the permissions profile (incunabula project admin user)") { @@ -85,7 +85,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk(SharedTestDataADM.incunabulaProjectIri), ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.incunabulaProjectAdminUser.permissionData) }, test("return the permissions profile (incunabula creator user)") { @@ -97,7 +97,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk.empty, ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.incunabulaCreatorUser.permissionData) }, test("return the permissions profile (incunabula normal project member user)") { @@ -107,7 +107,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { SystemAdmin.IsNotSystemAdmin, Chunk.empty, ) - for { actual <- KnoraUserToUserConverter(_.toUser(user)) } yield assertTrue( + for { actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue( actual.permissions == SharedTestDataADM2.incunabulaMemberUser.permissionData, ) }, @@ -120,7 +120,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk(imagesProjectIri), ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.imagesUser01.permissionData) }, test("return the permissions profile (images-reviewer-user)") { @@ -131,7 +131,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { Chunk.empty, ) for { - actual <- KnoraUserToUserConverter(_.toUser(user)) + actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(actual.permissions == SharedTestDataADM2.imagesReviewerUser.permissionData) }, test("return the permissions profile (anything user 01)") { @@ -141,7 +141,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec { SystemAdmin.IsNotSystemAdmin, Chunk.empty, ) - for { actual <- KnoraUserToUserConverter(_.toUser(user)) } yield assertTrue( + for { actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue( actual.permissions == SharedTestDataADM2.anythingUser1.permissionData, ) }, diff --git a/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala b/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala index b662716ff3..a8542a5e03 100644 --- a/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala +++ b/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala @@ -40,7 +40,6 @@ import org.knora.webapi.slice.admin.api.service.UserRestService import org.knora.webapi.slice.admin.domain.service._ import org.knora.webapi.slice.common.api._ import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper -import org.knora.webapi.slice.infrastructure.CacheManager import org.knora.webapi.slice.infrastructure.JwtService import org.knora.webapi.slice.infrastructure.JwtServiceLive import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints @@ -72,6 +71,7 @@ object LayersLive { type DspEnvironmentLive = ActorSystem & AdminApiEndpoints & + AdminModule.Provided & ApiRoutes & ApiV2Endpoints & AppConfigurations & @@ -79,12 +79,10 @@ object LayersLive { AssetPermissionsResponder & Authenticator & AuthorizationRestService & - CacheManager & CardinalityHandler & ConstructResponseUtilV2 & GravsearchTypeInspectionRunner & GroupRestService & - GroupService & HttpServer & IIIFRequestMessageHandler & InferenceOptimizationService & @@ -92,7 +90,6 @@ object LayersLive { InvalidTokenCache & IriConverter & JwtService & - KnoraUserToUserConverter & ListsResponder & ListsResponderV2 & MessageRelay & @@ -107,7 +104,6 @@ object LayersLive { ProjectExportStorageService & ProjectImportService & ProjectRestService & - ProjectService & QueryTraverser & RepositoryUpdater & ResourceUtilV2 & @@ -123,7 +119,6 @@ object LayersLive { StringFormatter & TriplestoreService & UserRestService & - UserService & ValuesResponderV2 /** @@ -156,7 +151,6 @@ object LayersLive { IriService.layer, JwtServiceLive.layer, KnoraResponseRenderer.layer, - KnoraUserToUserConverter.layer, ListsResponder.layer, ListsResponderV2.layer, ManagementEndpoints.layer, @@ -190,7 +184,6 @@ object LayersLive { StringFormatter.live, TapirToPekkoInterpreter.layer, TriplestoreServiceLive.layer, - UserService.layer, ValuesResponderV2Live.layer, org.knora.webapi.core.ActorSystem.layer, ) diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala index 92e6e0a909..b480c4c89f 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala @@ -18,7 +18,11 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService object AdminModule { type Dependencies = - AppConfig & IriService & OntologyRepo & PredicateObjectMapper & TriplestoreService + AppConfig & + IriService & + OntologyRepo & + PredicateObjectMapper & + TriplestoreService type Provided = AdminDomainModule.Provided diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala index 4f2d01d213..0e3b25e824 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala @@ -37,9 +37,11 @@ object AdminDomainModule { KnoraGroupService & KnoraProjectService & KnoraUserService & + KnoraUserToUserConverter & MaintenanceService & PasswordService & - ProjectService + ProjectService & + UserService val layer = ZLayer.makeSome[Dependencies, Provided]( AdministrativePermissionService.layer, @@ -47,8 +49,10 @@ object AdminDomainModule { KnoraGroupService.layer, KnoraProjectService.layer, KnoraUserService.layer, + KnoraUserToUserConverter.layer, MaintenanceService.layer, PasswordService.layer, ProjectService.layer, + UserService.layer, ) }