diff options
author | Kevin Smokowski <ks6305@att.com> | 2018-02-09 21:36:38 +0000 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2018-02-09 19:13:58 -0500 |
commit | 7f2452b38b0d69ce51888ec0aefc7ada4281e864 (patch) | |
tree | 942c202d5d0120167108587c15ee25633a5c5df8 /sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java | |
parent | 131cb46f6109a6099a445cb8e1b12ff5b68ae6de (diff) |
Reset MDC after invoking node
collapse get node into a common metho, reset MDC right before getting next node for certain executor
Change-Id: I85b1cf0dfd595deee42dc93f4095ecbc6c831998
Issue-ID: CCSDK-187
Signed-off-by: Kevin Smokowski <ks6305@att.com>
Diffstat (limited to 'sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java')
-rw-r--r-- | sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java | 141 |
1 files changed, 53 insertions, 88 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java index 2df85ac8..d2b8b0a5 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -36,107 +35,73 @@ import org.slf4j.LoggerFactory; public class SaveNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(SaveNodeExecutor.class); + private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String forceStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("force"), node, ctx); - String localOnlyStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("local-only"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx); + String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - boolean force = "true".equalsIgnoreCase(forceStr); - boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); + boolean force = "true".equalsIgnoreCase(forceStr); + boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - Map<String, String> parmMap = new HashMap<String, String>(); + Map<String, String> parmMap = new HashMap<String, String>(); - Set<Map.Entry<String, SvcLogicExpression>> parmSet = node - .getParameterSet(); - boolean hasParms = false; + Set<Map.Entry<String, SvcLogicExpression>> parmSet = node.getParameterSet(); + boolean hasParms = false; - for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry<String, SvcLogicExpression> curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate( - curExpr, node, ctx); + for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry<String, SvcLogicExpression> curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - LOG.debug("Parameter " + curName + " = " - + curExpr.asParsedExpr() + " resolves to " - + curExprValue); + LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - parmMap.put(curName, curExprValue); - } - } + parmMap.put(curName, curExprValue); + } + } - String outValue = "failure"; + String outValue = "failure"; - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + plugin); + } SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.save(resourceType, force, localOnly, key, - parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } |