aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smokowski <ks6305@att.com>2017-05-26 18:23:42 +0000
committerKevin Smokowski <ks6305@att.com>2017-05-26 18:23:42 +0000
commitae1e918820b3b4e70b7844b3c1d6c45dcde3b22d (patch)
treefd24d5677940db51a67ba893b7241e2d8d77abe0
parentdda3edb6257146ab6599bfd44658a9791037511d (diff)
SDNC-12 refactoring to support easy mocking
Change-Id: I5788e5b728c12bbefe83f1702f508a6a1daf22f0 Signed-off-by: Kevin Smokowski <ks6305@att.com>
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java37
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java3
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java19
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java20
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java19
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java1
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java437
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java4
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java69
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java6
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java3
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java18
-rw-r--r--sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java137
20 files changed, 383 insertions, 530 deletions
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java
index a500b6f..7b79c19 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java
@@ -78,7 +78,16 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor {
{
rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx);
}
-
+
+ if ((rpc == null) || (rpc.length() == 0))
+ {
+ if (myGraph != null)
+ {
+ rpc = myGraph.getRpc();
+ LOG.debug("myGraph.getRpc() returned "+rpc);
+ }
+ }
+
String mode = null;
moduleExpr = node.getAttribute("mode");
@@ -108,21 +117,24 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor {
String parentGraph = ctx.getAttribute("currentGraph");
ctx.setAttribute("parentGraph", parentGraph);
- SvcLogicStore store = SvcLogicActivator.getStore();
+ SvcLogicStore store = getStore();
if (store != null) {
- SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode);
+ SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode);
+ LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString());
+ ctx.setAttribute("currentGraph", calledGraph.toString());
if (calledGraph != null) {
- svc.execute(calledGraph, ctx);
- LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString());
- ctx.setAttribute("currentGraph", calledGraph.toString());
- outValue = ctx.getStatus();
+ svc.execute(calledGraph, ctx);
+
+ outValue = ctx.getStatus();
} else {
- LOG.debug("Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found");
- }
- } else {
- LOG.debug("Could not get SvcLogicStore reference");
- }
+ LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]");
+ }
+ }
+ else
+ {
+ LOG.debug("Could not get SvcLogicStore reference");
+ }
SvcLogicNode nextNode = node.getOutcomeValue(outValue);
if (nextNode != null) {
@@ -150,5 +162,4 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor {
}
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java
index d6aab3d..a3f2874 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java
@@ -50,8 +50,7 @@ public class ConfigureNodeExecutor extends SvcLogicNodeExecutor {
+ adaptorName);
}
- SvcLogicAdaptor adaptor = SvcLogicAdaptorFactory
- .getInstance(adaptorName);
+ SvcLogicAdaptor adaptor = getAdaptor(adaptorName);
if (adaptor != null) {
String activate = SvcLogicExpressionResolver.evaluate(
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java
index 375c631..081cbcf 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java
@@ -25,9 +25,6 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -100,22 +97,5 @@ public class DeleteNodeExecutor extends SvcLogicNodeExecutor {
}
return (nextNode);
}
-
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java
index 85aede7..7ae4d0d 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java
@@ -28,16 +28,11 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import org.openecomp.sdnc.sli.SvcLogicAdaptor;
import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
import org.openecomp.sdnc.sli.SvcLogicNode;
-import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -145,21 +140,6 @@ public class ExecuteNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(pluginName);
-
- if (sref == null) {
- LOG.warn("Could not find service reference object for plugin " + pluginName);
- return null;
- } else {
- SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx
- .getService(sref);
- return plugin;
- }
- }
protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx);
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java
index 464c676..688a86e 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java
@@ -25,9 +25,6 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,21 +102,4 @@ public class ExistsNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java
index c260db2..d431a18 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java
@@ -26,9 +26,6 @@ import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -133,22 +130,5 @@ public class GetResourceNodeExecutor extends SvcLogicNodeExecutor {
}
return (nextNode);
}
-
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java
index 00c7e66..0df7368 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java
@@ -25,9 +25,6 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,20 +100,4 @@ public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java
index 4dc4a93..706014a 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java
@@ -25,9 +25,6 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,21 +99,4 @@ public class NotifyNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java
index f75752b..8ba14d2 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java
@@ -31,9 +31,6 @@ import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicRecorder;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,7 +76,7 @@ public class RecordNodeExecutor extends SvcLogicNodeExecutor {
}
- SvcLogicRecorder recorder = getSvcLogicResource(plugin);
+ SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
if (recorder != null) {
@@ -115,20 +112,7 @@ public class RecordNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicRecorder getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- return null;
- }
- }
+
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java
index b51cf9f..0d8416c 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java
@@ -25,9 +25,6 @@ import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -100,21 +97,4 @@ public class ReleaseNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java
index 7db233f..f0bbda8 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java
@@ -26,9 +26,6 @@ import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,21 +111,4 @@ public class ReserveNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java
index f57eac8..57eac7f 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java
@@ -31,9 +31,6 @@ import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -142,20 +139,4 @@ public class SaveNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
-
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java
index 55ad737..013997e 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java
@@ -21,7 +21,6 @@
package org.openecomp.sdnc.sli.provider;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java
index 8996095..ae42e2c 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java
@@ -1,226 +1,225 @@
-/*-
+/*-
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-
-import org.openecomp.sdnc.sli.ConfigurationException;
-import org.openecomp.sdnc.sli.SvcLogicAdaptor;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicStore;
-import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mysql.jdbc.Driver;
-
-public class SvcLogicActivator implements BundleActivator {
-
- private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES";
- private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
-
- private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
- {
- put("block", new BlockNodeExecutor());
- put("call", new CallNodeExecutor());
- put("configure", new ConfigureNodeExecutor());
- put("delete", new DeleteNodeExecutor());
- put("execute", new ExecuteNodeExecutor());
- put("exists", new ExistsNodeExecutor());
- put("for", new ForNodeExecutor());
- put("get-resource", new GetResourceNodeExecutor());
- put("is-available", new IsAvailableNodeExecutor());
- put("notify", new NotifyNodeExecutor());
- put("record", new RecordNodeExecutor());
- put("release", new ReleaseNodeExecutor());
- put("reserve", new ReserveNodeExecutor());
- put("return", new ReturnNodeExecutor());
- put("save", new SaveNodeExecutor());
- put("set", new SetNodeExecutor());
- put("switch", new SwitchNodeExecutor());
- put("update", new UpdateNodeExecutor());
- put("break", new BreakNodeExecutor());
- put("while", new WhileNodeExecutor());
- }
- };
-
- private static LinkedList<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
-
- private static HashMap<String, SvcLogicAdaptor> adaptorMap = null;
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SvcLogicActivator.class);
-
- private static Properties props = null;
-
- private static BundleContext bundleCtx = null;
-
- private static SvcLogicService svcLogicServiceImpl = null;
-
- @Override
- public void start(BundleContext ctx) throws Exception {
-
- LOG.info("Activating SLI");
-
- bundleCtx = ctx;
-
- // Read properties
- props = new Properties();
- String propPath = System.getenv(SVCLOGIC_PROP_VAR);
-
- if (propPath == null) {
- String propDir = System.getenv(SDNC_CONFIG_DIR);
- if (propDir == null) {
-
- propDir = "/opt/sdnc/data/properties";
- }
- propPath = propDir + "/svclogic.properties";
- LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath);
- }
-
- File propFile = new File(propPath);
-
- if (!propFile.exists()) {
-
- throw new ConfigurationException(
- "Missing configuration properties file : "
- + propFile);
- }
- try {
-
- props.load(new FileInputStream(propFile));
- } catch (Exception e) {
- throw new ConfigurationException(
- "Could not load properties file " + propPath, e);
-
- }
-
-
- if (registrations == null) {
-
- registrations = new LinkedList<ServiceRegistration>();
- }
-
- // Advertise SvcLogicService
- svcLogicServiceImpl = new SvcLogicServiceImpl();
-
- LOG.info("SLI: Registering service " + SvcLogicService.NAME
- + " in bundle " + ctx.getBundle().getSymbolicName());
- ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME,
- svcLogicServiceImpl, null);
- registrations.add(reg);
-
- // Initialize SvcLogicStore
- try {
- SvcLogicStore store = getStore();
- registerNodeTypes(store);
- } catch (ConfigurationException e) {
- LOG.warn("Could not initialize SvcLogicScore", e);
- }
-
- LOG.info("SLI - done registering services");
- }
-
- @Override
- public void stop(BundleContext ctx) throws Exception {
-
- if (registrations != null) {
- for (ServiceRegistration reg : registrations) {
- ServiceReference regRef = reg.getReference();
- /* Don't bother to remove node types from table
- String nodeType = (String) regRef.getProperty("nodeType");
- if (nodeType != null) {
- LOG.info("SLI - unregistering node type " + nodeType);
- store.unregisterNodeType(nodeType);
- }
- */
- reg.unregister();
- }
- registrations = null;
- }
- }
-
- public static SvcLogicStore getStore() throws SvcLogicException {
- // Create and initialize SvcLogicStore object - used to access
- // saved service logic.
-
- SvcLogicStore store = null;
-
- try {
- Driver dvr = new Driver();
- store = SvcLogicStoreFactory.getSvcLogicStore(props);
- } catch (Exception e) {
- throw new ConfigurationException(
- "Could not get service logic store", e);
-
- }
-
- try {
- store.init(props);
- } catch (Exception e) {
- throw new ConfigurationException(
- "Could not get service logic store", e);
- }
-
- return(store);
- }
-
- private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException {
-
- if (store == null) {
- return;
- }
- // Advertise built-in node executors
- LOG.info("SLI : Registering built-in node executors");
- Hashtable propTable = new Hashtable();
-
- for (String nodeType : BUILTIN_NODES.keySet()) {
- LOG.info("SLI - registering node type " + nodeType);
- propTable.clear();
- propTable.put("nodeType", nodeType);
-
- ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(),
- BUILTIN_NODES.get(nodeType), propTable);
- registrations.add(reg);
-
- store.registerNodeType(nodeType);
-
- LOG.info("SLI - registering node executor");
-
- ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
-
- }
-
- }
-
-}
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli.provider;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+
+import org.openecomp.sdnc.sli.ConfigurationException;
+import org.openecomp.sdnc.sli.SvcLogicAdaptor;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicStore;
+import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.mysql.jdbc.Driver;
+
+public class SvcLogicActivator implements BundleActivator {
+
+ private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES";
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+
+ private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
+ {
+ put("block", new BlockNodeExecutor());
+ put("call", new CallNodeExecutor());
+ put("configure", new ConfigureNodeExecutor());
+ put("delete", new DeleteNodeExecutor());
+ put("execute", new ExecuteNodeExecutor());
+ put("exists", new ExistsNodeExecutor());
+ put("for", new ForNodeExecutor());
+ put("get-resource", new GetResourceNodeExecutor());
+ put("is-available", new IsAvailableNodeExecutor());
+ put("notify", new NotifyNodeExecutor());
+ put("record", new RecordNodeExecutor());
+ put("release", new ReleaseNodeExecutor());
+ put("reserve", new ReserveNodeExecutor());
+ put("return", new ReturnNodeExecutor());
+ put("save", new SaveNodeExecutor());
+ put("set", new SetNodeExecutor());
+ put("switch", new SwitchNodeExecutor());
+ put("update", new UpdateNodeExecutor());
+ put("break", new BreakNodeExecutor());
+
+ }
+ };
+
+ private static LinkedList<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
+
+ private static HashMap<String, SvcLogicAdaptor> adaptorMap = null;
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicActivator.class);
+
+ private static Properties props = null;
+
+ private static BundleContext bundleCtx = null;
+
+ private static SvcLogicService svcLogicServiceImpl = null;
+
+ @Override
+ public void start(BundleContext ctx) throws Exception {
+
+ LOG.info("Activating SLI");
+
+ bundleCtx = ctx;
+
+ // Read properties
+ props = new Properties();
+ String propPath = System.getenv(SVCLOGIC_PROP_VAR);
+
+ if (propPath == null) {
+ String propDir = System.getenv(SDNC_CONFIG_DIR);
+ if (propDir == null) {
+
+ propDir = "/opt/sdnc/data/properties";
+ }
+ propPath = propDir + "/svclogic.properties";
+ LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath);
+ }
+
+ File propFile = new File(propPath);
+
+ if (!propFile.exists()) {
+
+ throw new ConfigurationException(
+ "Missing configuration properties file : "
+ + propFile);
+ }
+ try {
+
+ props.load(new FileInputStream(propFile));
+ } catch (Exception e) {
+ throw new ConfigurationException(
+ "Could not load properties file " + propPath, e);
+
+ }
+
+
+ if (registrations == null) {
+
+ registrations = new LinkedList<ServiceRegistration>();
+ }
+
+ // Advertise SvcLogicService
+ svcLogicServiceImpl = new SvcLogicServiceImpl();
+
+ LOG.info("SLI: Registering service " + SvcLogicService.NAME
+ + " in bundle " + ctx.getBundle().getSymbolicName());
+ ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME,
+ svcLogicServiceImpl, null);
+ registrations.add(reg);
+
+ // Initialize SvcLogicStore
+ try {
+ SvcLogicStore store = getStore();
+ registerNodeTypes(store);
+ } catch (ConfigurationException e) {
+ LOG.warn("Could not initialize SvcLogicScore", e);
+ }
+
+ LOG.info("SLI - done registering services");
+ }
+
+ @Override
+ public void stop(BundleContext ctx) throws Exception {
+
+ if (registrations != null) {
+ for (ServiceRegistration reg : registrations) {
+ ServiceReference regRef = reg.getReference();
+ /* Don't bother to remove node types from table
+ String nodeType = (String) regRef.getProperty("nodeType");
+ if (nodeType != null) {
+ LOG.info("SLI - unregistering node type " + nodeType);
+ store.unregisterNodeType(nodeType);
+ }
+ */
+ reg.unregister();
+ }
+ registrations = null;
+ }
+ }
+
+ public static SvcLogicStore getStore() throws SvcLogicException {
+ // Create and initialize SvcLogicStore object - used to access
+ // saved service logic.
+
+ SvcLogicStore store = null;
+
+ try {
+ Driver dvr = new Driver();
+ store = SvcLogicStoreFactory.getSvcLogicStore(props);
+ } catch (Exception e) {
+ throw new ConfigurationException(
+ "Could not get service logic store", e);
+
+ }
+
+ try {
+ store.init(props);
+ } catch (Exception e) {
+ throw new ConfigurationException(
+ "Could not get service logic store", e);
+ }
+
+ return(store);
+ }
+
+ private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException {
+
+ if (store == null) {
+ return;
+ }
+ // Advertise built-in node executors
+ LOG.info("SLI : Registering built-in node executors");
+ Hashtable propTable = new Hashtable();
+
+ for (String nodeType : BUILTIN_NODES.keySet()) {
+ LOG.info("SLI - registering node type " + nodeType);
+ propTable.clear();
+ propTable.put("nodeType", nodeType);
+
+ ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(),
+ BUILTIN_NODES.get(nodeType), propTable);
+ registrations.add(reg);
+
+ store.registerNodeType(nodeType);
+
+ LOG.info("SLI - registering node executor");
+
+ ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
+
+ }
+
+ }
+
+}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java
index 29bd9b4..5c17c79 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java
@@ -25,15 +25,15 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdnc.sli.SvcLogicAtom;
+import org.openecomp.sdnc.sli.SvcLogicAtom.AtomType;
import org.openecomp.sdnc.sli.SvcLogicBinaryExpression;
+import org.openecomp.sdnc.sli.SvcLogicBinaryExpression.OperatorType;
import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicFunctionCall;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicVariableTerm;
-import org.openecomp.sdnc.sli.SvcLogicAtom.AtomType;
-import org.openecomp.sdnc.sli.SvcLogicBinaryExpression.OperatorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java
index de969de..0c8166a 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java
@@ -21,16 +21,27 @@
package org.openecomp.sdnc.sli.provider;
+import org.openecomp.sdnc.sli.SvcLogicAdaptor;
import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
import org.openecomp.sdnc.sli.SvcLogicNode;
+import org.openecomp.sdnc.sli.SvcLogicRecorder;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.SvcLogicStore;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class SvcLogicNodeExecutor {
public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class);
- protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
+ protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
throws SvcLogicException {
if (node == null) {
return null;
@@ -40,4 +51,60 @@ public abstract class SvcLogicNodeExecutor {
node, ctx));
}
+
+ protected SvcLogicStore getStore() throws SvcLogicException {
+ return SvcLogicActivator.getStore();
+ }
+
+ protected SvcLogicAdaptor getAdaptor(String adaptorName) {
+ return SvcLogicAdaptorFactory.getInstance(adaptorName);
+ }
+
+ protected SvcLogicResource getSvcLogicResource(String plugin) {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
+ .getBundleContext();
+
+ ServiceReference sref = bctx.getServiceReference(plugin);
+ if (sref != null) {
+ SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
+ .getService(sref);
+ return resourcePlugin;
+ }
+ else {
+ LOG.warn("Could not find service reference object for plugin " + plugin);
+ return null;
+ }
+ }
+
+ protected SvcLogicRecorder getSvcLogicRecorder(String plugin) {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
+ .getBundleContext();
+
+ ServiceReference sref = bctx.getServiceReference(plugin);
+ if (sref != null) {
+ SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx
+ .getService(sref);
+ return resourcePlugin;
+ }
+ else {
+ return null;
+ }
+ }
+
+ protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
+ .getBundleContext();
+
+ ServiceReference sref = bctx.getServiceReference(pluginName);
+
+ if (sref == null) {
+ LOG.warn("Could not find service reference object for plugin " + pluginName);
+ return null;
+ } else {
+ SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx
+ .getService(sref);
+ return plugin;
+ }
+ }
+
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java
index 93d6807..f30b3fc 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java
@@ -21,16 +21,10 @@
package org.openecomp.sdnc.sli.provider;
-import java.util.HashMap;
import java.util.Properties;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicGraph;
-
-
-
public interface SvcLogicService {
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java
index 2e32a58..e8ae7c8 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java
@@ -21,9 +21,6 @@
package org.openecomp.sdnc.sli.provider;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicNode;
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java
index e7a6621..9eeab65 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java
@@ -31,9 +31,6 @@ import org.openecomp.sdnc.sli.SvcLogicException;
import org.openecomp.sdnc.sli.SvcLogicExpression;
import org.openecomp.sdnc.sli.SvcLogicNode;
import org.openecomp.sdnc.sli.SvcLogicResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -136,19 +133,4 @@ public class UpdateNodeExecutor extends SvcLogicNodeExecutor {
return (nextNode);
}
- protected SvcLogicResource getSvcLogicResource(String plugin) {
- BundleContext bctx = FrameworkUtil.getBundle(this.getClass())
- .getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(plugin);
- if (sref != null) {
- SvcLogicResource resourcePlugin = (SvcLogicResource) bctx
- .getService(sref);
- return resourcePlugin;
- }
- else {
- LOG.warn("Could not find service reference object for plugin " + plugin);
- return null;
- }
- }
}
diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java
index 7ec36e1..5bbab32 100644
--- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java
+++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java
@@ -1,76 +1,75 @@
-/*-
+/*-
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.openecomp.sdnc.sli.BreakNodeException;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicExpression;
-import org.openecomp.sdnc.sli.SvcLogicNode;
-
-public class WhileNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
-
- String testResult = evaluateNodeTest(node, ctx);
- SvcLogicExpression silentFailureExpr = node.getAttribute("do");
- String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx);
- if ("true".equals(doWhile)) {
- LOG.debug("While loop will execute once regardless of expression because do is set to true");
- }
-
- try {
- while ("true".equals(testResult) || "true".equals(doWhile)) {
- if (!"true".equals(doWhile)) {
- LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop.");
- }
- int numOutcomes = node.getNumOutcomes() + 1;
- for (int i = 0; i < numOutcomes; i++) {
- SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1));
- if (nextNode != null) {
- while (nextNode != null) {
- nextNode = svc.executeNode(nextNode, ctx);
- }
- } else {
- if ("true".equals(doWhile)) {
- LOG.debug("Do executed, will only execute again if test expression is true.");
- doWhile = "false";
- }
- testResult = evaluateNodeTest(node, ctx);
- LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult);
- }
- }
- }
- LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop.");
- } catch (BreakNodeException e) {
- LOG.debug("WhileNodeExecutor caught break");
- }
- return (null);
- }
-
-}
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli.provider;
+
+import org.openecomp.sdnc.sli.BreakNodeException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicExpression;
+import org.openecomp.sdnc.sli.SvcLogicNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WhileNodeExecutor extends SvcLogicNodeExecutor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class);
+
+ @Override
+ public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
+
+ String testResult = evaluateNodeTest(node, ctx);
+ SvcLogicExpression silentFailureExpr = node.getAttribute("do");
+ String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx);
+ if ("true".equals(doWhile)) {
+ LOG.debug("While loop will execute once regardless of expression because do is set to true");
+ }
+
+ try {
+ while ("true".equals(testResult) || "true".equals(doWhile)) {
+ if (!"true".equals(doWhile)) {
+ LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop.");
+ }
+ int numOutcomes = node.getNumOutcomes() + 1;
+ for (int i = 0; i < numOutcomes; i++) {
+ SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1));
+ if (nextNode != null) {
+ while (nextNode != null) {
+ nextNode = svc.executeNode(nextNode, ctx);
+ }
+ } else {
+ if ("true".equals(doWhile)) {
+ LOG.debug("Do executed, will only execute again if test expression is true.");
+ doWhile = "false";
+ }
+ testResult = evaluateNodeTest(node, ctx);
+ LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult);
+ }
+ }
+ }
+ LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop.");
+ } catch (BreakNodeException e) {
+ LOG.debug("WhileNodeExecutor caught break");
+ }
+ return (null);
+ }
+
+}