diff options
author | Smokowski, Kevin (ks6305) <ks6305@att.com> | 2018-05-03 18:38:16 +0000 |
---|---|---|
committer | Kevin Smokowski <ks6305@att.com> | 2018-05-03 18:46:52 +0000 |
commit | 979b646bec328670a9ef4c9f24ebd5a4e0ae3987 (patch) | |
tree | c2f9b7e52d2861a7ba383a21359eb409c82b1541 /sli/provider/src/main/java/org/onap | |
parent | 1f66572b9e9622634086922caf73f82c24ab50da (diff) |
SetNodeExecutor nulling feature enhancement
Add special handling for clear a single array element or an entire array
Change-Id: Ica73e2af32f4a566219e1487504753276bc98aa2
Issue-ID: CCSDK-265
Signed-off-by: Smokowski, Kevin (ks6305) <ks6305@att.com>
Diffstat (limited to 'sli/provider/src/main/java/org/onap')
-rw-r--r-- | sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index cd478977..758f2039 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; public class SetNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class); + protected final String arrayPattern = "\\[\\d*\\]"; @Override public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) @@ -131,8 +132,14 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { LinkedList<String> parmsToRemove = new LinkedList<String>(); String prefix = lhsVarName + "."; for (String curCtxVarname : ctx.getAttributeKeySet()) { - if (curCtxVarname.startsWith(prefix)) { - LOG.debug("Unsetting " + curCtxVarname); + String curCtxVarnameMatchingValue = curCtxVarname; + //Special handling for reseting array values, strips out brackets and any numbers between the brackets + //when testing if a context memory value starts with a prefix + if(!prefix.contains("[") && curCtxVarnameMatchingValue.contains("[")) { + curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, ""); + } + if (curCtxVarnameMatchingValue.startsWith(prefix)) { + LOG.debug("Unsetting " + curCtxVarname + " because matching value " + curCtxVarnameMatchingValue + " starts with the prefix " + prefix); parmsToRemove.add(curCtxVarname); } } |