Skip to content

Commit

Permalink
make mutableversionsrepo optional
Browse files Browse the repository at this point in the history
  • Loading branch information
atschabu committed Jan 15, 2024
1 parent a8f15e9 commit c6b1d62
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down

0 comments on commit c6b1d62

Please sign in to comment.