aboutsummaryrefslogtreecommitdiffstats
path: root/sli/provider/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'sli/provider/src/main/java')
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java75
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java42
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java175
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java248
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java74
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java141
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java75
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java42
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java109
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java99
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java71
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java74
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java82
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java73
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java87
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java78
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java107
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java179
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java5
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java81
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java605
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java94
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java28
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java1
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java39
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java143
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java63
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java103
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java75
29 files changed, 82 insertions, 2986 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java
deleted file mode 100644
index e5ae021f..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BlockNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(BlockNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
- throws SvcLogicException {
-
- SvcLogicExpression atomicExpr = node.getAttribute("atomic");
- String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx);
- boolean isAtomic = "true".equalsIgnoreCase(atomicStr);
-
- // Initialize status to success so that at least one outcome will execute
- ctx.setStatus("success");
-
- int numOutcomes = node.getNumOutcomes();
-
- for (int i = 0; i < numOutcomes; i++) {
- if ("failure".equals(ctx.getStatus()) && isAtomic) {
- LOG.info("Block - stopped executing nodes due to failure status");
- return(null);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1));
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Block - executing outcome " + (i + 1));
- }
- while (nextNode != null)
- {
- nextNode = svc.executeNode(nextNode, ctx);
- }
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Block - done: no outcome " + (i + 1));
- }
- }
- }
-
- return (null);
- }
-
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java
deleted file mode 100644
index fc6f0a50..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.BreakNodeException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BreakNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId();
- LOG.debug(message);
- throw new BreakNodeException(message);
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java
deleted file mode 100755
index c8e6548f..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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.SvcLogicGraph;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CallNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(CallNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
- throws SvcLogicException {
-
- String outValue = "not-found";
-
- SvcLogicGraph myGraph = node.getGraph();
-
- if (myGraph == null)
- {
- LOG.debug("execute: getGraph returned null");
- }
- else
- {
- LOG.debug("execute: got SvcLogicGraph");
- }
-
- SvcLogicExpression moduleExpr = null;
-
- String module = null;
-
- moduleExpr = node.getAttribute("module");
- if (moduleExpr != null)
- {
- module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
- }
-
- if ((module == null) || (module.length() == 0))
- {
- if (myGraph != null)
- {
- module = myGraph.getModule();
- LOG.debug("myGraph.getModule() returned "+module);
- }
- }
-
- SvcLogicExpression rpcExpr = null;
- String rpc = null;
- rpcExpr = node.getAttribute("rpc");
- if (rpcExpr != null)
- {
- 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");
- if (moduleExpr != null)
- {
- mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
- }
-
- if ((mode == null) || (mode.length() == 0))
- {
- if (myGraph != null)
- {
- mode = myGraph.getMode();
-
- LOG.debug("myGraph.getMode() returned "+mode);
- }
- }
-
- String version = null;
-
- moduleExpr = node.getAttribute("version");
- if (moduleExpr != null)
- {
- version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
- }
-
- String parentGraph = ctx.getAttribute("currentGraph");
- ctx.setAttribute("parentGraph", parentGraph);
-
- SvcLogicStore store = svc.getStore();
- String errorMessage = "Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found";
- boolean graphWasCalled = false;
- if (store != null) {
- SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode);
- if (calledGraph != null) {
- LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString());
- ctx.setAttribute("currentGraph", calledGraph.toString());
- svc.execute(calledGraph, ctx);
- outValue = ctx.getStatus();
- graphWasCalled = true;
- } else {
- LOG.debug(errorMessage);
- }
- } else {
- LOG.debug("Could not get SvcLogicStore reference");
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(outValue);
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("about to execute " + outValue + " branch");
- }
- ctx.setAttribute("currentGraph", parentGraph);
- 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");
- }
- }
-
- if (graphWasCalled == false) {
- if (node.getOutcomeValue("catch") != null) {
- nextNode = node.getOutcomeValue("catch");
- LOG.debug("graph could not be called, but catch node was found and will be executed");
- } else {
- LOG.debug("graph could not be called and no catch node was found, throwing exception");
- throw new SvcLogicException(errorMessage);
- }
- }
-
- ctx.setAttribute("currentGraph", parentGraph);
- ctx.setAttribute("parentGraph", null);
-
- return (nextNode);
-
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java
deleted file mode 100644
index 337b7064..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConfigureNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(ConfigureNodeExecutor.class);
-
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String adaptorName = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("adaptor"), node, ctx);
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("configure node encountered - looking for adaptor "
- + adaptorName);
- }
-
- SvcLogicAdaptor adaptor = getAdaptor(adaptorName);
-
- if (adaptor != null) {
- String activate = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("activate"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("key"), node, ctx);
-
- Map<String, String> parmMap = new HashMap<String, String>();
-
- 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);
- }
-
- if (hasParms) {
- SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
-
- try {
- confStatus = adaptor.configure(key, parmMap, ctx);
- } catch (Exception e) {
- LOG.warn("Caught exception from "+adaptorName+".configure", e);
- confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- }
-
- switch (confStatus) {
- case SUCCESS:
- outValue = "success";
- if ((activate != null) && (activate.length() > 0)) {
- if ("true".equalsIgnoreCase(activate)) {
- SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
-
- try {
- activateStatus = adaptor.activate(key, ctx);
- } catch (Exception e) {
-
- LOG.warn("Caught exception from "+adaptorName+".activate", e);
- activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- }
- switch (activateStatus) {
- case SUCCESS:
- break;
- case ALREADY_ACTIVE:
- outValue = "already-active";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case NOT_READY:
- outValue = "not-ready";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } else if ("false".equalsIgnoreCase(activate)) {
- SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
-
- try {
- deactivateStatus = adaptor.deactivate(key, ctx);
- } catch (Exception e) {
-
- LOG.warn("Caught exception from "+adaptorName+".deactivate", e);
- deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- }
- switch (deactivateStatus) {
- case SUCCESS:
- break;
- case ALREADY_ACTIVE:
- outValue = "already-active";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case NOT_READY:
- outValue = "not-ready";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- }
- }
- break;
- case ALREADY_ACTIVE:
- outValue = "already-active";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case NOT_READY:
- outValue = "not-ready";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } else {
- if ((activate != null) && (activate.length() > 0)) {
- if ("true".equalsIgnoreCase(activate)) {
- SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- try {
- activateStatus = adaptor.activate(key, ctx);
- } catch (Exception e) {
- LOG.warn("Caught exception from "+adaptorName+".activate", e);
- activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- }
- switch (activateStatus) {
- case SUCCESS:
- outValue = "success";
- break;
- case ALREADY_ACTIVE:
- outValue = "already-active";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case NOT_READY:
- outValue = "not-ready";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- } else if ("false".equalsIgnoreCase(activate)) {
- SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
-
- try {
- deactivateStatus = adaptor.deactivate(key, ctx);
- } catch (Exception e) {
- LOG.warn("Caught exception from "+adaptorName+".deactivate", e);
- deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE;
- }
- switch (deactivateStatus) {
- case SUCCESS:
- outValue = "success";
- break;
- case ALREADY_ACTIVE:
- outValue = "already-active";
- break;
- case NOT_FOUND:
- outValue = "not-found";
- break;
- case NOT_READY:
- outValue = "not-ready";
- break;
- case FAILURE:
- default:
- outValue = "failure";
- }
- }
- } else {
- LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set");
- outValue = "success";
- }
- }
- } else {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Adaptor for " + adaptorName + " not found");
- }
- }
-
- 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);
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java
deleted file mode 100644
index 18f1ce9a..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DeleteNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class);
- private static final String FAILURE="failure";
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 outValue = FAILURE;
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("delete node encountered - looking for resource class " + plugin);
- }
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.delete(resourceType, key, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java
deleted file mode 100644
index ed75c335..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExecuteNodeExecutor extends SvcLogicNodeExecutor {
- private static final Logger LOG = LoggerFactory
- .getLogger(ExecuteNodeExecutor.class);
-
- private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure.";
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String pluginName = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("plugin"), node, ctx);
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("execute node encountered - looking for plugin "
- + pluginName);
- }
-
- SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName);
-
- if (plugin == null) {
- outValue = "not-found";
- } else {
-
- String methodName = evaluate(node.getAttribute("method"), node, ctx);
-
- Class pluginClass = plugin.getClass();
-
- Method pluginMethod = null;
-
- try {
- pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class);
- } catch (NoSuchMethodException e) {
- LOG.error(pluginErrorMessage, e);
- }
-
- if (pluginMethod == null) {
- outValue = "unsupported-method";
- } else {
- try {
-
- Map<String, String> parmMap = new HashMap<String, String>();
-
- 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.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue);
-
- parmMap.put(curName,curExprValue);
- }
-
- Object o = pluginMethod.invoke(plugin, parmMap, ctx);
- String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
-
- outValue = mapOutcome(o, emitsOutcome);
-
- } catch (InvocationTargetException e) {
- if(e.getCause() != null){
- LOG.error(pluginErrorMessage, e.getCause());
- }else{
- LOG.error(pluginErrorMessage, e);
- }
- outValue = "failure";
- ctx.setStatus("failure");
- } catch (IllegalAccessException e) {
- LOG.error(pluginErrorMessage, e);
- outValue = "failure";
- ctx.setStatus("failure");
- } catch (IllegalArgumentException e) {
- LOG.error(pluginErrorMessage, e);
- outValue = "failure";
- ctx.setStatus("failure");
- }
- }
-
- }
- return (getNextNode(node, outValue));
- }
-
- protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx);
- }
-
- public String mapOutcome(Object o, String emitsOutcome) {
- if (emitsOutcome != null) {
- Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome);
- if (nodeEmitsOutcome) {
- return (String) o;
- } else {
- return "success";
- }
- } else {
- return "success";
- }
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java
deleted file mode 100644
index 80aec075..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExistsNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("exists node encountered - looking for resource class " + plugin);
- }
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) {
- case SUCCESS:
- outValue = "true";
- break;
- case NOT_FOUND:
- outValue = "false";
- break;
- case FAILURE:
- default:
- outValue = "false";
- }
- } 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java
deleted file mode 100755
index fc667f40..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.ExitNodeException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExitNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId();
- LOG.debug(message);
- throw new ExitNodeException(message);
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java
deleted file mode 100644
index a73fadcf..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.BreakNodeException;
-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.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ForNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(ForNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- SvcLogicExpression atomicExpr = node.getAttribute("atomic");
- String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx);
- boolean isAtomic = !("false".equalsIgnoreCase(atomicStr));
-
- int numOutcomes = node.getNumOutcomes();
- String idxVar = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("index"), node, ctx);
- String startVal = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("start"), node, ctx);
- String endVal = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("end"), node, ctx);
-
- LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal
- + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)");
-
- int startIdx = 0;
- int endIdx = 0;
-
- try {
- startIdx = Integer.parseInt(startVal);
- endIdx = Integer.parseInt(endVal);
- } catch (NumberFormatException e) {
- SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure");
- String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx);
- boolean isSilentFailure = Boolean.parseBoolean(silentFailure);
- String message = "Invalid index values [" + startVal + "," + endVal + "]";
- if(!isSilentFailure){
- throw new SvcLogicException(message);
- }else{
- LOG.debug(message + ". Not exiting because silentFailure was set to true.");
- return(null);
- }
- }
-
- try {
- for (int ctr = startIdx; ctr < endIdx; ctr++) {
-
- ctx.setAttribute(idxVar, "" + ctr);
-
- for (int i = 0; i < numOutcomes; i++) {
-
- if ("failure".equals(ctx.getStatus()) && isAtomic) {
- LOG.info("For - stopped executing nodes due to failure status");
- return(null);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1));
- if (nextNode != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("For - executing outcome " + (i + 1));
- }
- SvcLogicNode innerNextNode = nextNode;
- while (innerNextNode != null) {
- innerNextNode = svc.executeNode(innerNextNode, ctx);
- }
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("For - done: no outcome " + (i + 1));
- }
- }
- }
- }
- } catch (BreakNodeException br) {
- LOG.error("ForNodeExecutor caught break",br);
- }
- return (null);
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java
deleted file mode 100644
index 468a6fff..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GetResourceNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class);
-
- public SvcLogicNode execute(SvcLogicService 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 pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
-
- String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx);
-
- // Note: for get-resource, only refresh from A&AI if the DG explicitly set
- // local-only to false. Otherwise, just read from local database.
- boolean localOnly = true;
-
- if ("false".equalsIgnoreCase(localOnlyStr)) {
- localOnly = false;
- }
-
- SvcLogicExpression selectExpr = node.getAttribute("select");
- String select = null;
-
- if (selectExpr != null) {
- select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx);
- }
-
- SvcLogicExpression orderByExpr = node.getAttribute("order-by");
- String orderBy = null;
-
- if (orderByExpr != null) {
- orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx);
- }
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin);
- }
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java
deleted file mode 100644
index 72d99e4f..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
-
- String outValue = "failure";
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) {
- case SUCCESS:
- outValue = "true";
- break;
- case NOT_FOUND:
- outValue = "false";
- break;
- case FAILURE:
- default:
- outValue = "false";
- }
- } 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java
deleted file mode 100644
index 44d1ec8f..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NotifyNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx);
- String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx);
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("release node encountered - looking for resource class " + plugin);
- }
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.notify(resourceType, action, key, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java
deleted file mode 100644
index e3941446..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RecordNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx)
- throws SvcLogicException {
-
- 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<String, String>();
-
- 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);
- }
-
- SvcLogicRecorder recorder = getSvcLogicRecorder(plugin);
- if (recorder != null) {
- try {
- recorder.record(parmMap);
- } catch (SvcLogicException e) {
- LOG.error("Caught exception from recorder plugin", e);
- outValue = "failure";
- }
- } else {
- LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin);
- }
- return (getNextNode(node, outValue));
- }
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java
deleted file mode 100644
index b0453fad..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReleaseNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("release node encountered - looking for resource class " + plugin);
- }
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
- if (resourcePlugin != null) {
- try {
- switch (resourcePlugin.release(resourceType, key, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java
deleted file mode 100644
index 00355cd0..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReserveNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
-
-
- SvcLogicExpression selectExpr = node.getAttribute("select");
- String select = null;
-
- if (selectExpr != null) {
- select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx);
- }
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("reserve node encountered - looking for resource class " + plugin);
- }
-
-
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.reserve(resourceType, select, key, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java
deleted file mode 100644
index e05692d5..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReturnNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(ReturnNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
- String status = SvcLogicExpressionResolver.evaluate(
- node.getAttribute("status"), node, ctx);
-
- if (status != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Returning status " + status);
- }
- ctx.setStatus(status);
- } else {
- if (LOG.isWarnEnabled()) {
- LOG.warn("Return node has no status attribute set");
- }
- }
-
- Set<Map.Entry<String, SvcLogicExpression>> parameterSet = node
- .getParameterSet();
-
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parameterSet
- .iterator(); iter.hasNext();) {
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- String curValue = SvcLogicExpressionResolver.evaluate(
- curEnt.getValue(), node, ctx);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Setting context attribute " + curName + " to "
- + curValue);
- }
- ctx.setAttribute(curName, curValue);
- }
- return null;
- }
-
-
-}
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
deleted file mode 100644
index 1b5219be..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SaveNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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);
-
- boolean force = "true".equalsIgnoreCase(forceStr);
- boolean localOnly = "true".equalsIgnoreCase(localOnlyStr);
-
- Map<String, String> parmMap = new HashMap<String, String>();
-
- 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);
- }
- }
-
- String outValue = "failure";
-
- 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);
- }
- return (getNextNode(node, outValue));
- }
-
-}
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
deleted file mode 100755
index 8275a8e4..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-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)
- throws SvcLogicException {
- execute(node,ctx);
- return null;
- }
-
- public void execute(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- String ifunsetStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("only-if-unset"), node, ctx);
-
- boolean ifunset = "true".equalsIgnoreCase(ifunsetStr);
-
- Set<Map.Entry<String, SvcLogicExpression>> parameterSet = node.getParameterSet();
-
- for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = parameterSet.iterator(); iter.hasNext();) {
- Map.Entry<String, SvcLogicExpression> curEnt = iter.next();
- String curName = curEnt.getKey();
- String lhsVarName = curName;
-
- // Resolve LHS of assignment (could contain index variables)
- try {
- // Backticks symbolize the variable should be handled as an expression instead of as a variable
- if (curName.trim().startsWith("`")) {
- int lastParen = curName.lastIndexOf("`");
- String evalExpr = curName.trim().substring(1, lastParen);
- SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr);
- lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx);
- } else {
- SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName);
- lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx);
- }
- } catch (Exception e) {
- LOG.warn("Caught exception trying to resolve variable name (" + curName + ")", e);
- }
-
- boolean setValue = true;
-
- if (curName.endsWith(".")) {
- // Copy subtree - value should be a variable name
- SvcLogicExpression curValue = curEnt.getValue();
-
- if (curValue != null) {
- String rhsRoot = curValue.toString();
-
- if ((rhsRoot != null) && (rhsRoot.length() > 0)) {
- if (rhsRoot.endsWith(".")) {
- rhsRoot = rhsRoot.substring(0, rhsRoot.length() - 1);
- }
-
- // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved
- try {
- SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot);
- rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx);
- } catch (Exception e) {
- LOG.warn("Caught exception trying to resolve variable name (" + rhsRoot + ")", e);
- }
-
- // See if the parameters are reversed (copying service-data to input) .. this
- // was done as a workaround to earlier issue
- if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) {
- LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead");
- lhsVarName = rhsRoot + ".";
- rhsRoot = curName.substring(0, curName.length() - 1);
- }
-
- rhsRoot = rhsRoot + ".";
- String lhsPrefix = lhsVarName;
-
- if (lhsPrefix.endsWith(".")) {
- lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1);
- }
-
- HashMap<String, String> parmsToAdd = new HashMap<String, String>();
-
- for (String sourceVarName : ctx.getAttributeKeySet()) {
- if (sourceVarName.startsWith(rhsRoot)) {
- String targetVar = lhsPrefix + "." + sourceVarName.substring(rhsRoot.length());
- LOG.debug("Copying {} value to {}", sourceVarName, targetVar);
- parmsToAdd.put(targetVar, ctx.getAttribute(sourceVarName));
- }
- }
- for (String newParmName : parmsToAdd.keySet()) {
- ctx.setAttribute(newParmName, parmsToAdd.get(newParmName));
- }
- } else {
- // If RHS is empty, unset attributes in LHS
- LinkedList<String> parmsToRemove = new LinkedList<String>();
- String prefix = lhsVarName + ".";
- String arrayPrefix = lhsVarName + "[";
- //Clear length value in case an array exists with this prefix
- String lengthParamName = lhsVarName + "_length";
- LOG.debug("Unsetting {} because prefix {} is being cleared.", lengthParamName, prefix);
-
- for (String curCtxVarname : ctx.getAttributeKeySet()) {
- 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 {} because matching value {} starts with the prefix {}", curCtxVarname, curCtxVarnameMatchingValue, prefix);
- parmsToRemove.add(curCtxVarname);
- }else if (curCtxVarnameMatchingValue.startsWith(lengthParamName)) {
- LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName);
- parmsToRemove.add(curCtxVarname);
- }else if (curCtxVarnameMatchingValue.startsWith(arrayPrefix)) {
- LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix);
- parmsToRemove.add(curCtxVarname);
- }
- }
- for (String parmName : parmsToRemove) {
- ctx.setAttribute(parmName, null);
- }
- }
- }
- } else {
- if (ifunset) {
- String ctxValue = ctx.getAttribute(lhsVarName);
- if ((ctxValue != null) && (ctxValue.length() > 0)) {
- setValue = false;
- LOG.debug("Attribute {} already set and only-if-unset is true, so not overriding", lhsVarName);
- }
- }
- if (setValue) {
- 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);
- }
- ctx.setAttribute(lhsVarName, curValue);
- }
- }
- }
- }
-}
-
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java
index ecfe6b69..540c04ef 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java
@@ -24,9 +24,6 @@ package org.onap.ccsdk.sli.core.sli.provider;
import java.util.HashMap;
import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +53,7 @@ public class SvcLogicAdaptorFactory {
return adaptorMap.get(name);
} else {
- SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name);
+ SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.getInstance().resolve(name);
if (adaptor != null) {
registerAdaptor(adaptor);
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java
index d2b733fc..f10976a5 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java
@@ -1,5 +1,10 @@
package org.onap.ccsdk.sli.core.sli.provider;
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -7,35 +12,63 @@ import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SvcLogicClassResolver {
- private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class);
+public class SvcLogicClassResolver implements SvcLogicResolver {
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class);
+ private static SvcLogicClassResolver instance = new SvcLogicClassResolver();
- public static Object resolve(String className) {
+ private SvcLogicClassResolver() {
+ }
- Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class);
+ public static SvcLogicClassResolver getInstance() {
+ return instance;
+ }
- if (bundle == null) {
- // Running outside OSGi container (e.g. jUnit). Use Reflection
- // to resolve class
- try {
- return(Class.forName(className).newInstance());
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ public Object resolve(String className) {
- LOG.error("Could not resolve class "+className, e);
- return null;
- }
+ Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class);
- } else {
- BundleContext bctx = bundle.getBundleContext();
- ServiceReference sref = bctx.getServiceReference(className);
- if (sref != null) {
- return bctx.getService(sref);
- } else {
+ if (bundle == null) {
+ // Running outside OSGi container (e.g. jUnit). Use Reflection
+ // to resolve class
+ try {
+ return (Class.forName(className).newInstance());
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOG.warn("Could not find service reference object for class " + className);
- return null;
- }
- }
- }
+ LOG.error("Could not resolve class " + className, e);
+ return null;
+ }
+
+ } else {
+ BundleContext bctx = bundle.getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(className);
+ if (sref != null) {
+ return bctx.getService(sref);
+ } else {
+
+ LOG.warn("Could not find service reference object for class " + className);
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public SvcLogicResource getSvcLogicResource(String resourceName) {
+ return (SvcLogicResource) resolve(resourceName);
+ }
+
+ @Override
+ public SvcLogicRecorder getSvcLogicRecorder(String recorderName) {
+ return (SvcLogicRecorder) resolve(recorderName);
+ }
+
+ @Override
+ public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) {
+ return (SvcLogicJavaPlugin) resolve(pluginName);
+ }
+
+ @Override
+ public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) {
+ return SvcLogicAdaptorFactory.getInstance(adaptorName);
+ }
}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java
deleted file mode 100644
index c9446bda..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-import org.onap.ccsdk.sli.core.sli.SvcLogicAtom;
-import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression;
-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.SvcLogicFunctionCall;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicVariableTerm;
-import org.onap.ccsdk.sli.core.sli.SvcLogicAtom.AtomType;
-import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression.OperatorType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SvcLogicExpressionResolver {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SvcLogicExpressionResolver.class);
-
- public static String evaluate(SvcLogicExpression expr, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
- if (expr == null) {
- return (null);
- }
-
-
-
- if (expr instanceof SvcLogicAtom) {
- SvcLogicAtom atom = (SvcLogicAtom) expr;
-
- AtomType atomType = atom.getAtomType();
- switch (atomType) {
- case NUMBER:
- case STRING:
- return (atom.toString());
- case CONTEXT_VAR:
- case IDENTIFIER:
-
- String varName = resolveVariableName(atom, node, ctx);
-
- if (atomType == AtomType.CONTEXT_VAR)
- {
- LOG.trace("Evaluating context variable $"+varName);
-
- String varValue = ctx.getAttribute(varName);
-
- if (varValue == null) {
- LOG.trace("Context variable $"+varName+" unset - treating as empty string");
- varValue = "";
- }
-
- return (varValue);
- }
- SvcLogicExpression parm = node.getParameter(varName);
- if (parm != null) {
- LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr());
-
- return (evaluate(parm, node, ctx));
- }
- else
- {
- return(varName);
- }
- default:
- return(null);
- }
-
- } else if (expr instanceof SvcLogicBinaryExpression) {
- SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr;
- List<OperatorType> operators = binExpr.getOperators();
- if (operators.isEmpty())
- {
- 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
- {
- if (operands.isEmpty())
- {
- LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null");
- }
- else
- {
- LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null");
- }
- return(null);
- }
- }
- switch (operators.get(0)) {
- case addOp:
- case subOp:
- case multOp:
- case divOp:
- return(evalArithExpression(binExpr, node, ctx));
- case equalOp:
- case neOp:
- case ltOp:
- case leOp:
- case gtOp:
- case geOp:
- return (evalCompareExpression(binExpr, node, ctx));
- case andOp:
- case orOp:
- return(evalLogicExpression(binExpr, node, ctx));
-
- default:
- return(null);
- }
- }
- else if (expr instanceof SvcLogicFunctionCall)
- {
- return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx));
- }
- else
- {
- throw new SvcLogicException("Unrecognized expression type ["+expr+"]");
- }
- }
-
- private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- List<SvcLogicExpression> operands = binExpr.getOperands();
- List<OperatorType> operators = binExpr.getOperators();
- if (operands.size() != (operators.size()+1))
- {
- throw new SvcLogicException("Invalid expression ("+binExpr+")");
- }
- String retval = evaluate(operands.get(0), node, ctx);
- String retsval = retval;
- long retlval = 0;
- boolean valueIsLong = false;
-
- int i = 1;
- try
- {
-
- if ((retval.length() > 0) && StringUtils.isNumeric(retval))
- {
- retlval = Long.parseLong(retval);
- valueIsLong = true;
- }
- for (OperatorType operator: operators)
- {
- String curOperandValue = evaluate(operands.get(i++), node, ctx);
- switch(operator) {
- case addOp:
- retsval = retsval + curOperandValue;
- if (valueIsLong)
- {
- if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) )
- {
- retlval = retlval + Long.parseLong(curOperandValue);
- }
- else
- {
- valueIsLong = false;
- }
- }
- break;
- case subOp:
- retlval = retlval - Long.parseLong(curOperandValue);
- break;
- case multOp:
- retlval = retlval * Long.parseLong(curOperandValue);
- break;
- case divOp:
- retlval = retlval / Long.parseLong(curOperandValue);
- break;
- }
-
- }
- }
- catch (NumberFormatException e1)
- {
- throw new SvcLogicException("Illegal value in arithmetic expression", e1);
- }
-
- if (valueIsLong)
- {
- return("" + retlval);
- }
- else
- {
- return(retsval);
- }
-
- }
-
-
-
- private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException
- {
-
- List<OperatorType> operators = expr.getOperators();
- List<SvcLogicExpression> operands = expr.getOperands();
-
- if ((operators.size() != 1) || (operands.size() != 2))
- {
- throw new SvcLogicException ("Invalid comparison expression : "+expr);
- }
-
- OperatorType operator = operators.get(0);
- String op1Value = evaluate(operands.get(0), node, ctx);
- String op2Value = evaluate(operands.get(1), node, ctx);
-
- if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value)))
- {
- try
- {
- double op1dbl = Double.parseDouble(op1Value);
- double op2dbl = Double.parseDouble(op2Value);
-
- switch(operator)
- {
- case equalOp:
- return(Boolean.toString(op1dbl == op2dbl));
- case neOp:
- return(Boolean.toString(op1dbl != op2dbl));
- case ltOp:
- return(Boolean.toString(op1dbl < op2dbl));
- case leOp:
- return(Boolean.toString(op1dbl <= op2dbl));
- case gtOp:
- return(Boolean.toString(op1dbl > op2dbl));
- case geOp:
- return(Boolean.toString(op1dbl >= op2dbl));
- default:
- return(null);
- }
- }
- catch (NumberFormatException e)
- {
- throw new SvcLogicException("Caught exception trying to compare numeric values", e);
- }
- }
- else
- {
-
- int compResult = 0;
-
- if (op1Value == null) {
- compResult = -1;
- } else if (op2Value == null ) {
- compResult = 1;
- } else {
- compResult = op1Value.compareToIgnoreCase(op2Value);
- }
-
- switch(operator)
- {
- case equalOp:
- return(Boolean.toString(compResult == 0));
- case neOp:
- return(Boolean.toString(compResult != 0));
- case ltOp:
- return(Boolean.toString(compResult < 0));
- case leOp:
- return(Boolean.toString(compResult <= 0));
- case gtOp:
- return(Boolean.toString(compResult > 0));
- case geOp:
- return(Boolean.toString(compResult >= 0));
- default:
- return(null);
- }
- }
-
- }
-
- private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException
- {
- boolean retval;
-
- List<SvcLogicExpression> operands = expr.getOperands();
- List<OperatorType> operators = expr.getOperators();
-
- if (operands.size() != (operators.size()+1))
- {
- throw new SvcLogicException("Invalid expression ("+expr+")");
- }
-
- try
- {
- retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx));
- int i = 1;
- for (OperatorType operator : operators)
- {
- if (operator == OperatorType.andOp)
- {
- retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx));
- }
- else
- {
-
- retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx));
- }
-
- }
- }
- catch (Exception e)
- {
- throw new SvcLogicException("Invalid expression ("+expr+")");
- }
-
-
- return(Boolean.toString(retval));
- }
-
- private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException
- {
- String funcName = func.getFunctionName();
- List<SvcLogicExpression> operands = func.getOperands();
-
- if ("length".equalsIgnoreCase(funcName))
- {
-
- if (operands.size() == 1)
- {
- String opValue = evaluate(operands.get(0), node, ctx);
- return(""+opValue.length());
- }
- else
- {
- throw new SvcLogicException("Invalid call to length() function");
- }
- }
- else if ("substr".equalsIgnoreCase(funcName))
- {
- if (operands.size() == 3)
- {
- String op1Value = evaluate(operands.get(0), node, ctx);
- String op2Value = evaluate(operands.get(1), node, ctx);
- String op3Value = evaluate(operands.get(2), node, ctx);
-
- if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value))
- {
- throw new SvcLogicException("Invalid arguments to substr() function");
- }
-
- try
- {
- return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value)));
- }
- catch (Exception e)
- {
- throw new SvcLogicException("Caught exception trying to take substring", e);
- }
- }
- else
- {
-
- throw new SvcLogicException("Invalid call to substr() function");
- }
-
- }
- else if ("toUpperCase".equalsIgnoreCase(funcName))
- {
- if (operands.size() == 1)
- {
- String opValue = evaluate(operands.get(0), node, ctx);
- if (opValue != null) {
- return(opValue.toUpperCase());
- } else {
- return("");
- }
- }
- else
- {
- throw new SvcLogicException("Invalid call to toUpperCase() function");
- }
- }
- else if ("toLowerCase".equalsIgnoreCase(funcName))
- {
- if (operands.size() == 1)
- {
- String opValue = evaluate(operands.get(0), node, ctx);
- if (opValue != null) {
- return(opValue.toLowerCase());
- } else {
- return("");
- }
- }
- else
- {
- throw new SvcLogicException("Invalid call to toLowerCase() function");
- }
- }
- else if ("convertBase".equalsIgnoreCase(funcName)) {
- int fromBase = 10;
- int toBase = 10;
- String srcString = "";
-
- if (operands.size() == 2)
- {
- fromBase = 10;
- srcString = evaluate(operands.get(0), node, ctx);
- toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx));
- } else if (operands.size() == 3) {
-
- srcString = evaluate(operands.get(0), node, ctx);
- fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx));
- toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx));
- } else {
- throw new SvcLogicException("Invalid call to convertBase() function");
- }
-
- long srcValue = Long.parseLong(srcString, fromBase);
- return(Long.toString(srcValue, toBase));
- }
- else
- {
- throw new SvcLogicException("Unrecognized function ("+funcName+")");
- }
-
- }
-
- public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
- if (expr == null) {
- return (null);
- }
-
-
-
- if (expr instanceof SvcLogicAtom) {
- SvcLogicAtom atom = (SvcLogicAtom) expr;
-
- AtomType atomType = atom.getAtomType();
- StringBuffer varNameBuff = new StringBuffer();
- switch (atomType) {
- case NUMBER:
- return (atom.toString());
- case STRING:
- return("'"+atom.toString()+"'");
- case CONTEXT_VAR:
- case IDENTIFIER:
- boolean needDot = false;
- for (SvcLogicExpression term : atom.getOperands())
- {
- if (needDot)
- {
- varNameBuff.append(".");
- }
- if (term instanceof SvcLogicVariableTerm)
- {
- SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term;
- varNameBuff.append(vterm.getName());
- if (vterm.numOperands() > 0)
- {
- varNameBuff.append("[");
- varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx));
- varNameBuff.append("]");
-
- }
- }
- else
- {
- varNameBuff.append(term.toString());
- }
- needDot = true;
- }
-
- String varName = varNameBuff.toString();
- LOG.debug("Evaluating context variable $"+varName);
- String ctxValue = ctx.getAttribute(varName);
- if (ctxValue == null)
- {
- return(null);
- }
- if (StringUtils.isNumeric(ctxValue))
- {
- return(ctxValue);
- }
- else
- {
- return("'"+ctxValue+"'");
- }
-
- default:
- return(null);
- }
-
- } else if (expr instanceof SvcLogicBinaryExpression) {
- SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr;
- List<OperatorType> operators = binExpr.getOperators();
- List<SvcLogicExpression> operands = binExpr.getOperands();
- if (operators.isEmpty())
- {
- if (operands.size() == 1)
- {
- LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand");
- return(evaluateAsKey(operands.get(0), node, ctx));
- }
- else
- {
- if (operands.isEmpty())
- {
- LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null");
- }
- else
- {
- LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null");
- }
- return(null);
- }
- }
- StringBuffer sbuff = new StringBuffer();
- sbuff.append(evaluateAsKey(operands.get(0), node, ctx));
- int i = 1;
- for (OperatorType operator : operators)
- {
- sbuff.append(" ");
- sbuff.append(operator.toString());
- sbuff.append(" ");
- sbuff.append(evaluateAsKey(operands.get(i++), node,ctx));
- }
- return(sbuff.toString());
- }
- else if (expr instanceof SvcLogicFunctionCall)
- {
- StringBuffer sbuff = new StringBuffer();
- SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr;
- sbuff.append(funcCall.getFunctionName());
- sbuff.append("(");
- boolean needComma = false;
- for (SvcLogicExpression operand : funcCall.getOperands())
- {
- if (needComma)
- {
- sbuff.append(",");
- }
- else
- {
- needComma = true;
- }
- sbuff.append(evaluateAsKey(operand, node, ctx));
- }
- sbuff.append(")");
- return(sbuff.toString());
- }
- else
- {
- throw new SvcLogicException("Unrecognized expression type ["+expr+"]");
- }
- }
-
- public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException
- {
- StringBuffer varNameBuff = new StringBuffer();
-
- boolean needDot = false;
- for (SvcLogicExpression term : atom.getOperands())
- {
- if (needDot)
- {
- varNameBuff.append(".");
- }
- if (term instanceof SvcLogicVariableTerm)
- {
- SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term;
- varNameBuff.append(vterm.getName());
- if (vterm.numOperands() > 0)
- {
- varNameBuff.append("[");
- varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx));
- varNameBuff.append("]");
- }
- }
- else
- {
- varNameBuff.append(term.toString());
- }
- needDot = true;
- }
- return(varNameBuff.toString());
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java
deleted file mode 100644
index 34fdb537..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.MetricLogger;
-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.SvcLogicJavaPlugin;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class SvcLogicNodeExecutor {
-
- public abstract SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException;
-
- private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class);
-
- protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx)
- throws SvcLogicException {
- if (node == null) {
- return null;
- }
-
- return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"),
- node, ctx));
-
- }
-
-
-
- protected SvcLogicAdaptor getAdaptor(String adaptorName) {
- return SvcLogicAdaptorFactory.getInstance(adaptorName);
- }
-
- protected SvcLogicResource getSvcLogicResource(String plugin) {
-
- return((SvcLogicResource) SvcLogicClassResolver.resolve(plugin));
- }
-
- protected SvcLogicRecorder getSvcLogicRecorder(String plugin) {
- return((SvcLogicRecorder) SvcLogicClassResolver.resolve(plugin));
- }
-
- protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){
- return((SvcLogicJavaPlugin) SvcLogicClassResolver.resolve(pluginName));
-
- }
-
- protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) {
- MetricLogger.resetContext();
- 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);
- }
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java
deleted file mode 100644
index 9debd6bc..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * onap
- * ================================================================================
- * Copyright (C) 2016 - 2017 ONAP
- * ================================================================================
- * 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.onap.ccsdk.sli.core.sli.provider;
-
-import java.util.Properties;
-
-public interface SvcLogicPropertiesProvider {
-
- public Properties getProperties();;
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java
index a9992a09..c4680cce 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java
@@ -31,6 +31,7 @@ import java.util.Vector;
import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
import org.onap.ccsdk.sli.core.utils.JREFileResolver;
import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver;
import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver;
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java
index 3f24adff..a23594ee 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java
@@ -22,43 +22,15 @@
package org.onap.ccsdk.sli.core.sli.provider;
import java.util.Properties;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-public interface SvcLogicService {
+public interface SvcLogicService extends SvcLogicServiceBase {
String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService";
- // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException;
- /**
- * Check for existence of a directed graph
- * @param module - module name
- * @param rpc - rpc name
- * @param version - version. If null, looks for active version
- * @param mode - mode (sync/async)
- * @return true if directed graph found, false otherwise
- * @throws SvcLogicException
- */
- boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException;
-
- /**
- * Execute a directed graph
- *
- * @param module - module name
- * @param rpc - rpc name
- * @param version - version. If null, use active version
- * @param mode - mode (sync/async)
- * @param parms - parameters, used to set SvcLogicContext attributes
- * @return final values of attributes from SvcLogicContext, as Properties
- * @throws SvcLogicException
- *
- *
- * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead
- */
@Deprecated
Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException;
@@ -76,10 +48,5 @@ public interface SvcLogicService {
*/
Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException;
- SvcLogicStore getStore() throws SvcLogicException;
-
- SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException;
-
- SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException;
}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
index c7942563..23d703c2 100755
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
@@ -23,20 +23,20 @@
package org.onap.ccsdk.sli.core.sli.provider;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Properties;
+
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
-import org.onap.ccsdk.sli.core.sli.ExitNodeException;
import org.onap.ccsdk.sli.core.sli.MetricLogger;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -44,71 +44,32 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-public class SvcLogicServiceImpl implements SvcLogicService {
-
- 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());
- put("exit", new ExitNodeExecutor());
- }
- };
+public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService {
private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class);
- protected HashMap<String, SvcLogicNodeExecutor> nodeExecutors = null;
protected BundleContext bctx = null;
- protected Properties properties;
- protected SvcLogicStore store;
- private static final String CURRENT_GRAPH="currentGraph";
public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException {
+ super(null);
+ this.resolver = SvcLogicClassResolver.getInstance();
properties = resourceProvider.getProperties();
- getStore();
+ this.store = getStore();
}
public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc)
throws SvcLogicException {
+ super(null);
+ this.resolver = SvcLogicClassResolver.getInstance();
properties = resourceProvider.getProperties();
- store = new SvcLogicDblibStore(dbSvc);
- }
-
-
- protected void registerExecutors() {
-
- LOG.info("Entered register executors");
- for (String nodeType : BUILTIN_NODES.keySet()) {
- LOG.info("SLI - registering node executor for node type " + nodeType);
- registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
- }
- LOG.info("Done registerExecutors");
+ this.store = new SvcLogicDblibStore(dbSvc);
}
public void registerExecutor(ServiceReference sr) {
String nodeName = (String) sr.getProperty("nodeType");
if (nodeName != null) {
-
- SvcLogicNodeExecutor executor;
-
+ AbstractSvcLogicNodeExecutor executor;
try {
- executor = (SvcLogicNodeExecutor) bctx.getService(sr);
+ executor = (AbstractSvcLogicNodeExecutor) bctx.getService(sr);
} catch (Exception e) {
LOG.error("Cannot get service executor for {}", nodeName, e);
return;
@@ -117,14 +78,6 @@ public class SvcLogicServiceImpl implements SvcLogicService {
}
}
- public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) {
- if (nodeExecutors == null) {
- nodeExecutors = new HashMap<>();
- }
- LOG.info("SLI - registering executor for node type {}", nodeName);
- nodeExecutors.put(nodeName, executor);
- }
-
public void unregisterExecutor(ServiceReference sr) {
String nodeName = (String) sr.getProperty("nodeType");
@@ -133,67 +86,6 @@ public class SvcLogicServiceImpl implements SvcLogicService {
}
}
- public void unregisterExecutor(String nodeName) {
- LOG.info("SLI - unregistering executor for node type {}", nodeName);
- nodeExecutors.remove(nodeName);
- }
-
- public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException {
- if (nodeExecutors == null) {
- registerExecutors();
- }
-
- // Set service name in MDC to reference current working directed graph
- MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion());
-
- MDC.put(CURRENT_GRAPH, graph.toString());
-
- SvcLogicNode curNode = graph.getRootNode();
- LOG.info("About to execute graph {}", graph.toString());
- try {
- while (curNode != null) {
-
- SvcLogicNode nextNode = executeNode(curNode, ctx);
- curNode = nextNode;
- }
- } catch (ExitNodeException e) {
- LOG.debug("SvcLogicServiceImpl caught ExitNodeException");
- }
- MDC.remove("nodeId");
- MDC.remove(CURRENT_GRAPH);
-
- return (ctx);
- }
-
- public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
- if (node == null) {
- 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());
- }
-
- SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType());
-
- if (executor != null) {
- LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(),
- executor.getClass().getName());
-
- MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")");
- return (executor.execute(this, node, ctx));
- } else {
- throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type");
- }
- }
-
- @Override
- public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
- return (store.hasGraph(module, rpc, version, mode));
- }
-
@Override
public Properties execute(String module, String rpc, String version, String mode, Properties props)
throws SvcLogicException {
@@ -218,12 +110,16 @@ public class SvcLogicServiceImpl implements SvcLogicService {
ctx.setAttribute(CURRENT_GRAPH, graph.toString());
ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID"));
ctx.setDomDataBroker(domDataBroker);
-
execute(graph, ctx);
-
return (ctx.toProperties());
}
+
+ @Override
+ protected void resetContext() {
+ MetricLogger.resetContext();
+ }
+ @Override
public SvcLogicStore getStore() throws SvcLogicException {
// Create and initialize SvcLogicStore object - used to access
// saved service logic.
@@ -246,4 +142,5 @@ public class SvcLogicServiceImpl implements SvcLogicService {
return store;
}
+
}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java
deleted file mode 100644
index 592fb288..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SwitchNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SwitchNodeExecutor.class);
-
- @Override
-
- public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
-
-
- String testResult = evaluateNodeTest(node, ctx);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Executing switch node");
-
-
- LOG.debug("test expression (" + node.getAttribute("test")
- + ") evaluates to " + testResult);
- }
-
- SvcLogicNode nextNode = node.getOutcomeValue(testResult);
-
- if (LOG.isDebugEnabled()) {
- if (nextNode != null) {
- LOG.debug("Next node to execute is node " + nextNode.getNodeId());
- } else {
- LOG.debug("No next node found");
- }
- }
- return (nextNode);
-
- }
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java
deleted file mode 100644
index a783df41..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-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;
-import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class UpdateNodeExecutor extends SvcLogicNodeExecutor {
-
- private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class);
-
- @Override
- public SvcLogicNode execute(SvcLogicService 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 pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx);
-
-
- Map<String, String> parmMap = new HashMap<String, String>();
-
- 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);
- }
- }
-
- String outValue = "failure";
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("save node encountered - looking for resource class " + plugin);
- }
-
-
- SvcLogicResource resourcePlugin = getSvcLogicResource(plugin);
-
-
- if (resourcePlugin != null) {
-
- try {
- switch (resourcePlugin.update(resourceType, 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));
- }
-
-}
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java
deleted file mode 100644
index b717aa98..00000000
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * 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
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.provider;
-
-import org.onap.ccsdk.sli.core.sli.BreakNodeException;
-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.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(SvcLogicService 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);
- }
-
-}