} else {
return null;
}
- } catch (SQLException e) {
- throw new ConfigurationException("SQL query failed", e);
} catch (Exception e) {
- throw new ConfigurationException("Graph processing failed", e);
+ LOG.error("Graph processing failed", e);
+ throw new ConfigurationException("Graph processing failed: " + e.getMessage());
} finally {
try {
if (fetchGraphStmt != null) {
private void pushExpr(SvcLogicExpression expr)
{
- LOG.trace("Pushing expression ["+expr.getClass().getName()+"]");
if (curExpr != null)
{
exprStack.push(curExpr);
public static SvcLogicExpression parse(String exprStr) throws IOException
{
- LOG.trace("parse("+exprStr+")");
InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes());
CharStream input = new ANTLRInputStream(exprStream);
ExprGrammarLexer lexer = new ExprGrammarLexer(input);
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="ccsdk-dblib">
- <feature name="features-sli" description="ccsdk-sli-core :: sli :: features-sli" version="${project.version}">
+ <feature name="ccsdk-sli">
<!-- the generated bundle symbolic name is very long for wrapped jars, providing an instruction to shorten it -->
- <bundle>wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider.base</bundle>
+ <bundle>wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}/$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider-base&Bundle-Name=sli-provider-base</bundle>
</feature>
</features>
package org.onap.ccsdk.sli.core.sli.provider.base;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class);
+ protected static final String PARAMETER_DEBUG_PATTERN = "Parameter: {} resolves to: {} which came from the expression: {}";
+ protected static final String SETTING_DEBUG_PATTERN = "Setting context attribute: {} to: {} which came from the expression: {}";
protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
return (nextNode);
}
+ protected Map<String, String> getResolvedParameters(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException{
+ Map<String, String> parmMap = new HashMap<>();
+
+ Set<Map.Entry<String, SvcLogicExpression>> parmSet = node
+ .getParameterSet();
+
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet
+ .iterator(); iter.hasNext();) {
+ Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
+ String curName = curEnt.getKey();
+ SvcLogicExpression curExpr = curEnt.getValue();
+ String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
+ LOG.trace(PARAMETER_DEBUG_PATTERN, curName, curExprValue, curExpr.toString());
+ parmMap.put(curName,curExprValue);
+ }
+
+ return parmMap;
+ }
+
}
String key = SvcLogicExpressionResolver.evaluate(
node.getAttribute("key"), node, ctx);
- Map<String, String> parmMap = new HashMap<>();
-
- 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();
- String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
-
- LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue);
-
- parmMap.put(curName,curExprValue);
- }
+
+ Map<String, String> parmMap = getResolvedParameters(node,ctx);
+ if(!parmMap.isEmpty()) {
+ hasParms = true;
+ }
if (hasParms) {
SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
} else {
try {
- Map<String, String> parmMap = new HashMap<>();
-
- Set<Map.Entry<String, SvcLogicExpression>> parmSet = node
- .getParameterSet();
-
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parmSet
- .iterator(); iter.hasNext();) {
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- SvcLogicExpression curExpr = curEnt.getValue();
- String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
-
- LOG.trace("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue);
-
- parmMap.put(curName,curExprValue);
- }
+ Map<String, String> parmMap = getResolvedParameters(node,ctx);
Object o = pluginMethod.invoke(plugin, parmMap, ctx);
String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx);
String outValue = "failure";
- if (LOG.isTraceEnabled()) {
- LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin);
- }
-
- Map<String, String> parmMap = new HashMap<>();
-
- 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();
- String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx);
-
- if (LOG.isTraceEnabled()) {
- LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue);
- }
- parmMap.put(curName, curExprValue);
- }
+ Map<String, String> parmMap = getResolvedParameters(node,ctx);
SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
if (recorder != null) {
curEnt.getValue(), node, ctx);
if (LOG.isDebugEnabled()) {
- LOG.debug("Setting context attribute " + curName + " to "
- + curValue);
+ LOG.debug(SETTING_DEBUG_PATTERN, curName, curValue);
}
ctx.setAttribute(curName, curValue);
}
boolean force = "true".equalsIgnoreCase(forceStr);
boolean localOnly = "true".equalsIgnoreCase(localOnlyStr);
- Map<String, String> parmMap = new HashMap<>();
-
- 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);
-
- LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue);
-
- parmMap.put(curName, curExprValue);
- }
- }
+ Map<String, String> parmMap = getResolvedParameters(node,ctx);
String outValue = FAILURE;
String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx);
if (LOG.isDebugEnabled()) {
- LOG.trace("Parameter value {} resolves to {}", curEnt.getValue().asParsedExpr(), curValue);
- LOG.debug("Setting context attribute {} to {}", lhsVarName, curValue);
+ LOG.debug(SETTING_DEBUG_PATTERN, lhsVarName, curValue, curEnt.getValue().toString());
}
ctx.setAttribute(lhsVarName, curValue);
}
private static final Logger LOG = LoggerFactory
.getLogger(SvcLogicExpressionResolver.class);
private static final String INVALID_EXPRESSION_MSG= "Invalid expression (";
+ private static final String EXPRESSION_DEBUG_PATTERN = "Expression: {} resolves to {}: which has the value {}";
public static String evaluate(SvcLogicExpression expr, SvcLogicNode node,
SvcLogicContext ctx) throws SvcLogicException {
return (null);
}
-
-
if (expr instanceof SvcLogicAtom) {
SvcLogicAtom atom = (SvcLogicAtom) expr;
LOG.trace("Context variable $"+varName+" unset - treating as empty string");
varValue = "";
}
-
+ LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varValue);
return (varValue);
}
SvcLogicExpression parm = node.getParameter(varName);
if (parm != null) {
- return (evaluate(parm, node, ctx));
+ String value = evaluate(parm, node, ctx);
+ LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,value);
+ return value;
}
else
{
+ LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varName);
return(varName);
}
default:
List<SvcLogicExpression> operands = binExpr.getOperands();
if (operands.size() == 1)
{
- LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand");
return(evaluate(operands.get(0), node, ctx));
}
else
return (null);
}
- LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType());
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc());
- }
+ LOG.info("About to execute node #{} {} node in graph {}", node.getNodeId(), node.getNodeType(), node.getGraph().toString());
AbstractSvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType());
String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
- Map<String, String> parmMap = new HashMap<>();
-
- 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);
-
- LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue);
-
- parmMap.put(curName, curExprValue);
- }
- }
+ Map<String, String> parmMap = getResolvedParameters(node,ctx);
String outValue = "failure";
// "getValue", then
// set value identified by "prefix" to that one value.
if ((numGetters == 1) && ("getValue".equals(lastGetterName))) {
- LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx
- + " = " + propVal);
props.setProperty(propNamePfx, propVal);
- } else {
- LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was "
- + lastGetterName);
-
}
-
} else {
// Class is not yang generated and not a list
// It must be an element of a leaf list - set "prefix" to value
@Override
public Properties execute(String module, String rpc, String version, String mode, Properties props,
DOMDataBroker domDataBroker) throws SvcLogicException {
- LOG.info("Fetching service logic from data store");
SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
if (graph == null) {