From c6b1d623dc7abdceb1d8f201bfadb71408f959a8 Mon Sep 17 00:00:00 2001 From: Andreas Tschabuschnig Date: Mon, 15 Jan 2024 10:25:27 +0800 Subject: [PATCH] make mutableversionsrepo optional --- .../ocpi/toolkit/common/OcpiSelfRegisteringModuleServer.kt | 4 ++-- .../ocpi/toolkit/modules/credentials/CredentialsServer.kt | 4 ++-- .../ocpi/toolkit/modules/locations/LocationsCpoServer.kt | 4 ++-- .../ocpi/toolkit/modules/locations/LocationsEmspServer.kt | 4 ++-- .../izivia/ocpi/toolkit/modules/sessions/SessionsCpoServer.kt | 4 ++-- .../ocpi/toolkit/modules/sessions/SessionsEmspServer.kt | 4 ++-- .../com/izivia/ocpi/toolkit/modules/tokens/TokensCpoServer.kt | 4 ++-- .../izivia/ocpi/toolkit/modules/tokens/TokensEmspServer.kt | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/common/OcpiSelfRegisteringModuleServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/common/OcpiSelfRegisteringModuleServer.kt index c2c645af..a8e8c202 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/common/OcpiSelfRegisteringModuleServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/common/OcpiSelfRegisteringModuleServer.kt @@ -8,17 +8,17 @@ import com.izivia.ocpi.toolkit.modules.versions.repositories.MutableVersionsRepo import com.izivia.ocpi.toolkit.transport.TransportServer abstract class OcpiSelfRegisteringModuleServer( - private val versionsRepository: MutableVersionsRepository, private val ocpiVersion: VersionNumber, private val moduleID: ModuleID, private val interfaceRole: InterfaceRole, + private val versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiModuleServer(basePathOverride ?: "/${ocpiVersion.value}/${moduleID.name}") { protected abstract suspend fun doRegisterOn(transportServer: TransportServer) override suspend fun registerOn(transportServer: TransportServer) { - versionsRepository.addEndpoint( + versionsRepository?.addEndpoint( ocpiVersion, Endpoint( identifier = moduleID, diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/credentials/CredentialsServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/credentials/CredentialsServer.kt index 9ec55739..5d3a51d5 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/credentials/CredentialsServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/credentials/CredentialsServer.kt @@ -12,14 +12,14 @@ import com.izivia.ocpi.toolkit.transport.domain.HttpMethod class CredentialsServer( private val service: CredentialsServerService, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.credentials, // role irrelevant for module credentials, but docs suggest using SENDER interfaceRole = InterfaceRole.SENDER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsCpoServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsCpoServer.kt index e49faf09..43c8b2b3 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsCpoServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsCpoServer.kt @@ -13,13 +13,13 @@ import java.time.Instant class LocationsCpoServer( private val service: LocationsCpoInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.locations, interfaceRole = InterfaceRole.SENDER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsEmspServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsEmspServer.kt index dac3a2f9..a0a3f251 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsEmspServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/locations/LocationsEmspServer.kt @@ -14,13 +14,13 @@ import com.izivia.ocpi.toolkit.transport.domain.VariablePathSegment class LocationsEmspServer( private val service: LocationsEmspInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.locations, interfaceRole = InterfaceRole.RECEIVER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsCpoServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsCpoServer.kt index 799cee15..6dd8955a 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsCpoServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsCpoServer.kt @@ -16,13 +16,13 @@ import java.time.Instant class SessionsCpoServer( private val service: SessionsCpoInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.sessions, interfaceRole = InterfaceRole.SENDER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsEmspServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsEmspServer.kt index 745b5f4f..72180d6e 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsEmspServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/sessions/SessionsEmspServer.kt @@ -15,13 +15,13 @@ import com.izivia.ocpi.toolkit.transport.domain.VariablePathSegment class SessionsEmspServer( private val service: SessionsEmspInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.sessions, interfaceRole = InterfaceRole.RECEIVER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensCpoServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensCpoServer.kt index 3bb6aaee..8c75ac8d 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensCpoServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensCpoServer.kt @@ -16,13 +16,13 @@ import com.izivia.ocpi.toolkit.transport.domain.VariablePathSegment class TokensCpoServer( private val service: TokensCpoInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.tokens, interfaceRole = InterfaceRole.SENDER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) { diff --git a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensEmspServer.kt b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensEmspServer.kt index 6b9d461a..f13fd4f2 100644 --- a/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensEmspServer.kt +++ b/ocpi-toolkit-2.2.1/src/main/kotlin/com/izivia/ocpi/toolkit/modules/tokens/TokensEmspServer.kt @@ -17,13 +17,13 @@ import java.time.Instant class TokensEmspServer( private val service: TokensEmspInterface, - versionsRepository: MutableVersionsRepository, + versionsRepository: MutableVersionsRepository? = null, basePathOverride: String? = null ) : OcpiSelfRegisteringModuleServer( - versionsRepository = versionsRepository, ocpiVersion = VersionNumber.V2_2_1, moduleID = ModuleID.tokens, interfaceRole = InterfaceRole.RECEIVER, + versionsRepository = versionsRepository, basePathOverride = basePathOverride ) {