Skip to content

Commit

Permalink
set service/permission option
Browse files Browse the repository at this point in the history
Signed-off-by: Arzon <[email protected]>
  • Loading branch information
Arzon committed Jun 19, 2020
1 parent fbe2b6c commit 1b1299f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ class NodeProperties {
var plannedPartySearchRate: String = "3600000" // defaults to 1 hour

var plannedPartySearchEnabled: Boolean = true

var messageForwardEnabled: Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import org.slf4j.LoggerFactory
import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Service
import snc.openchargingnetwork.node.components.OcpiRequestHandler
import snc.openchargingnetwork.node.config.NodeProperties
import snc.openchargingnetwork.node.models.ocpi.ModuleID

@Service
class AsyncTaskService(private val registryService: RegistryService) {
class AsyncTaskService(private val registryService: RegistryService, private val properties: NodeProperties) {

companion object {
private val logger = LoggerFactory.getLogger(AsyncTaskService::class.java)
Expand All @@ -37,9 +38,11 @@ class AsyncTaskService(private val registryService: RegistryService) {
fun forwardOcpiRequestToLinkedServices(requestHandler: OcpiRequestHandler<*>, fromLocalPlatform: Boolean = true) {
// we only want to forward to services if the module is one of the default OCPI modules,
// and only if the sender is a local platform (to avoid repeat forwarding on the recipient node)
// and also forward if message forward option is enabled
val isDefaultModule = requestHandler.request.module != ModuleID.CUSTOM
val isEnabledForwarding = properties.messageForwardEnabled

if (isDefaultModule && fromLocalPlatform) {
if (isDefaultModule && fromLocalPlatform && isEnabledForwarding) {
val request = requestHandler.request
registryService.getAgreementsByInterface(request.headers.sender, request.module, request.interfaceRole)
.forEach {
Expand Down

0 comments on commit 1b1299f

Please sign in to comment.