Commit 9ab4b4f2 authored by Vikram Ingawale's avatar Vikram Ingawale
Browse files

CallService: Branch changes added

parent 6c448279
Branches
Tags
2 merge requests!220Release v2.0.0 alpha,!219Add: Support for branches
Showing with 30 additions and 8 deletions
package routebuildermdl
import (
"strings"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/constantmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/servicebuildermdl"
......@@ -153,17 +156,36 @@ func SetAppVersion(appVersion, minSupportedVersion string) error {
// CallService - calls service with provided configuration, returns result and error from executed service
func CallService(name string, rs *gjson.Result, isRestricted bool, isRoleBased bool, p servicebuildermdl.Principal) (interface{}, error) {
return CallServiceWithBranch(name, constantmdl.Branch_Main, rs, isRestricted, isRoleBased, p)
}
// CallServiceWithBranch - calls service of given branch with provided configuration, returns result and error from executed service
func CallServiceWithBranch(name, branch string, rs *gjson.Result, isRestricted bool, isRoleBased bool, p servicebuildermdl.Principal) (interface{}, error) {
var found bool
var service interface{}
if isRestricted {
if isRoleBased {
service, found = roleBasedServices.Get(name)
} else {
service, found = restrictedServices.Get(name)
}
} else {
service, found = openServices.Get(name)
if strings.TrimSpace(branch) == "" {
loggermdl.LogError("Branch is empty")
return nil, errormdl.Wrap("Branch is empty")
}
activityName := ConcatenateEntityWithBranch(name, branch)
// if isRestricted {
// if isRoleBased {
// service, found = roleBasedServices.Get(activityName)
// } else {
// service, found = restrictedServices.Get(activityName)
// }
// } else {
// service, found = openServices.Get(activityName)
// }
switch {
case isRestricted == true && isRoleBased == true:
service, found = roleBasedServices.Get(activityName)
case isRestricted == true && isRoleBased == false:
service, found = restrictedServices.Get(activityName)
case isRestricted == false:
service, found = openServices.Get(activityName)
}
if !found {
loggermdl.LogError("Service Not Found: " + name)
return nil, errormdl.Wrap("Service Not Found: " + name)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment