Hi Team,
I have requirement to read multiple API proxies names and that includes request path with comma (“,”) separated from keyvaule maps as metioned below
KVM name is SF-KVM and the key name is globalvar that contains a value
apiproxyname1,apiproxyname12,apiproxyname3,apiproxyname4,/apiproxyname1/sample/json2xml
I have used a KVM policy to retrieve value and written a java script policy to construct the conditional string to execute one of the policy based on condition in a shared flow default flow.
var kvalue=context.getVariable(“kvm-val”);
var conditionStr=“”;
var arr=“”;
if(kvalue.indexOf(‘,’) > -1) {
arr = kvalue.split(‘,’);
for(i=0; i<=arr.length-1; i++) {
if(arr[i].indexOf(‘/’) > -1 && arr[i].indexOf(‘/’) === 0) {
conditionStr+=“or” + " (request.path = " + arr[i].toString() + ") "
} else {
conditionStr+=“or” + " (apiproxy.name = " + arr[i].toString() + ") "
}
}
} else {
if(kvalue.indexOf(‘/’) > -1 && kvalue.indexOf(‘/’) === 0) {
conditionStr+=“or” + " (request.path = " + kvalue.toString() + ") "
} else {
conditionStr+=“or” + " (apiproxy.name = " + kvalue.toString() + “)”
}
}
}
context.setVariable(“condStr”,conditionStr);
print(conditionStr)
I am successfully able to construct the conditional string dynamically as mentioned below and is this possible to use dynamically constructed conditional string in an shared flow default
condStr= (apiproxy.name = apiproxyname1) or (apiproxy.name =apiproxyname2) or (apiproxy.name = apiproxyname3) or (apiproxy.name = apiproxyname4) or (request.path /apiproxyname1/sample/json2xml)
sharedflow default xml file content as mentioned below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> kvm-policy KVM-javascript RaiseFault condStr this is step is not at all workingI have requirement to apply this shared flow on environment level using a flow-hook
I appreciate any help regarding this.
Regards
Nandeesha