summaryrefslogtreecommitdiffstats
path: root/sli/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'sli/common/src')
-rwxr-xr-xsli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g466
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java46
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java45
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java45
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java302
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java301
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java42
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java174
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java149
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java248
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java533
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java46
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java316
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java44
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java51
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java99
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java80
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java184
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java34
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java895
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java456
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java598
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java43
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java30
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java53
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java37
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java96
-rw-r--r--sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java77
-rw-r--r--sli/common/src/main/resources/crAseNetwork.sql82
-rwxr-xr-xsli/common/src/main/resources/svclogic.xsd334
-rwxr-xr-xsli/common/src/main/yang/ase-network.yang179
-rwxr-xr-xsli/common/src/main/yang/ase-type.yang561
-rwxr-xr-xsli/common/src/main/yang/ase.yang558
-rw-r--r--sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java69
-rw-r--r--sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java69
-rw-r--r--sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java163
-rw-r--r--sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml70
-rw-r--r--sli/common/src/test/resources/EvcPortSvcLogic_v100.xml263
-rw-r--r--sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml89
-rw-r--r--sli/common/src/test/resources/bad_neutron_logic_v11.xml61
-rwxr-xr-xsli/common/src/test/resources/expression.tests19
-rw-r--r--sli/common/src/test/resources/mergetest.xml54
-rw-r--r--sli/common/src/test/resources/neutron_logic_v10.xml56
-rw-r--r--sli/common/src/test/resources/nonsense.xml24
-rwxr-xr-xsli/common/src/test/resources/parser-bad.tests3
-rwxr-xr-xsli/common/src/test/resources/parser-good.tests2
-rw-r--r--sli/common/src/test/resources/simplelogger.properties24
-rw-r--r--sli/common/src/test/resources/svclogic.properties26
-rw-r--r--sli/common/src/test/resources/svclogic.sh32
-rwxr-xr-xsli/common/src/test/resources/svclogic.xsd323
50 files changed, 8151 insertions, 0 deletions
diff --git a/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4
new file mode 100755
index 000000000..51f401690
--- /dev/null
+++ b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4
@@ -0,0 +1,66 @@
+grammar ExprGrammar;
+
+options {
+ language = Java;
+}
+
+
+COMPAREOP : '==' | '!=' | '>' | '<' | '>=' | '<=';
+
+RELOP : 'and' | 'or';
+
+ADDOP : '+' | '-';
+
+MULTOP : '/' | '*';
+
+NUMBER : ('0'..'9')+;
+
+STRING : '\'' ~[\']* '\'';
+
+IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*;
+
+// CONTEXT_VAR : '$' IDENTIFIER;
+
+WS: [ \n\t\r]+ -> skip;
+
+constant : NUMBER | STRING ;
+
+variableLead : ('$')? variableTerm ;
+
+variableTerm : IDENTIFIER ('[' expr ']')? ;
+
+variable : variableLead ('.' variableTerm)* ('.')?;
+
+// variable : CONTEXT_VAR ( '[' expr ']' )? ('.' IDENTIFIER )? ;
+
+atom : constant | variable;
+
+
+expr : atom
+ | parenExpr
+ | multExpr
+ | addExpr
+ | compareExpr
+ | relExpr
+ | funcExpr;
+
+parenExpr : '(' expr ')';
+
+term : atom | parenExpr | funcExpr;
+
+multExpr : term (MULTOP term)*;
+
+addExpr : multExpr (ADDOP multExpr)*;
+
+compareExpr : addExpr COMPAREOP addExpr;
+
+relExpr : compareExpr (RELOP expr)*;
+
+funcExpr : IDENTIFIER '(' expr (',' expr)* ')';
+
+
+
+
+
+
+
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java
new file mode 100644
index 000000000..3e355baad
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class BreakNodeException extends SvcLogicException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public BreakNodeException()
+ {
+ super();
+ }
+
+ public BreakNodeException(String message)
+ {
+ super(message);
+ }
+
+ public BreakNodeException(String message, Throwable t)
+ {
+ super(message, t);
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java
new file mode 100644
index 000000000..fa1308f0e
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class ConfigurationException extends SvcLogicException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public ConfigurationException()
+ {
+ super();
+ }
+
+ public ConfigurationException(String msg)
+ {
+ super(msg);
+ }
+
+ public ConfigurationException(String msg, Throwable t)
+ {
+ super(msg, t);
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java
new file mode 100644
index 000000000..beb22b0b8
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class DuplicateValueException extends SvcLogicException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public DuplicateValueException()
+ {
+ super();
+ }
+
+ public DuplicateValueException(String message)
+ {
+ super(message);
+ }
+
+ public DuplicateValueException(String message, Throwable t)
+ {
+ super(message, t);
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java
new file mode 100644
index 000000000..5e5b621b0
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java
@@ -0,0 +1,302 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.sql.rowset.CachedRowSet;
+
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class MessageWriter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class);
+
+ private static final String DBLIB_SERVICE = "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager";
+ private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES";
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+
+ private static final String INCOMING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeIncomingRequests";
+ private static final String OUTGOING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeOutgoingRequests";
+
+ private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+
+ private static DbLibService dbLibService = null;
+
+ private static boolean incomingEnabled = false;
+ private static boolean outgoingEnabled = false;
+
+ private static boolean initialized = false;
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private static void init() {
+ if (initialized)
+ return;
+
+ initialized = true;
+
+ // Read properties
+ Properties props = new Properties();
+ String propPath = System.getenv(SVCLOGIC_PROP_VAR);
+
+ if (propPath == null) {
+ String propDir = System.getenv(SDNC_CONFIG_DIR);
+ if (propDir == null) {
+ propDir = "/opt/sdnc/data/properties";
+ }
+ propPath = propDir + "/svclogic.properties";
+ LOG.warn("Environment variable " + SVCLOGIC_PROP_VAR + " unset - defaulting to " + propPath);
+ }
+
+ File propFile = new File(propPath);
+
+ if (!propFile.exists()) {
+ LOG.warn("Property file does not exist: " + propPath);
+ }
+
+ try {
+ props.load(new FileInputStream(propFile));
+ } catch (Exception e) {
+ LOG.warn("Error loading property file: " + propPath, e);
+ }
+
+ incomingEnabled = Boolean.valueOf(props.getProperty(INCOMING_PROPERTY_NAME, "false"));
+ outgoingEnabled = Boolean.valueOf(props.getProperty(OUTGOING_PROPERTY_NAME, "false"));
+
+ LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled);
+ LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled);
+
+ if (dbLibService != null)
+ return;
+
+ BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext();
+
+ ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE);
+
+ if (sref == null) {
+ LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
+ } else {
+ dbLibService = (DbLibService) bctx.getService(sref);
+ if (dbLibService == null) {
+ LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
+ }
+ }
+ }
+
+ public static void saveOutgoingRequest(
+ String requestId,
+ String serviceInstanceId,
+ String targetUrl,
+ String request) {
+ try {
+ init();
+
+ if (!outgoingEnabled)
+ return;
+
+ if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0)
+ serviceInstanceId = "NA";
+
+ int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId) + 1;
+ String now = df.format(new Date());
+
+ String sql = "INSERT INTO OUTGOING_MESSAGE (\n" +
+ " request_id, sequence_number, service_instance_id, target_url, request, start_time)\n" +
+ "VALUES (?, ?, ?, ?, ?, ?)";
+
+ ArrayList<String> data = new ArrayList<>();
+ data.add(requestId);
+ data.add(String.valueOf(seqnum));
+ data.add(serviceInstanceId);
+ data.add(targetUrl);
+ data.add(request);
+ data.add(now);
+
+ dbLibService.writeData(sql, data, null);
+
+ } catch (Exception e) {
+ LOG.warn("Failed to save outgoing request for request-id: " + requestId, e);
+ }
+ }
+
+ public static void saveOutgoingResponse(String requestId, int httpResponseCode, String response) {
+ try {
+ init();
+
+ if (!outgoingEnabled)
+ return;
+
+ int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId);
+ if (seqnum == 0) {
+ LOG.warn("Failed to save outgoing response for request-id: " + requestId +
+ ": Request record not found in OUTGOING_MESSAGE");
+ return;
+ }
+
+ String now = df.format(new Date());
+
+ String sql = "UPDATE OUTGOING_MESSAGE SET http_response_code = ?, response = ?,\n" +
+ " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" +
+ "WHERE request_id = ? AND sequence_number = ?";
+
+ ArrayList<String> data = new ArrayList<>();
+ data.add(String.valueOf(httpResponseCode));
+ data.add(response);
+ data.add(now);
+ data.add(requestId);
+ data.add(String.valueOf(seqnum));
+
+ dbLibService.writeData(sql, data, null);
+
+ } catch (Exception e) {
+ LOG.warn("Failed to save outgoing response for request-id: " + requestId, e);
+ }
+ }
+
+ public static void saveIncomingRequest(
+ String requestId,
+ String serviceInstanceId,
+ String requestHost,
+ String request) {
+ try {
+ init();
+
+ if (!incomingEnabled)
+ return;
+
+ if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0)
+ serviceInstanceId = "NA";
+
+ int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId) + 1;
+ String now = df.format(new Date());
+
+ String sql = "INSERT INTO INCOMING_MESSAGE (\n" +
+ " request_id, sequence_number, service_instance_id, request_host, request, start_time)\n" +
+ "VALUES (?, ?, ?, ?, ?, ?)";
+
+ ArrayList<String> data = new ArrayList<>();
+ data.add(requestId);
+ data.add(String.valueOf(seqnum));
+ data.add(serviceInstanceId);
+ data.add(requestHost);
+ data.add(request);
+ data.add(now);
+
+ dbLibService.writeData(sql, data, null);
+
+ } catch (Exception e) {
+ LOG.warn("Failed to save incoming request for request-id: " + requestId, e);
+ }
+ }
+
+ public static void saveIncomingResponse(String requestId, int httpResponseCode, String response) {
+ try {
+ init();
+
+ if (!incomingEnabled)
+ return;
+
+ int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId);
+ if (seqnum == 0) {
+ LOG.warn("Failed to save response for request-id: " + requestId +
+ ": Request record not found in INCOMING_MESSAGE");
+ return;
+ }
+
+ String now = df.format(new Date());
+
+ String sql = "UPDATE INCOMING_MESSAGE SET http_response_code = ?, response = ?,\n" +
+ " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" +
+ "WHERE request_id = ? AND sequence_number = ?";
+
+ ArrayList<String> data = new ArrayList<>();
+ data.add(String.valueOf(httpResponseCode));
+ data.add(response);
+ data.add(now);
+ data.add(requestId);
+ data.add(String.valueOf(seqnum));
+
+ dbLibService.writeData(sql, data, null);
+
+ } catch (Exception e) {
+ LOG.warn("Failed to save response for request-id: " + requestId, e);
+ }
+ }
+
+ public static String getServiceInstanceId(String requestId) throws SQLException {
+ init();
+
+ String sql = "SELECT service_instance_id FROM OUTGOING_MESSAGE WHERE request_id = '" + requestId +
+ "' ORDER BY sequence_number DESC";
+
+ CachedRowSet rs = null;
+ try {
+ rs = dbLibService.getData(sql, null, null);
+ if (rs.next()) {
+ return rs.getString("service_instance_id");
+ }
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ LOG.warn("Failed to close CachedRowSet", e);
+ }
+ }
+ }
+ return null;
+ }
+
+ private static int getLastSequenceNumber(String tableName, String requestId) throws SQLException {
+ String sql = "SELECT sequence_number FROM " + tableName + " WHERE request_id = '" + requestId +
+ "' ORDER BY sequence_number DESC";
+
+ CachedRowSet rs = null;
+ try {
+ rs = dbLibService.getData(sql, null, null);
+ if (rs.next()) {
+ return rs.getInt("sequence_number");
+ }
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ LOG.warn("Failed to close CachedRowSet", e);
+ }
+ }
+ }
+ return 0;
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java
new file mode 100644
index 000000000..14b1f008b
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java
@@ -0,0 +1,301 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ *
+ */
+package org.openecomp.sdnc.sli;
+
+import java.net.InetAddress;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+/**
+ * @author dt5972
+ *
+ */
+public class MetricLogger {
+
+ private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class);
+ private static final Logger METRIC = LoggerFactory.getLogger("org.openecomp.sdnc.filters.metric");
+
+ public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp";
+ public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp";
+ public static final String REQUEST_ID = "X-ECOMP-RequestID";
+ public static final String SERVICE_INSTANCE_ID = "X-ECOMP-ServiceInstanceID";
+ public static final String SERVICE_NAME = "X-ECOMP-ServiceName";
+ public static final String PARTNER_NAME = "X-ECOMP-PartnerName";
+ public static final String TARGET_ENTITY = "X-ECOMP-TargetEntity";
+ public static final String TARGET_SERVICE_NAME = "X-ECOMP-TargetServiceName";
+ public static final String STATUS_CODE = "X-ECOMP-StatusCode";
+ public static final String RESPONSE_CODE = "X-ECOMP-ResponseCode";
+ public static final String RESPONSE_DESCRIPTION = "X-ECOMP-ResponseDescription";
+ public static final String INSTANCE_UUID = "X-ECOMP-InstanceUUID";
+ public static final String CATEGORY_LOG_LEVEL = "X-ECOMP-CategoryLogLevel";
+ public static final String SEVERITY = "X-ECOMP-Severity";
+ public static final String SERVER_IP_ADDRESS = "X-ECOMP-ServerIpAddress";
+ public static final String ELAPSED_TIME = "X-ECOMP-ElapsedTime";
+ public static final String SERVER = "X-ECOMP-Server";
+ public static final String CLIENT_IP = "X-ECOMP-ClientIp";
+ public static final String CLASS_NAME = "X-ECOMP-ClassName";
+ public static final String TARGET_VIRTUAL_ENTITY = "X-ECOMP-TargetVirtualEntity";
+
+ private long beginTimestamp;
+ private String lastMsg = null;
+
+ public MetricLogger() {
+ beginTimestamp = System.currentTimeMillis();
+
+ try {
+ InetAddress localhost = InetAddress.getLocalHost();
+ setServerIpAddress(localhost.getHostAddress());
+ setServer(localhost.getCanonicalHostName());
+ } catch (Exception e) {
+ KARAF.error("Could not get localhost", e);
+ }
+
+ }
+
+
+ public String getBeginTimestamp() {
+ return MDC.get(BEGIN_TIMESTAMP);
+ }
+
+ private void setBeginTimestamp(long beginTimestamp) {
+ this.beginTimestamp = beginTimestamp;
+ MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(beginTimestamp));
+ }
+
+ public String getEndTimestamp() {
+ return MDC.get(END_TIMESTAMP);
+ }
+
+ private void setEndTimestamp(long endTimestamp) {
+ // Set MDC with formatted time stamp
+ MDC.put(END_TIMESTAMP, MetricLogger.asIso8601(endTimestamp));
+
+ // Set elapsed time
+ setElapsedTime(endTimestamp - beginTimestamp);
+
+ }
+
+ public String getRequestID() {
+ return MDC.get(REQUEST_ID);
+ }
+
+
+ public String getServiceInstanceID() {
+ return MDC.get(SERVICE_INSTANCE_ID);
+ }
+
+ private void setServiceInstanceID(String svcInstanceId) {
+ MDC.put(SERVICE_INSTANCE_ID, svcInstanceId);
+ }
+
+ public String getServiceName() {
+ return MDC.get(SERVICE_NAME);
+ }
+
+ private void setServiceName(String svcName) {
+ MDC.put(SERVICE_NAME, svcName);
+ }
+
+ public String getPartnerName() {
+ return MDC.get(PARTNER_NAME);
+ }
+
+ private void setPartnerName(String partnerName) {
+ MDC.put(PARTNER_NAME, partnerName);
+ }
+
+ public String getTargetEntity() {
+ return MDC.get(TARGET_ENTITY);
+ }
+
+ private void setTargetEntity(String targetEntity) {
+ MDC.put(TARGET_ENTITY, targetEntity);
+ }
+
+ public String getTargetServiceName() {
+ return MDC.get(TARGET_SERVICE_NAME);
+ }
+
+ private void setTargetServiceName(String targetServiceName) {
+ MDC.put(TARGET_SERVICE_NAME, targetServiceName);
+ }
+
+ public String getStatusCode() {
+ return MDC.get(STATUS_CODE);
+ }
+
+ private void setStatusCode(String statusCode) {
+ MDC.put(STATUS_CODE, statusCode);
+ }
+
+ public String getResponseCode() {
+ return MDC.get(RESPONSE_CODE);
+ }
+
+ private void setResponseCode(String responseCode) {
+ MDC.put(RESPONSE_CODE, responseCode);
+ }
+
+ public String getResponseDescription() {
+ return MDC.get(RESPONSE_DESCRIPTION);
+ }
+
+ private void setResponseDescription(String responseDesc) {
+ MDC.put(RESPONSE_DESCRIPTION, responseDesc);
+ }
+
+ public String getInstanceUUID() {
+ return MDC.get(INSTANCE_UUID);
+ }
+
+ private void setInstanceUUID(String instanceUUID) {
+ MDC.put(INSTANCE_UUID, instanceUUID);
+ }
+
+ public String getCategoryLogLevel() {
+ return MDC.get(CATEGORY_LOG_LEVEL);
+ }
+
+ private void setCategoryLogLevel(String categoryLogLevel) {
+ MDC.put(CATEGORY_LOG_LEVEL, categoryLogLevel);
+ }
+
+ public String getSeverity() {
+ return MDC.get(SEVERITY);
+ }
+
+ private void setSeverity(String severity) {
+ MDC.put(SEVERITY, severity);
+ }
+
+ public String getServerIpAddress() {
+ return MDC.get(SERVER_IP_ADDRESS);
+ }
+
+ private void setServerIpAddress(String serverIpAddress) {
+ MDC.put(SERVER_IP_ADDRESS, serverIpAddress);
+ }
+
+ public String getElapsedTime() {
+ return MDC.get(ELAPSED_TIME);
+ }
+
+ private void setElapsedTime(long elapsedTime) {
+ MDC.put(ELAPSED_TIME, ""+elapsedTime);
+ }
+
+ public String getServer() {
+ return MDC.get(SERVER);
+ }
+
+ private void setServer(String server) {
+ MDC.put(SERVER, server);
+ }
+
+ public String getClientIp() {
+ return MDC.get(CLIENT_IP);
+ }
+
+ private void setClientIp(String clientIp) {
+ MDC.put(CLIENT_IP, clientIp);
+ }
+
+ public String getClassName() {
+ return MDC.get(CLASS_NAME);
+ }
+
+ private void setClassName(String className) {
+ MDC.put(CLASS_NAME, className);
+ }
+
+ public String getTargetVirtualEntity() {
+ return MDC.get(TARGET_VIRTUAL_ENTITY);
+ }
+
+ private void setTargetVirtualEntity(String targetVirtualEntity) {
+ MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity);
+ }
+
+ public static String asIso8601(Date date) {
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'");
+ df.setTimeZone(tz);
+ return df.format(date);
+ }
+
+ public static String asIso8601(long tsInMillis) {
+ return MetricLogger.asIso8601(new Date(tsInMillis));
+ }
+
+ public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) {
+
+ setBeginTimestamp(System.currentTimeMillis());
+
+ if (svcInstanceId != null) {
+ setServiceInstanceID(svcInstanceId);
+ }
+
+ if (svcName != null) {
+ setServiceName(svcName);
+ }
+
+ if (partnerName != null) {
+ setPartnerName(partnerName);
+ }
+
+ if (targetEntity != null) {
+ setTargetEntity(targetEntity);
+ }
+
+ if (targetServiceName != null) {
+ setTargetServiceName(targetServiceName);
+ }
+
+ if (targetVirtualEntity != null) {
+ setTargetVirtualEntity(targetVirtualEntity);
+ }
+
+ this.lastMsg = msg;
+
+
+ }
+
+ public void logResponse(String statusCode, String responseCode, String responseDescription) {
+ setEndTimestamp(System.currentTimeMillis());
+
+ setStatusCode(statusCode);
+ setResponseCode(responseCode);
+ setResponseDescription(responseDescription);
+
+ METRIC.info(lastMsg);
+
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java
new file mode 100644
index 000000000..b4d62ab48
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.Map;
+
+public interface SvcLogicAdaptor {
+
+ public enum ConfigStatus {
+ SUCCESS,
+ ALREADY_ACTIVE,
+ NOT_FOUND,
+ NOT_READY,
+ FAILURE
+ }
+
+ public ConfigStatus configure(String key, Map<String,String> parameters, SvcLogicContext ctx);
+
+ public ConfigStatus activate(String key, SvcLogicContext ctx);
+
+ public ConfigStatus deactivate(String key, SvcLogicContext ctx);
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java
new file mode 100644
index 000000000..9ac648933
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java
@@ -0,0 +1,174 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+public class SvcLogicAtom extends SvcLogicExpression {
+
+ public enum AtomType {
+ NUMBER,
+ STRING,
+ IDENTIFIER,
+ CONTEXT_VAR
+
+ }
+
+ private AtomType atomType;
+ private String atom;
+
+
+ public SvcLogicAtom(String atomType, String atom)
+ {
+ this.atomType = AtomType.valueOf(atomType);
+ this.atom = atom;
+
+ }
+
+ public SvcLogicAtom(String atom)
+ {
+
+ if (atom == null)
+ {
+ this.atomType = null;
+ this.atom = null;
+ }
+ else
+ {
+ if (atom.startsWith("$"))
+ {
+ this.atomType = AtomType.CONTEXT_VAR;
+ this.atom = atom.substring(1);
+ }
+ else
+ {
+ if (Character.isDigit(atom.charAt(0)))
+ {
+ this.atomType = AtomType.NUMBER;
+ this.atom = atom;
+ }
+ else if (atom.charAt(0) == '\'')
+ {
+ this.atomType = AtomType.STRING;
+ this.atom = atom.substring(1, atom.length()-1);
+ }
+ else
+ {
+ this.atomType = AtomType.IDENTIFIER;
+ this.atom = atom;
+
+ }
+
+ }
+ }
+ }
+
+ public AtomType getAtomType() {
+ return atomType;
+ }
+
+ public void setAtomType(String newType)
+ {
+ atomType = AtomType.valueOf(newType);
+ }
+
+ public String getAtom() {
+ return atom;
+ }
+
+
+
+ public void setAtomType(AtomType atomType) {
+ this.atomType = atomType;
+ }
+
+ public void setAtom(String atom) {
+ this.atom = atom;
+ }
+
+
+
+ public String toString()
+ {
+ StringBuffer sbuff = new StringBuffer();
+ switch(getAtomType())
+ {
+ case CONTEXT_VAR:
+ sbuff.append("$");
+ case IDENTIFIER:
+ boolean needDot = false;
+ for (SvcLogicExpression term: this.getOperands())
+ {
+ if (needDot)
+ {
+ sbuff.append(".");
+ }
+ sbuff.append(term.toString());
+ needDot = true;
+ }
+ return(sbuff.toString());
+ case STRING:
+ case NUMBER:
+ default:
+ return(atom);
+ }
+ }
+
+ public String asParsedExpr()
+ {
+ // simplify debugging output for NUMBER type
+ if (atomType == AtomType.NUMBER) {
+ return atom;
+ }
+
+ StringBuffer sbuff = new StringBuffer();
+
+ sbuff.append("(atom");
+ sbuff.append("<");
+ sbuff.append(atomType.toString());
+ sbuff.append(">");
+
+ switch(atomType)
+ {
+ case IDENTIFIER:
+ case CONTEXT_VAR:
+ for (SvcLogicExpression term : getOperands())
+ {
+ sbuff.append(" ");
+ sbuff.append(term.asParsedExpr());
+
+ }
+ break;
+ default:
+ sbuff.append(" ");
+ sbuff.append(atom);
+ }
+
+ sbuff.append(")");
+ return(sbuff.toString());
+ }
+
+
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java
new file mode 100644
index 000000000..1d780d7e7
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class SvcLogicBinaryExpression extends SvcLogicExpression {
+
+
+ public enum OperatorType {
+ addOp("+"),
+ subOp("-"),
+ multOp("*"),
+ divOp("/"),
+ equalOp("=="),
+ ltOp("<"),
+ leOp("<="),
+ gtOp(">"),
+ geOp(">="),
+ neOp("!="),
+ andOp("and"),
+ orOp("or");
+
+ private String text;
+
+ private OperatorType(String text)
+ {
+ this.text = text;
+ }
+
+ public String getText()
+ {
+ return(text);
+ }
+
+ public static OperatorType fromString(String text)
+ {
+ if (text != null)
+ {
+ for (OperatorType t : OperatorType.values())
+ {
+ if (text.equalsIgnoreCase(t.getText())) {
+
+ return(t);
+ }
+ }
+ }
+ return(null);
+ }
+
+ public String toString()
+ {
+ return(text);
+ }
+ }
+ private List<OperatorType> operators;
+
+ public List<OperatorType> getOperators() {
+ return operators;
+ }
+
+ public SvcLogicBinaryExpression()
+ {
+ operators = new LinkedList<OperatorType>();
+ }
+
+ public void addOperator(String operator)
+ {
+ operators.add(OperatorType.fromString(operator));
+ }
+
+
+ public String toString()
+ {
+
+ List<SvcLogicExpression>operands = getOperands();
+ StringBuffer sbuff = new StringBuffer();
+
+ sbuff.append(operands.get(0).toString());
+ for (int i = 0 ; i < operators.size(); i++)
+ {
+ sbuff.append(" ");
+ sbuff.append(operators.get(i));
+ sbuff.append(" ");
+ if (i + 1 < operands.size()) {
+ sbuff.append(operands.get(i + 1).toString());
+ } else {
+ // expression incomplete; operand not bound yet
+ sbuff.append("?");
+ }
+ }
+
+ return(sbuff.toString());
+
+ }
+
+ public String asParsedExpr() {
+
+ List<SvcLogicExpression> operands = getOperands();
+
+ if (operators.isEmpty()) {
+ return operands.get(0).asParsedExpr();
+ } else {
+ StringBuffer sbuff = new StringBuffer();
+ // operators in reverse order for left associativity
+ for (int i = operators.size() - 1; i >= 0; --i) {
+ sbuff.append("(");
+ sbuff.append(operators.get(i).getText());
+ sbuff.append(" ");
+ }
+ for (int i = 0; i < operators.size() + 1; ++i) {
+ if (i < operands.size()) {
+ sbuff.append(operands.get(i).asParsedExpr());
+ } else {
+ // expression incomplete; operand not bound yet
+ sbuff.append("?");
+ }
+ if (i != 0) {
+ sbuff.append(")");
+ }
+ if (i < operators.size()) {
+ sbuff.append(" ");
+ }
+ }
+ return sbuff.toString();
+ }
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java
new file mode 100644
index 000000000..79082af29
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java
@@ -0,0 +1,248 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+
+public class SvcLogicContext {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicContext.class);
+
+ private HashMap<String, String> attributes;
+
+ private DOMDataBroker domDataBroker;
+
+ private String status = "success";
+
+ public SvcLogicContext()
+ {
+ this.attributes = new HashMap<String,String> ();
+
+ }
+
+ public SvcLogicContext(Properties props)
+ {
+ this.attributes = new HashMap<String, String> ();
+
+ if (props.containsKey("SvcLogic.status"))
+ {
+ this.status = props.getProperty("SvcLogic.status");
+ }
+
+ for (Object nameObj : props.keySet())
+ {
+ String propName = (String) nameObj;
+ attributes.put(propName, props.getProperty(propName));
+ }
+ }
+
+
+
+ public DOMDataBroker getDomDataBroker() {
+ return domDataBroker;
+ }
+
+ public void setDomDataBroker(DOMDataBroker domDataBroker) {
+ this.domDataBroker = domDataBroker;
+ }
+
+ public String getAttribute(String name)
+ {
+ if (attributes.containsKey(name))
+ {
+ return(attributes.get(name));
+ }
+ else
+ {
+ return(null);
+ }
+ }
+
+ public void setAttribute(String name, String value)
+ {
+ if (value == null) {
+ if (attributes.containsKey(name)) {
+ attributes.remove(name);
+ }
+ } else {
+ attributes.put(name, value);
+ }
+ }
+
+ public Set<String> getAttributeKeySet()
+ {
+ return(attributes.keySet());
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public Properties toProperties()
+ {
+ Properties props = new Properties();
+
+ if (status != null)
+ {
+ props.setProperty("SvcLogic.status", status);
+ }
+
+ for (String attrName : attributes.keySet())
+ {
+ String attrVal = attributes.get(attrName);
+ if (attrVal == null) {
+ LOG.warn("attribute " + attrName
+ + "null - setting to empty string");
+ props.setProperty(attrName, "");
+ } else {
+ props.setProperty(attrName, attributes.get(attrName));
+ }
+ }
+
+ return(props);
+ }
+
+ public void mergeDocument(String pfx, Document doc) {
+ String prefix = "";
+
+ if (pfx != null) {
+ prefix = pfx;
+ }
+
+ Element root = doc.getDocumentElement();
+
+ mergeElement(prefix, root, null);
+ }
+
+ public void mergeElement(String pfx, Element element, Map<String, Integer> nodeMap) {
+
+ // In XML, cannot tell the difference between containers and lists.
+ // So, have to treat each element as both (ugly but necessary).
+ // We do this by passing a nodeMap to be used to count instance of each tag,
+ // which will be used to set _length and to set index
+
+ LOG.trace("mergeElement("+pfx+","+element.getTagName()+","+nodeMap+")");
+
+ String curTagName = element.getTagName();
+ String prefix = curTagName;
+
+ if (pfx != null) {
+ prefix = pfx + "." + prefix;
+ }
+
+ int myIdx = 0;
+
+ if (nodeMap != null) {
+ if (nodeMap.containsKey(curTagName)) {
+ myIdx = nodeMap.get(curTagName).intValue();
+ }
+
+ nodeMap.put(curTagName, new Integer(myIdx+1));
+ this.setAttribute(prefix+"_length", ""+(myIdx+1));
+ }
+
+ NodeList children = element.getChildNodes();
+
+ int numChildren = children.getLength();
+
+ Map<String, Integer> childMap = new HashMap<String, Integer>();
+ Map<String, Integer> idxChildMap = new HashMap<String, Integer>();
+
+ for (int i = 0 ; i < numChildren ; i++) {
+ Node curNode = children.item(i);
+
+ if (curNode instanceof Text) {
+ Text curText = (Text) curNode;
+ String curTextValue = curText.getTextContent();
+ LOG.trace("Setting ctx variable "+prefix+" = "+curTextValue);
+ this.setAttribute(prefix, curText.getTextContent());
+
+
+ } else if (curNode instanceof Element) {
+ mergeElement(prefix, (Element) curNode, childMap);
+ if (nodeMap != null) {
+
+ mergeElement(prefix+"["+myIdx+"]", (Element)curNode, idxChildMap);
+
+ }
+ }
+ }
+
+ }
+
+ public String resolve(String ctxVarName) {
+
+ if (ctxVarName.indexOf('[') == -1) {
+ // Ctx variable contains no arrays
+ return (this.getAttribute(ctxVarName));
+ }
+
+ // Resolve any array references
+ StringBuffer sbuff = new StringBuffer();
+ String[] ctxVarParts = ctxVarName.split("\\[");
+ sbuff.append(ctxVarParts[0]);
+ for (int i = 1; i < ctxVarParts.length; i++) {
+ if (ctxVarParts[i].startsWith("$")) {
+ int endBracketLoc = ctxVarParts[i].indexOf("]");
+ if (endBracketLoc == -1) {
+ // Missing end bracket ... give up parsing
+ LOG.warn("Variable reference " + ctxVarName
+ + " seems to be missing a ']'");
+ return (this.getAttribute(ctxVarName));
+ }
+
+ String idxVarName = ctxVarParts[i].substring(1, endBracketLoc);
+ String remainder = ctxVarParts[i].substring(endBracketLoc);
+
+ sbuff.append("[");
+ sbuff.append(this.getAttribute(idxVarName));
+ sbuff.append(remainder);
+
+ } else {
+ // Index is not a variable reference
+ sbuff.append("[");
+ sbuff.append(ctxVarParts[i]);
+ }
+ }
+
+ return (this.getAttribute(sbuff.toString()));
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java
new file mode 100644
index 000000000..d494eaab2
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java
@@ -0,0 +1,533 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Blob;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import javax.sql.rowset.CachedRowSet;
+
+import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SvcLogicDblibStore implements SvcLogicStore {
+
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicDblibStore.class);
+
+ private static final String DBLIB_SERVICE =
+ // "org.openecomp.sdnc.sli.resource.dblib.DBLibService";
+ "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager";
+
+ Properties props = null;
+
+ public void init(Properties props) throws ConfigurationException {
+
+ DbLibService dbSvc = getDbLibService();
+ if(dbSvc == null) {
+ LOG.error("SvcLogic cannot acquire DBLIB_SERVICE");
+ return;
+ }
+ try {
+ dbSvc.getData("select 1 from DUAL", new ArrayList<String>(), null);
+ LOG.debug("SQL test was successful");
+ } catch (SQLException e) {
+ LOG.error("Failed SQL test", e);
+ }
+ }
+
+ public boolean hasGraph(String module, String rpc, String version,
+ String mode) throws SvcLogicException {
+
+ DbLibService dbSvc = getDbLibService();
+
+ boolean retval = false;
+ CachedRowSet results = null;
+ String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ String hasActiveGraphSql = "SELECT count(*) FROM SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+
+ PreparedStatement hasGraphStmt = null;
+
+ ArrayList<String> args = new ArrayList<String>();
+ args.add(module);
+ args.add(rpc);
+ args.add(mode);
+
+ try {
+
+ if (version == null) {
+ results = dbSvc.getData(hasActiveGraphSql, args, null);
+ } else {
+ args.add(version);
+ results = dbSvc.getData(hasVersionGraphSql, args, null);
+ }
+
+ if (results.next()) {
+ int cnt = results.getInt(1);
+
+ if (cnt > 0) {
+ retval = true;
+ }
+
+ }
+ } catch (Exception e) {
+ throw new ConfigurationException("SQL query failed", e);
+ } finally {
+ if (results != null) {
+ try {
+
+ results.close();
+ } catch (SQLException x) {
+ }
+ }
+
+ }
+
+ return (retval);
+
+ }
+
+ public SvcLogicGraph fetch(String module, String rpc, String version,
+ String mode) throws SvcLogicException {
+
+ DbLibService dbSvc = getDbLibService();
+
+ Connection dbConn = null;
+ SvcLogicGraph retval = null;
+ ResultSet results = null;
+
+ String fetchVersionGraphSql = "SELECT graph FROM SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ String fetchActiveGraphSql = "SELECT graph FROM SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+
+
+ try {
+ dbConn = ((DBResourceManager) dbSvc).getConnection();
+ PreparedStatement fetchGraphStmt;
+
+ ArrayList<String> args = new ArrayList<String>();
+ args.add(module);
+ args.add(rpc);
+ args.add(mode);
+
+ if (version == null) {
+ fetchGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql);
+ } else {
+ fetchGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql);
+ }
+
+ fetchGraphStmt.setString(1, module);
+ fetchGraphStmt.setString(2, rpc);
+ fetchGraphStmt.setString(3, mode);
+ if (version != null) {
+ fetchGraphStmt.setString(4,version);
+ }
+
+ results = fetchGraphStmt.executeQuery();
+
+ if (results.next()) {
+ Blob graphBlob = results.getBlob("graph");
+
+ ObjectInputStream gStream = new ObjectInputStream(
+ graphBlob.getBinaryStream());
+
+ Object graphObj = gStream.readObject();
+ gStream.close();
+
+ if (graphObj instanceof SvcLogicGraph) {
+ retval = (SvcLogicGraph) graphObj;
+ } else {
+ throw new ConfigurationException("invalid type for graph ("
+ + graphObj.getClass().getName());
+
+ }
+
+ } else {
+ return (null);
+ }
+ } catch (SQLException e) {
+ throw new ConfigurationException("SQL query failed", e);
+ } catch (Exception e) {
+ throw new ConfigurationException("Graph processing failed", e);
+ } finally {
+ if (results != null) {
+ try {
+ results.close();
+ } catch (SQLException x) {
+ }
+ }
+ try {
+ if (dbConn != null && !dbConn.isClosed()) {
+ dbConn.close();
+ }
+ } catch (Throwable exc) {
+ // the exception not monitored
+ } finally {
+ dbConn = null;
+ }
+
+ }
+
+ return (retval);
+
+ }
+
+ public void store(SvcLogicGraph graph) throws SvcLogicException {
+
+ DbLibService dbSvc = getDbLibService();
+
+ String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)"
+ + " VALUES(?, ?, ?, ?, ?, ?)";
+
+ if (graph == null) {
+ throw new SvcLogicException("graph cannot be null");
+ }
+
+ byte[] graphBytes = null;
+
+ ByteArrayOutputStream byteStr = null;
+ ObjectOutputStream goutStr = null;
+
+ try {
+ byteStr = new ByteArrayOutputStream();
+ goutStr = new ObjectOutputStream(byteStr);
+ goutStr.writeObject(graph);
+
+ graphBytes = byteStr.toByteArray();
+
+ } catch (Exception e) {
+ throw new SvcLogicException("could not serialize graph", e);
+ } finally {
+
+ if (goutStr != null) {
+ try {
+ goutStr.close();
+ } catch (IOException e) {
+
+ }
+ }
+
+ if (byteStr != null) {
+ try {
+ byteStr.close();
+ } catch (IOException e) {
+
+ }
+ }
+ }
+
+ // If object already stored in database, delete it
+ if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(),
+ graph.getMode())) {
+ delete(graph.getModule(), graph.getRpc(), graph.getVersion(),
+ graph.getMode());
+ }
+
+ Connection dbConn = null;
+
+ try {
+ dbConn = ((DBResourceManager) dbSvc).getConnection();
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ PreparedStatement storeGraphStmt = dbConn
+ .prepareStatement(storeGraphSql);
+ storeGraphStmt.setString(1, graph.getModule());
+ storeGraphStmt.setString(2, graph.getRpc());
+ storeGraphStmt.setString(3, graph.getVersion());
+ storeGraphStmt.setString(4, graph.getMode());
+ storeGraphStmt.setString(5, "N");
+ storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes));
+
+ storeGraphStmt.executeUpdate();
+ dbConn.commit();
+
+ dbConn.setAutoCommit(oldAutoCommit);
+ } catch (Exception e) {
+ throw new SvcLogicException("Could not write object to database", e);
+ } finally {
+ try {
+ if (dbConn != null && !dbConn.isClosed()) {
+ dbConn.close();
+ }
+ } catch (Throwable exc) {
+ // the exception not monitored
+ } finally {
+ dbConn = null;
+ }
+
+ }
+ }
+
+ public void delete(String module, String rpc, String version, String mode)
+ throws SvcLogicException {
+
+ DbLibService dbSvc = getDbLibService();
+
+ String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
+
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(module);
+ args.add(rpc);
+ args.add(version);
+ args.add(mode);
+
+ try {
+ dbSvc.writeData(deleteGraphSql, args, null);
+ } catch (Exception e) {
+ throw new SvcLogicException(
+ "Could not delete object from database", e);
+ }
+ }
+
+ public void activate(SvcLogicGraph graph) throws SvcLogicException {
+ DbLibService dbSvc = getDbLibService();
+
+ String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
+
+ String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(graph.getModule());
+ args.add(graph.getRpc());
+ args.add(graph.getMode());
+
+ try {
+
+ dbSvc.writeData(deactivateSql, args, null);
+
+ args.add(graph.getVersion());
+ dbSvc.writeData(activateSql, args, null);
+
+ } catch (Exception e) {
+ throw new SvcLogicException("Could not activate graph", e);
+ }
+ }
+
+ @Override
+ public void registerNodeType(String nodeType) throws SvcLogicException {
+
+ String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)";
+
+ if (isValidNodeType(nodeType)) {
+ return;
+ }
+
+ DbLibService dbSvc = getDbLibService();
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(nodeType);
+
+ try {
+ dbSvc.writeData(registerNodeSql, args, null);
+ } catch (Exception e) {
+ throw new SvcLogicException("Could not add node type to database",
+ e);
+ }
+
+ }
+
+ @Override
+ public void unregisterNodeType(String nodeType) throws SvcLogicException {
+
+ if (!isValidNodeType(nodeType)) {
+ return;
+ }
+
+ String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?";
+
+ DbLibService dbSvc = getDbLibService();
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(nodeType);
+
+ try {
+ dbSvc.writeData(unregisterNodeSql, args, null);
+ } catch (Exception e) {
+ throw new SvcLogicException(
+ "Could not delete node type from database", e);
+ }
+
+ }
+
+ @Override
+ public boolean isValidNodeType(String nodeType) throws SvcLogicException {
+
+ String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?";
+
+ DbLibService dbSvc = getDbLibService();
+
+ ArrayList<String> args = new ArrayList<String>();
+
+ args.add(nodeType);
+
+ boolean isValid = false;
+
+ CachedRowSet results = null;
+ try {
+ results = dbSvc.getData(validateNodeSql, args, null);
+ if (results != null) {
+ if (results.next()) {
+ int cnt = results.getInt(1);
+
+ if (cnt > 0) {
+ isValid = true;
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new SvcLogicException(
+ "Cannot select node type from database", e);
+ } finally {
+ if (results != null) {
+ try {
+ results.close();
+ } catch (SQLException x) {
+ }
+ }
+
+ }
+
+ return (isValid);
+ }
+
+ private DbLibService getDbLibService() {
+
+ // Get DbLibService interface object.
+ DbLibService dblibSvc = null;
+ ServiceReference sref = null;
+ BundleContext bctx = null;
+
+ Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class);
+
+ if (bundle != null) {
+ bctx = bundle.getBundleContext();
+
+ if (bctx != null) {
+ sref = bctx.getServiceReference(DBLIB_SERVICE);
+ }
+
+ if (sref == null) {
+ LOG.warn("Could not find service reference for DBLIB service ("
+ + DBLIB_SERVICE + ")");
+ } else {
+ dblibSvc = (DbLibService) bctx.getService(sref);
+ if (dblibSvc == null) {
+
+ LOG.warn("Could not find service reference for DBLIB service ("
+ + DBLIB_SERVICE + ")");
+ }
+ }
+ }
+
+ // initialize a stand-alone instance of dblib resource
+ else {
+ // Try to create a DbLibService object from dblib properties
+ if(JavaSingleton.getInstance() == null){
+ Properties dblibProps = new Properties();
+
+ String propDir = System.getenv(SDNC_CONFIG_DIR);
+ if (propDir == null) {
+
+ propDir = "/opt/sdnc/data/properties";
+ }
+ String propPath = propDir + "/dblib.properties";
+
+ File propFile = new File(propPath);
+
+ if (!propFile.exists()) {
+
+ LOG.warn(
+ "Missing configuration properties file : "
+ + propFile);
+ return(null);
+ }
+
+ try {
+
+ dblibProps.load(new FileInputStream(propFile));
+ } catch (Exception e) {
+ LOG.warn(
+ "Could not load properties file " + propPath, e);
+ return(null);
+
+ }
+
+ try {
+ dblibSvc = DBResourceManager.create(dblibProps);
+ JavaSingleton.setInstance(dblibSvc);
+ } catch (Exception e) {
+ LOG.warn("Caught exception trying to create DBResourceManager", e);
+ }
+ } else {
+ dblibSvc = JavaSingleton.getInstance();
+ }
+ }
+ return (dblibSvc);
+ }
+
+
+ static class JavaSingleton {
+ /* Private constructor */
+ private JavaSingleton() {
+ /* the body of the constructor here */
+ }
+
+ /* instance of the singleton declaration */
+ private static volatile DbLibService INSTANCE ;
+
+ /* Access point to the unique instance of the singleton */
+ public static DbLibService getInstance() {
+ return INSTANCE;
+ }
+
+ public static void setInstance(DbLibService dbresource) {
+ INSTANCE = dbresource;
+ }
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java
new file mode 100644
index 000000000..c087b8ad8
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class SvcLogicException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public SvcLogicException()
+ {
+ super();
+ }
+
+ public SvcLogicException(String message)
+ {
+ super(message);
+ }
+
+ public SvcLogicException(String message, Throwable t)
+ {
+ super(message, t);
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java
new file mode 100644
index 000000000..4fef12fbc
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java
@@ -0,0 +1,316 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.openecomp.sdnc.sli.ExprGrammarParser.AddExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.AtomContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.CompareExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.ConstantContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.FuncExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.MultExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.ParenExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.RelExprContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.VariableContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.VariableLeadContext;
+import org.openecomp.sdnc.sli.ExprGrammarParser.VariableTermContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SvcLogicExprListener extends ExprGrammarBaseListener
+{
+
+
+
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicExprListener.class);
+
+ private SvcLogicExpression curExpr;
+ private SvcLogicExpression topExpr;
+ private LinkedList<SvcLogicExpression> exprStack;
+
+ public SvcLogicExprListener()
+ {
+ exprStack = new LinkedList<SvcLogicExpression>();
+ }
+
+ public SvcLogicExpression getParsedExpr()
+ {
+ return(curExpr);
+ }
+
+ private void pushOperand(SvcLogicExpression operand)
+ {
+ if (curExpr == null)
+ {
+ curExpr = operand;
+ }
+ else
+ {
+ curExpr.addOperand(operand);
+ }
+ }
+
+ private void pushExpr(SvcLogicExpression expr)
+ {
+ LOG.trace("Pushing expression ["+expr.getClass().getName()+"]");
+ if (curExpr != null)
+ {
+ exprStack.push(curExpr);
+ }
+ curExpr = expr;
+ }
+
+ private void popExpr()
+ {
+ if (exprStack.isEmpty())
+ {
+ LOG.trace("Popping last expression");
+ topExpr = curExpr;
+ }
+ else
+ {
+ SvcLogicExpression lastExpr = curExpr;
+ curExpr = exprStack.pop();
+ curExpr.addOperand(lastExpr);
+ LOG.trace("New curExpr is ["+curExpr.getClass().getName()+"]");
+ }
+
+ }
+
+ @Override
+ public void enterAtom(AtomContext ctx) {
+
+ String atomText = ctx.getText();
+
+ LOG.trace("enterAtom: text = "+atomText);
+
+
+ SvcLogicAtom newAtom = new SvcLogicAtom(atomText);
+
+ pushExpr(newAtom);
+ }
+
+
+ @Override
+ public void enterMultExpr(MultExprContext ctx) {
+ LOG.trace("enterMultExpr: text = "+ctx.getText());
+
+ SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression();
+ pushExpr(curBinExpr);
+
+ List<TerminalNode> opList = ctx.MULTOP();
+
+ for (TerminalNode nd : opList)
+ {
+ LOG.trace("enterMultExpr: operator - "+nd.getText());
+ curBinExpr.addOperator(nd.getText());
+ }
+
+ }
+
+ @Override
+ public void exitMultExpr(MultExprContext ctx) {
+
+ LOG.trace("exitMultExpr: text = "+ctx.getText());
+
+ popExpr();
+
+ }
+
+ @Override
+ public void exitAtom(AtomContext ctx) {
+ LOG.trace("exitAtom: text = "+ctx.getText());
+ popExpr();
+ }
+
+ @Override
+ public void enterAddExpr(AddExprContext ctx) {
+ LOG.trace("enterAddExpr: text = "+ctx.getText());
+ List<TerminalNode> opList = ctx.ADDOP();
+
+
+ SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression();
+ pushExpr(curBinExpr);
+
+
+ for (TerminalNode nd : opList)
+ {
+ LOG.trace("enterAddExpr: operator - "+nd.getText());
+ curBinExpr.addOperator(nd.getText());
+ }
+
+ }
+
+ @Override
+ public void exitAddExpr(AddExprContext ctx) {
+ LOG.trace("exitAddExpr: text = "+ctx.getText());
+
+ popExpr();
+ }
+
+ @Override
+ public void enterFuncExpr(FuncExprContext ctx) {
+ LOG.trace("enterFuncExpr: text = "+ctx.getText());
+ LOG.trace("enterFuncExpr - IDENTIFIER : "+ctx.IDENTIFIER().getText());
+
+ for (ExprContext expr: ctx.expr())
+ {
+ LOG.trace("enterFuncExpr - expr = "+expr.getText());
+ }
+
+
+ pushExpr(new SvcLogicFunctionCall(ctx.IDENTIFIER().getText()));
+ }
+
+ @Override
+ public void exitFuncExpr(FuncExprContext ctx) {
+ LOG.trace("exitFuncExpr: text = "+ctx.getText());
+
+ popExpr();
+ }
+
+ @Override
+ public void enterParenExpr(ParenExprContext ctx) {
+ LOG.trace("enterParenExpr: text = "+ctx.getText());
+ LOG.trace("enterParenExpr: expr = "+ctx.expr().getText());
+ }
+
+ @Override
+ public void exitParenExpr(ParenExprContext ctx) {
+ LOG.trace("exitParenExpr: text = "+ctx.getText());
+ }
+
+ @Override
+ public void enterRelExpr(RelExprContext ctx) {
+ LOG.trace("enterRelExpr: text = "+ctx.getText());
+
+ List<TerminalNode> opList = ctx.RELOP();
+
+
+ SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression();
+ pushExpr(curBinExpr);
+
+
+ for (TerminalNode nd : opList)
+ {
+ LOG.trace("enterRelExpr: operator - "+nd.getText());
+ curBinExpr.addOperator(nd.getText());
+ }
+
+ }
+
+ @Override
+ public void exitRelExpr(RelExprContext ctx) {
+ LOG.trace("exitRelExpr: text = "+ctx.getText());
+
+ popExpr();
+ }
+
+ @Override
+ public void enterCompareExpr(CompareExprContext ctx) {
+ LOG.trace("enterCompareExpr: text = "+ctx.getText());
+
+ TerminalNode nd = ctx.COMPAREOP();
+
+ SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression();
+ pushExpr(curBinExpr);
+
+ LOG.trace("enterCompareExpr: operator - "+nd.getText());
+ curBinExpr.addOperator(nd.getText());
+
+ }
+
+ @Override
+ public void exitCompareExpr(CompareExprContext ctx) {
+ LOG.trace("exitCompareExpr : text = "+ctx.getText());
+
+ popExpr();
+ }
+
+
+
+ @Override
+ public void enterConstant(ConstantContext ctx) {
+ LOG.trace("enterConstant: text = "+ctx.getText());
+ }
+
+ @Override
+ public void exitConstant(ConstantContext ctx) {
+ LOG.trace("exitConstant: text = "+ctx.getText());
+ }
+
+
+ @Override
+ public void enterVariable(VariableContext ctx) {
+ LOG.trace("enterVariable: text = "+ctx.getText());
+
+
+ }
+
+ @Override
+ public void exitVariable(VariableContext ctx) {
+ LOG.debug("exitVariable: text ="+ctx.getText());
+
+ }
+
+
+ @Override
+ public void enterVariableLead(VariableLeadContext ctx) {
+
+ LOG.debug("enterVariableLead: text ="+ctx.getText());
+
+
+ }
+
+ @Override
+ public void exitVariableLead(VariableLeadContext ctx) {
+
+ LOG.trace("exitVariableLead: text ="+ctx.getText());
+ }
+
+ @Override
+ public void enterVariableTerm(VariableTermContext ctx) {
+ LOG.trace("enterVariableTerm: text ="+ctx.getText());
+
+ String name = ctx.getText();
+
+ int subscrStart = name.indexOf("[");
+ if (subscrStart > -1)
+ {
+ name = name.substring(0, subscrStart);
+ }
+ SvcLogicVariableTerm vterm = new SvcLogicVariableTerm(name);
+ pushExpr(vterm);
+ }
+
+ @Override
+ public void exitVariableTerm(VariableTermContext ctx) {
+ LOG.trace("exitVariableTerm: text="+ctx.getText());
+ popExpr();
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java
new file mode 100644
index 000000000..4c7dd22be
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import org.antlr.v4.runtime.BaseErrorListener;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+
+public class SvcLogicExprParserErrorListener extends BaseErrorListener {
+
+ private static final SvcLogicExprParserErrorListener instance = new SvcLogicExprParserErrorListener();
+
+ public static SvcLogicExprParserErrorListener getInstance() {
+ return(instance);
+ }
+
+ @Override
+ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
+ String msg, RecognitionException e) throws ParseCancellationException {
+ throw new ParseCancellationException(msg);
+ }
+
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java
new file mode 100644
index 000000000..a6af82018
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+
+public abstract class SvcLogicExpression implements Serializable {
+
+ private List<SvcLogicExpression> operands = new LinkedList<SvcLogicExpression>();
+
+
+ public void addOperand(SvcLogicExpression expr)
+ {
+ operands.add(expr);
+ }
+
+ public List<SvcLogicExpression> getOperands() {
+ return operands;
+ }
+
+ public int numOperands()
+ {
+ return(operands.size());
+ }
+
+ public abstract String asParsedExpr();
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java
new file mode 100644
index 000000000..cce8e044d
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SvcLogicExpressionFactory {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicExpressionFactory.class);
+
+
+ public static SvcLogicExpression parse(String exprStr) throws IOException
+ {
+ LOG.trace("parse("+exprStr+")");
+ InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes());
+ CharStream input = new ANTLRInputStream(exprStream);
+ ExprGrammarLexer lexer = new ExprGrammarLexer(input);
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ ExprGrammarParser parser = new ExprGrammarParser(tokens);
+
+ lexer.removeErrorListeners();
+ lexer.addErrorListener(SvcLogicExprParserErrorListener.getInstance());
+ parser.removeErrorListeners();
+ parser.addErrorListener(SvcLogicExprParserErrorListener.getInstance());
+
+ ExprContext expression = null;
+
+ try {
+ expression = parser.expr();
+ } catch (Exception e) {
+ String errorMsg = e.getMessage();
+
+ LOG.error(errorMsg);
+ throw new SvcLogicParserException(errorMsg);
+ }
+
+
+ ParseTreeWalker walker = new ParseTreeWalker();
+ SvcLogicExprListener listener = new SvcLogicExprListener();
+ walker.walk(listener, expression);
+
+
+ return(listener.getParsedExpr());
+ }
+
+ public static void main(String argv[]) {
+
+
+ System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
+
+ StringBuffer sbuff = new StringBuffer();
+
+ for (int i = 0 ; i < argv.length ; i++)
+ {
+ if (sbuff.length() > 0)
+ {
+ sbuff.append(" ");
+ }
+ sbuff.append(argv[i]);
+ }
+
+ try {
+ SvcLogicExpressionFactory.parse(sbuff.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java
new file mode 100644
index 000000000..a98cf6b22
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class SvcLogicFunctionCall extends SvcLogicExpression {
+
+ private String functionName;
+
+ public SvcLogicFunctionCall(String functionName)
+ {
+ this.functionName = functionName;
+ }
+
+ public String getFunctionName() {
+ return functionName;
+ }
+
+ public void setFunctionName(String functionName) {
+ this.functionName = functionName;
+ }
+
+ public String toString()
+ {
+ StringBuffer sbuff = new StringBuffer();
+
+ sbuff.append(functionName);
+ sbuff.append("(");
+ boolean needComma = false;
+ for (SvcLogicExpression operand: getOperands())
+ {
+ if (needComma)
+ {
+ sbuff.append(",");
+ }
+ else
+ {
+ needComma = true;
+ }
+ sbuff.append(operand.toString());
+
+ }
+ sbuff.append(")");
+ return(sbuff.toString());
+ }
+
+ public String asParsedExpr()
+ {
+ StringBuffer sbuff = new StringBuffer();
+
+ sbuff.append("(");
+ sbuff.append(functionName);
+ for (SvcLogicExpression operand: getOperands())
+ {
+ sbuff.append(" ");
+ sbuff.append(operand.asParsedExpr());
+ }
+ sbuff.append(")");
+ return(sbuff.toString());
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java
new file mode 100644
index 000000000..d3d6d9504
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java
@@ -0,0 +1,184 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SvcLogicGraph implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private String module = null;
+ private String rpc = null;
+ private String mode = null;
+ private String version = null;
+
+ private Map<String, Serializable> attributes;
+ private Map<String, SvcLogicNode> namedNodes;
+ private SvcLogicNode rootNode;
+
+ public SvcLogicGraph()
+ {
+ attributes = new HashMap<String, Serializable>();
+ namedNodes = new HashMap<String, SvcLogicNode>();
+ rootNode = null;
+ }
+
+
+ public String getModule() {
+ return module;
+ }
+
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+
+ public String getRpc() {
+ return rpc;
+ }
+
+
+ public void setRpc(String rpc) {
+ this.rpc = rpc;
+ }
+
+
+
+
+ public String getMode() {
+ return mode;
+ }
+
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+
+ public String getVersion() {
+ return version;
+ }
+
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+
+ public void setRootNode(SvcLogicNode rootNode)
+ {
+ this.rootNode = rootNode;
+ }
+
+ public SvcLogicNode getRootNode()
+ {
+ return(rootNode);
+ }
+
+ public Serializable getAttribute(String name)
+ {
+ if (attributes.containsKey(name))
+ {
+ return(attributes.get(name));
+ }
+ else
+ {
+ return(null);
+ }
+
+ }
+
+ public void setAttribute(String name, Serializable value) throws DuplicateValueException
+ {
+ if (attributes.containsKey(name))
+ {
+ throw new DuplicateValueException("Duplicate attribute "+name);
+ }
+
+ attributes.put(name, value);
+ }
+
+ public SvcLogicNode getNamedNode(String nodeName)
+ {
+ if (namedNodes.containsKey(nodeName))
+ {
+ return(namedNodes.get(nodeName));
+ }
+ else
+ {
+ return(null);
+ }
+ }
+
+ public void setNamedNode(String nodeName, SvcLogicNode node) throws DuplicateValueException
+ {
+ if (namedNodes.containsKey(nodeName))
+ {
+ throw new DuplicateValueException("Duplicate node name "+nodeName);
+ }
+
+ namedNodes.put(nodeName, node);
+ }
+
+
+
+ public void printAsGv(PrintStream pstr)
+ {
+ pstr.println("digraph g {");
+ pstr.println("START [label=\"START\\n"+module+":"+rpc+"\"];");
+
+ if (rootNode != null)
+ {
+ pstr.println("START -> node"+rootNode.getNodeId()+";");
+ rootNode.setVisited(false, true);
+ rootNode.printAsGv(pstr);
+ }
+ pstr.println("}");
+ }
+
+ public void printAsXml(PrintStream pstr)
+ {
+ pstr.println("<service-logic module='"+getModule()+"' version='"+getVersion()+"'>");
+ pstr.println(" <method rpc='"+getRpc()+"' mode='"+getMode()+"'>");
+ if (rootNode != null)
+ {
+ rootNode.setVisited(false, true);
+ rootNode.printAsXml(pstr, 2);
+ }
+ pstr.println(" </method>");
+ pstr.println("</service-logic>");
+ }
+
+ @Override
+ public String toString() {
+ return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + "]";
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java
new file mode 100644
index 000000000..ac14cacc1
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.Map;
+
+public interface SvcLogicJavaPlugin {
+
+ /**
+ * A marker interface, used to indicate that a class exposes methods that can be
+ * called from an <execute> node. Such methods must have the signature:
+ * void methodName(Map, SvcLogicContext)
+ */
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java
new file mode 100644
index 000000000..b9e7f80ec
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java
@@ -0,0 +1,895 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Blob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SvcLogicJdbcStore implements SvcLogicStore {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicJdbcStore.class);
+
+ private String dbUrl = null;
+ private String dbName = null;
+ private String dbUser = null;
+ private String dbPasswd = null;
+ private String dbDriver = null;
+
+ private Connection dbConn;
+ private PreparedStatement hasActiveGraphStmt = null;
+ private PreparedStatement hasVersionGraphStmt = null;
+ private PreparedStatement fetchActiveGraphStmt = null;
+ private PreparedStatement fetchVersionGraphStmt = null;
+ private PreparedStatement storeGraphStmt = null;
+ private PreparedStatement deleteGraphStmt = null;
+
+ private PreparedStatement deactivateStmt = null;
+ private PreparedStatement activateStmt = null;
+
+ private PreparedStatement registerNodeStmt = null;
+ private PreparedStatement unregisterNodeStmt = null;
+ private PreparedStatement validateNodeStmt = null;
+
+ private void getConnection() throws ConfigurationException
+ {
+
+ Properties jdbcProps = new Properties();
+
+ jdbcProps.setProperty("user", dbUser);
+ jdbcProps.setProperty("password", dbPasswd);
+
+ try {
+ Driver dvr = new com.mysql.jdbc.Driver();
+ if (dvr.acceptsURL(dbUrl))
+ {
+ LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl);
+ }
+ else
+ {
+ LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl);
+ }
+ } catch (SQLException e1) {
+ LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1);
+
+
+ }
+
+
+ try
+ {
+ this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e);
+ }
+
+ }
+
+ private void createTable() throws ConfigurationException
+ {
+
+
+ DatabaseMetaData dbm = null;
+
+
+ try {
+ dbm = dbConn.getMetaData();
+ } catch (SQLException e) {
+
+ throw new ConfigurationException("could not get databse metadata", e);
+ }
+
+ // See if table SVC_LOGIC exists. If not, create it.
+ try
+ {
+
+
+ ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null);
+ if (tables.next()) {
+ // Table exists
+ }
+ else {
+
+ String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC ("
+ + "module varchar(80) NOT NULL,"
+ + "rpc varchar(80) NOT NULL,"
+ + "version varchar(40) NOT NULL,"
+ + "mode varchar(5) NOT NULL,"
+ + "active varchar(1) NOT NULL,"
+ + "graph BLOB,"
+ + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
+
+ Statement stmt = null;
+ ConfigurationException myExc = null;
+ try
+ {
+ stmt = dbConn.createStatement();
+ stmt.executeUpdate(crTableCmd);
+ }
+ catch (SQLException e1)
+ {
+ myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1);
+ }
+ finally
+ {
+ if (stmt != null)
+ {
+ stmt.close();
+ }
+ }
+
+ if (myExc != null)
+ {
+ throw myExc;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not create SVC_LOGIC table", e);
+ }
+
+ // See if NODE_TYPES table exists and, if not, create it
+
+ try
+ {
+
+
+ ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null);
+ if (tables.next()) {
+ // Table exists
+ }
+ else {
+
+ String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES ("
+ + "nodetype varchar(80) NOT NULL,"
+ + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))";
+
+ Statement stmt = null;
+ ConfigurationException myExc = null;
+ try
+ {
+ stmt = dbConn.createStatement();
+ stmt.executeUpdate(crTableCmd);
+ }
+ catch (SQLException e1)
+ {
+ myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1);
+ }
+ finally
+ {
+ if (stmt != null)
+ {
+ stmt.close();
+ }
+ }
+
+ if (myExc != null)
+ {
+ throw myExc;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not create SVC_LOGIC table", e);
+ }
+ }
+
+ private void prepStatements() throws ConfigurationException
+ {
+
+ // Prepare statements
+ String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ try
+ {
+ hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e);
+
+ }
+
+ String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+
+ try
+ {
+ hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e);
+
+ }
+
+ String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+
+ try
+ {
+ fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e);
+
+ }
+
+ String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC"
+ + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+
+ try
+ {
+ fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e);
+
+ }
+
+ String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)"
+ + " VALUES(?, ?, ?, ?, ?, ?)";
+
+ try
+ {
+ storeGraphStmt = dbConn.prepareStatement(storeGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+storeGraphSql, e);
+ }
+
+ String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
+
+ try
+ {
+ deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e);
+ }
+
+ String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
+
+ try
+ {
+ deactivateStmt = dbConn.prepareStatement(deactivateSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+deactivateSql, e);
+ }
+
+ String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
+
+ try
+ {
+ activateStmt = dbConn.prepareStatement(activateSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+activateSql, e);
+ }
+
+ String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)";
+ try
+ {
+ registerNodeStmt = dbConn.prepareStatement(registerNodeSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+registerNodeSql, e);
+ }
+
+ String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?";
+ try
+ {
+ unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e);
+ }
+
+ String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?";
+ try
+ {
+ validateNodeStmt = dbConn.prepareStatement(validateNodeSql);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not prepare statement "+validateNodeSql, e);
+ }
+ }
+
+ private void initDbResources() throws ConfigurationException
+ {
+ if ((dbDriver != null) && (dbDriver.length() > 0))
+ {
+
+ try
+ {
+ Class.forName(dbDriver);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("could not load driver class "+dbDriver, e);
+ }
+ }
+ getConnection();
+ createTable();
+ prepStatements();
+ }
+
+
+ public void init(Properties props) throws ConfigurationException {
+
+
+ dbUrl = props.getProperty("org.openecomp.sdnc.sli.jdbc.url");
+ if ((dbUrl == null) || (dbUrl.length() == 0))
+ {
+ throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.url unset");
+ }
+
+ dbName = props.getProperty("org.openecomp.sdnc.sli.jdbc.database");
+ if ((dbName == null) || (dbName.length() == 0))
+ {
+ throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.database unset");
+ }
+
+ dbUser = props.getProperty("org.openecomp.sdnc.sli.jdbc.user");
+ if ((dbUser == null) || (dbUser.length() == 0))
+ {
+ throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.user unset");
+ }
+
+
+ dbPasswd = props.getProperty("org.openecomp.sdnc.sli.jdbc.password");
+ if ((dbPasswd == null) || (dbPasswd.length() == 0))
+ {
+ throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.password unset");
+ }
+
+ dbDriver = props.getProperty("org.openecomp.sdnc.sli.jdbc.driver");
+
+
+ initDbResources();
+
+ }
+
+ private boolean isDbConnValid()
+ {
+
+ boolean isValid = false;
+
+ try
+ {
+ if (dbConn != null)
+ {
+ isValid = dbConn.isValid(1);
+ }
+ }
+ catch (SQLException e)
+ {}
+
+ return(isValid);
+ }
+public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
+
+
+
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+
+
+ boolean retval = false;
+ ResultSet results = null;
+
+ PreparedStatement hasGraphStmt = null;
+ if (version == null)
+ {
+ hasGraphStmt = hasActiveGraphStmt;
+ }
+ else
+ {
+ hasGraphStmt = hasVersionGraphStmt;
+ }
+
+
+
+ try
+ {
+ hasGraphStmt.setString(1, module);
+ hasGraphStmt.setString(2, rpc);
+ hasGraphStmt.setString(3, mode);
+
+
+ if (version != null)
+ {
+ hasGraphStmt.setString(4, version);
+ }
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ results = hasGraphStmt.executeQuery();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+
+ if (results.next())
+ {
+ int cnt = results.getInt(1);
+
+ if (cnt > 0)
+ {
+ retval = true;
+ }
+
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("SQL query failed", e);
+ }
+ finally
+ {
+ if (results != null)
+ {
+ try
+ {
+
+ results.close();
+ }
+ catch (SQLException x)
+ {}
+ }
+
+ }
+
+
+ return(retval);
+
+
+ }
+
+ public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException {
+
+
+
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+
+
+ SvcLogicGraph retval = null;
+ ResultSet results = null;
+
+ PreparedStatement fetchGraphStmt = null;
+ if (version == null)
+ {
+ fetchGraphStmt = fetchActiveGraphStmt;
+ }
+ else
+ {
+ fetchGraphStmt = fetchVersionGraphStmt;
+ }
+ try
+ {
+ fetchGraphStmt.setString(1, module);
+ fetchGraphStmt.setString(2, rpc);
+ fetchGraphStmt.setString(3, mode);
+
+
+ if (version != null)
+ {
+ fetchGraphStmt.setString(4, version);
+ }
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ results = fetchGraphStmt.executeQuery();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+
+ if (results.next())
+ {
+ Blob graphBlob = results.getBlob("graph");
+
+ ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream());
+
+ Object graphObj = gStream.readObject();
+ gStream.close();
+
+ if (graphObj instanceof SvcLogicGraph)
+ {
+ retval = (SvcLogicGraph) graphObj;
+ }
+ else
+ {
+ throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName());
+
+ }
+
+ }
+ else
+ {
+ return(null);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("SQL query failed", e);
+ }
+ finally
+ {
+ if (results != null)
+ {
+ try
+ {
+ results.close();
+ }
+ catch (SQLException x)
+ {}
+ }
+
+ }
+
+
+ return(retval);
+
+
+ }
+
+ public void store(SvcLogicGraph graph) throws SvcLogicException {
+
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+ if (graph == null)
+ {
+ throw new SvcLogicException("graph cannot be null");
+ }
+
+ byte[] graphBytes = null;
+
+ ByteArrayOutputStream byteStr = null;
+ ObjectOutputStream goutStr = null;
+
+ try
+ {
+ byteStr = new ByteArrayOutputStream();
+ goutStr = new ObjectOutputStream(byteStr);
+ goutStr.writeObject(graph);
+
+ graphBytes = byteStr.toByteArray();
+
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("could not serialize graph", e);
+ }
+ finally
+ {
+
+ if (goutStr != null)
+ {
+ try {
+ goutStr.close();
+ } catch (IOException e) {
+
+ }
+ }
+
+ if (byteStr != null)
+ {
+ try {
+ byteStr.close();
+ } catch (IOException e) {
+
+ }
+ }
+ }
+
+
+ // If object already stored in database, delete it
+ if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()))
+ {
+ delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode());
+ }
+
+ try
+ {
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ storeGraphStmt.setString(1, graph.getModule());
+ storeGraphStmt.setString(2, graph.getRpc());
+ storeGraphStmt.setString(3, graph.getVersion());
+ storeGraphStmt.setString(4, graph.getMode());
+ storeGraphStmt.setString(5, "N");
+ storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes));
+
+ storeGraphStmt.executeUpdate();
+ dbConn.commit();
+
+ dbConn.setAutoCommit(oldAutoCommit);
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Could not write object to database", e);
+ }
+ }
+
+ public void delete(String module, String rpc, String version, String mode) throws SvcLogicException
+ {
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+ try
+ {
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ deleteGraphStmt.setString(1, module);
+ deleteGraphStmt.setString(2, rpc);
+ deleteGraphStmt.setString(3, version);
+ deleteGraphStmt.setString(4, mode);
+
+
+ deleteGraphStmt.executeUpdate();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Could not delete object from database", e);
+ }
+ }
+
+ public void activate(SvcLogicGraph graph) throws SvcLogicException
+ {
+ try
+ {
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+
+ dbConn.setAutoCommit(false);
+
+ // Deactivate any current active version
+ deactivateStmt.setString(1, graph.getModule());
+ deactivateStmt.setString(2, graph.getRpc());
+ deactivateStmt.setString(3, graph.getMode());
+ deactivateStmt.executeUpdate();
+
+ // Activate this version
+ activateStmt.setString(1, graph.getModule());
+ activateStmt.setString(2, graph.getRpc());
+ activateStmt.setString(3, graph.getVersion());
+ activateStmt.setString(4, graph.getMode());
+ activateStmt.executeUpdate();
+
+ dbConn.commit();
+
+ dbConn.setAutoCommit(oldAutoCommit);
+
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Could not activate graph", e);
+ }
+ }
+
+ @Override
+ public void registerNodeType(String nodeType) throws SvcLogicException {
+
+ if (isValidNodeType(nodeType))
+ {
+ return;
+ }
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+ try
+ {
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ registerNodeStmt.setString(1, nodeType);
+ registerNodeStmt.executeUpdate();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Could not add node type to database", e);
+ }
+
+ }
+
+ @Override
+ public void unregisterNodeType(String nodeType) throws SvcLogicException {
+
+ if (!isValidNodeType(nodeType))
+ {
+ return;
+ }
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+ try
+ {
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ unregisterNodeStmt.setString(1, nodeType);
+ unregisterNodeStmt.executeUpdate();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Could not delete node type from database", e);
+ }
+
+ }
+
+ @Override
+ public boolean isValidNodeType(String nodeType) throws SvcLogicException {
+
+ boolean isValid = false;
+
+ if (!isDbConnValid())
+ {
+
+ // Try reinitializing
+ initDbResources();
+
+ if (!isDbConnValid())
+ {
+ throw new ConfigurationException("no jdbc connection");
+ }
+ }
+
+ ResultSet results = null;
+ try
+ {
+ validateNodeStmt.setString(1, nodeType);
+
+ boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn.setAutoCommit(false);
+ results = validateNodeStmt.executeQuery();
+ dbConn.commit();
+ dbConn.setAutoCommit(oldAutoCommit);
+
+ if (results != null)
+ {
+ if (results.next())
+ {
+ int cnt = results.getInt(1);
+
+ if (cnt > 0)
+ {
+ isValid = true;
+ }
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new SvcLogicException("Cannot select node type from database", e);
+ }
+ finally
+ {
+ if (results != null)
+ {
+ try
+ {
+ results.close();
+ }
+ catch (SQLException x)
+ {}
+ }
+
+ }
+
+ return(isValid);
+ }
+
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java
new file mode 100644
index 000000000..6828e9ad1
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java
@@ -0,0 +1,456 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ *
+ */
+package org.openecomp.sdnc.sli;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.Locator;
+
+
+public class SvcLogicNode implements Serializable {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicExprListener.class);
+
+ private static final long serialVersionUID = 2L;
+
+ private String nodeName;
+ private int nodeId;
+ private String nodeType;
+ private boolean visited;
+ private SvcLogicGraph graph;
+
+
+ private HashMap<String, SvcLogicExpression> attributes;
+ private HashMap<String, SvcLogicNode> outcomes;
+ private HashMap<String, SvcLogicExpression> parameters;
+
+ public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph)
+ {
+ this.nodeId = nodeId;
+ nodeName = "";
+ this.nodeType = nodeType;
+ this.graph = graph;
+ attributes = new HashMap<String, SvcLogicExpression> ();
+ parameters = new HashMap<String, SvcLogicExpression> ();
+ outcomes = null;
+
+ }
+
+ public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException
+ {
+ this.nodeId = nodeId;
+ this.nodeName = nodeName;
+ this.nodeType = nodeType;
+ this.graph = graph;
+ attributes = new HashMap<String, SvcLogicExpression> ();
+ parameters = new HashMap<String, SvcLogicExpression> ();
+ outcomes = null;
+ graph.setNamedNode(nodeName, this);
+ }
+
+
+ public int getNodeId()
+ {
+ return nodeId;
+ }
+
+ public String getNodeName()
+ {
+ return(nodeName);
+ }
+
+ public String getNodeType()
+ {
+ return(nodeType);
+ }
+
+ public SvcLogicGraph getGraph()
+ {
+ return(graph);
+ }
+
+ public int getNumOutcomes()
+ {
+ if (outcomes == null)
+ {
+ return(0);
+ }
+ else
+ {
+ return(outcomes.size());
+ }
+ }
+
+ public SvcLogicExpression getAttribute(String name)
+ {
+ if (attributes.containsKey(name))
+ {
+ return(attributes.get(name));
+ }
+ else
+ {
+ return(null);
+ }
+
+ }
+
+ public void setAttribute(String name, String value) throws SvcLogicException
+ {
+ setAttribute(name, new SvcLogicAtom("STRING", value));
+ }
+
+ public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException
+ {
+ if (attributes.containsKey(name))
+ {
+ throw new DuplicateValueException("Duplicate attribute "+name);
+ }
+
+ attributes.put(name, value);
+ }
+
+
+ public void mapParameter(String name, String value) throws SvcLogicException
+ {
+
+ if (parameters.containsKey(name))
+ {
+ throw new DuplicateValueException("Duplicate parameter "+name);
+ }
+ try
+ {
+ SvcLogicExpression parmValue;
+ if ((value == null) || (value.length() == 0))
+ {
+ parmValue = new SvcLogicAtom("STRING", "");
+ }
+ else if (value.trim().startsWith("`"))
+ {
+ int lastParen = value.lastIndexOf("`");
+ String evalExpr = value.trim().substring(1, lastParen);
+ parmValue = SvcLogicExpressionFactory.parse(evalExpr);
+
+ }
+ else
+ {
+ if (Character.isDigit(value.charAt(0)))
+ {
+ parmValue = new SvcLogicAtom("NUMBER", value);
+ }
+ else
+ {
+ parmValue = new SvcLogicAtom("STRING", value);
+ }
+ }
+ LOG.debug("Setting parameter "+name+" = "+value+" = "+parmValue.asParsedExpr());
+ parameters.put(name, parmValue);
+ }
+ catch (IOException e) {
+
+ LOG.error("Invalid parameter value expression ("+value+")");
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+
+ public SvcLogicExpression getParameter(String name)
+ {
+ if (parameters.containsKey(name))
+ {
+ return(parameters.get(name));
+ }
+ else
+ {
+ return(null);
+ }
+ }
+
+ public boolean isVisited() {
+ return visited;
+ }
+
+ public void setVisited(boolean visited, boolean recursive) {
+ this.visited = visited;
+
+ if (recursive)
+ {
+ Set<Map.Entry<String, SvcLogicNode>> outcomeSet = getOutcomeSet();
+
+ if (outcomeSet == null)
+ {
+ return;
+ }
+
+ for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator(); iter.hasNext();)
+ {
+ Map.Entry<String, SvcLogicNode> curOutcome = iter.next();
+ SvcLogicNode outNode = curOutcome.getValue();
+ outNode.setVisited(visited, recursive);
+ }
+ }
+ }
+
+ public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException
+ {
+ if (outcomes == null)
+ {
+ outcomes = new HashMap<String, SvcLogicNode>();
+ }
+
+ if (outcomeValue.length() == 0) {
+ outcomeValue = "\"\"";
+ }
+ if (outcomes.containsKey(outcomeValue))
+ {
+ throw new DuplicateValueException("Duplicate outcome value "+outcomeValue);
+ }
+
+ outcomes.put(outcomeValue, node);
+ }
+
+ public Set<Map.Entry<String, SvcLogicNode>> getOutcomeSet()
+ {
+ if (outcomes == null)
+ {
+ return null;
+ }
+
+ return(outcomes.entrySet());
+
+ }
+
+ public Set<Map.Entry<String, SvcLogicExpression>> getParameterSet()
+ {
+ if (parameters == null)
+ {
+ return null;
+ }
+
+ return(parameters.entrySet());
+
+ }
+
+ public void printAsGv(PrintStream pstr)
+ {
+
+ if (visited)
+ {
+ return;
+ }
+ else
+ {
+ visited = true;
+ }
+
+ StringBuffer sbuff = new StringBuffer();
+
+ sbuff.append("node");
+ sbuff.append(nodeId);
+ sbuff.append(" [ shape=none, margin=0, label=<<table border=\"0\" cellborder=\"1\" align=\"left\">");
+ sbuff.append("<tr><td colspan=\"2\"><b>");
+ sbuff.append(nodeId);
+ sbuff.append(" : ");
+ sbuff.append(nodeType);
+ sbuff.append("</b></td></tr><th><td><i>Attribute</i></td><td><i>Value</i></td></th>");
+
+ if (nodeName.length() > 0)
+ {
+ sbuff.append("<tr><td>name</td><td>");
+ sbuff.append(nodeName);
+ sbuff.append("</td></tr>");
+ }
+
+ Set<Map.Entry<String, SvcLogicExpression>> attrSet = attributes.entrySet();
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = attrSet.iterator() ; iter.hasNext();)
+ {
+ Map.Entry<String, SvcLogicExpression> curAttr = iter.next();
+ sbuff.append("<tr><td>");
+ sbuff.append(curAttr.getKey());
+ sbuff.append("</td><td>");
+ sbuff.append(StringEscapeUtils.escapeHtml3(curAttr.getValue().toString()));
+ sbuff.append("</td></tr>");
+ }
+ sbuff.append("</table>>];");
+
+ pstr.println(sbuff.toString());
+
+
+ if (outcomes != null)
+ {
+ TreeMap<String, SvcLogicNode> sortedOutcomes = new TreeMap<String, SvcLogicNode>(outcomes);
+ Set<Map.Entry<String, SvcLogicNode>> outcomeSet = sortedOutcomes.entrySet();
+
+ for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator(); iter.hasNext();)
+ {
+ Map.Entry<String, SvcLogicNode> curOutcome = iter.next();
+ String outValue = curOutcome.getKey();
+ SvcLogicNode outNode = curOutcome.getValue();
+ pstr.println("node"+nodeId+" -> node"+outNode.getNodeId()+" [label=\""+outValue+"\"];");
+ outNode.printAsGv(pstr);
+ }
+ }
+ }
+
+ public void printAsXml(PrintStream pstr, int indentLvl)
+ {
+ if (visited)
+ {
+ return;
+ }
+ // Print node tag
+ for (int i = 0 ; i < indentLvl ; i++)
+ {
+ pstr.print(" ");
+ }
+ pstr.print("<");
+ pstr.print(this.getNodeType());
+
+ Set<Map.Entry<String, SvcLogicExpression>> attrSet = attributes.entrySet();
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = attrSet.iterator() ; iter.hasNext();)
+ {
+ Map.Entry<String, SvcLogicExpression> curAttr = iter.next();
+ pstr.print(" ");
+ pstr.print(curAttr.getKey());
+ pstr.print("='`");
+ pstr.print(curAttr.getValue());
+ pstr.print("'`");
+ }
+
+ if (((parameters == null) || (parameters.isEmpty())) &&
+ ((outcomes == null) || outcomes.isEmpty()))
+ {
+ pstr.print("/>\n");
+ pstr.flush();
+ return;
+ }
+ else
+ {
+ pstr.print(">\n");
+ }
+
+ // Print parameters (if any)
+ if (parameters != null)
+ {
+ Set<Map.Entry<String, SvcLogicExpression>> paramSet = parameters.entrySet();
+ for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = paramSet.iterator() ; iter.hasNext();)
+ {
+ for (int i = 0 ; i < indentLvl+1 ; i++)
+ {
+ pstr.print(" ");
+ }
+ pstr.print("<parameter");
+ Map.Entry<String, SvcLogicExpression> curAttr = iter.next();
+ pstr.print(" name='");
+ pstr.print(curAttr.getKey());
+ pstr.print("' value='`");
+ pstr.print(curAttr.getValue().toString());
+ pstr.print("`'/>\n");
+ }
+ }
+
+ // Print outcomes (if any)
+ if (outcomes != null)
+ {
+ Set<Map.Entry<String, SvcLogicNode>> outcomeSet = outcomes.entrySet();
+ for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator() ; iter.hasNext();)
+ {
+ for (int i = 0 ; i < indentLvl+1 ; i++)
+ {
+ pstr.print(" ");
+ }
+ pstr.print("<outcome");
+ Map.Entry<String, SvcLogicNode> curAttr = iter.next();
+ pstr.print(" value='");
+ pstr.print(curAttr.getKey());
+ pstr.print("'>\n");
+ SvcLogicNode outNode = curAttr.getValue();
+ outNode.printAsXml(pstr, indentLvl+2);
+ for (int i = 0 ; i < indentLvl+1 ; i++)
+ {
+ pstr.print(" ");
+ }
+ pstr.print("</outcome>\n");
+ }
+ }
+
+ // Print node end tag
+ for (int i = 0 ; i < indentLvl ; i++)
+ {
+ pstr.print(" ");
+ }
+ pstr.print("</");
+ pstr.print(this.getNodeType());
+ pstr.print(">\n");
+ pstr.flush();
+
+ }
+
+
+ public SvcLogicNode getOutcomeValue(String value)
+ {
+
+ if (value.length() == 0) {
+ value = "\"\"";
+ }
+ if (outcomes == null)
+ {
+ return(null);
+ }
+
+ if (outcomes.containsKey(value))
+ {
+ return(outcomes.get(value));
+ }
+ else
+ {
+ StringBuffer keyBuffer = new StringBuffer();
+ keyBuffer.append("{");
+ for (String key : outcomes.keySet()) {
+ keyBuffer.append(" ("+key+")");
+ }
+ keyBuffer.append("}");
+ LOG.info("Outcome (" + value + ") not found, keys are " + keyBuffer.toString());
+
+ if (outcomes.containsKey("Other"))
+ {
+ return(outcomes.get("Other"));
+ }
+ else
+ {
+ return(null);
+ }
+ }
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java
new file mode 100644
index 000000000..398c28de7
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java
@@ -0,0 +1,598 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.LinkedList;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author dt5972
+ *
+ */
+public class SvcLogicParser {
+
+ SvcLogicStore store = null;
+ static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+ static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+ static final String JAXP_DYNAMIC_VALIDATION = "http://apache.org/xml/features/validation/dynamic";
+ static final String JAXP_SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema";
+
+ private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - ";
+ private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - ";
+ private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - ";
+ private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - ";
+ private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class);
+ private static final String SLI_VALIDATING_PARSER = "org.openecomp.sdnc.sli.parser.validate";
+ private static final String SVCLOGIC_XSD = "/svclogic.xsd";
+
+ private class SvcLogicHandler extends DefaultHandler {
+ private Locator locator = null;
+ private String module = null;
+ private String version = null;
+ private LinkedList<SvcLogicGraph> graphs = null;
+ private SvcLogicGraph curGraph = null;
+ private SvcLogicNode curNode = null;
+ private LinkedList<SvcLogicNode> nodeStack = null;
+ private int curNodeId = 0;
+ private String outcomeValue = null;
+ private LinkedList<String> outcomeStack = null;
+ private SvcLogicStore svcLogicStore = null;
+
+ public SvcLogicHandler(LinkedList<SvcLogicGraph> graphs, SvcLogicStore store) {
+ this.graphs = graphs;
+ this.curNode = null;
+ this.nodeStack = new LinkedList<>();
+ this.outcomeStack = new LinkedList<>();
+ this.curNodeId = 1;
+ this.outcomeValue = null;
+ this.svcLogicStore = store;
+
+ }
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+
+ // Handle service-logic (graph) tag
+ if ("service-logic".equalsIgnoreCase(qName)) {
+
+ module = attributes.getValue("module");
+ if (module == null || module.length() == 0) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'module' attribute from service-logic tag");
+ }
+
+ version = attributes.getValue("version");
+ if (version == null || version.length() == 0) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'version' attribute from service-logic tag");
+ }
+
+ return;
+ }
+
+ if ("method".equalsIgnoreCase(qName)) {
+ if (curGraph != null) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot nest module tags");
+ }
+ curGraph = new SvcLogicGraph();
+ curGraph.setModule(module);
+ curGraph.setVersion(version);
+ this.curNodeId = 1;
+
+ String attrValue = attributes.getValue("rpc");
+ if (attrValue == null || attrValue.length() == 0) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'rpc' attribute for method tag");
+ }
+ curGraph.setRpc(attrValue);
+
+ attrValue = attributes.getValue("mode");
+ if (attrValue == null || attrValue.length() == 0) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'mode' attribute for method tag");
+ }
+ curGraph.setMode(attrValue);
+
+ return;
+
+ }
+
+ // Handle outcome (edge) tag
+ if ("outcome".equalsIgnoreCase(qName)) {
+ String refValue = attributes.getValue("ref");
+
+ if (refValue != null) {
+ SvcLogicNode refNode = curGraph.getNamedNode(refValue);
+
+ if (refNode != null) {
+ try {
+ curNode.addOutcome(attributes.getValue("value"), refNode);
+ } catch (SvcLogicException e) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot add outcome", e);
+ }
+ } else {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "ref to unknown node " + refValue);
+ }
+ return;
+ }
+
+ if (outcomeValue != null) {
+ outcomeStack.push(outcomeValue);
+ }
+ outcomeValue = attributes.getValue("value");
+
+ return;
+ }
+
+ // Handle parameter tag
+ if ("parameter".equalsIgnoreCase(qName)) {
+ String parmName = attributes.getValue("name");
+ String parmValue = attributes.getValue("value");
+
+ if (parmName != null && parmName.length() > 0 && parmValue != null) {
+ try {
+
+ curNode.mapParameter(parmName, parmValue);
+ } catch (Exception e) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]");
+ }
+ }
+
+ return;
+ }
+
+ // Handle node tags
+
+ String nodeName = attributes.getValue("name");
+ SvcLogicNode thisNode = null;
+
+ try {
+ if (!svcLogicStore.isValidNodeType(qName)) {
+ throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Unknown tag " + qName);
+ }
+ } catch (Exception e) {
+ throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot validate node type " + qName);
+ }
+
+ try {
+ if (nodeName != null && nodeName.length() > 0) {
+ thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph);
+ } else {
+ thisNode = new SvcLogicNode(curNodeId++, qName, curGraph);
+ }
+
+ if (curGraph.getRootNode() == null) {
+ curGraph.setRootNode(thisNode);
+ }
+ } catch (SvcLogicException e) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage());
+
+ }
+
+ int numAttributes = attributes.getLength();
+
+ for (int i = 0; i < numAttributes; i++) {
+ String attrName = attributes.getQName(i);
+ if (!"name".equalsIgnoreCase(attrName)) {
+ try {
+
+ String attrValueStr = attributes.getValue(i);
+ SvcLogicExpression attrValue = null;
+ if (attrValueStr.trim().startsWith("`")) {
+ int lastParen = attrValueStr.lastIndexOf("`");
+ String evalExpr = attrValueStr.trim().substring(1, lastParen);
+ attrValue = SvcLogicExpressionFactory.parse(evalExpr);
+
+ } else {
+ if (Character.isDigit(attrValueStr.charAt(0))) {
+ attrValue = new SvcLogicAtom("NUMBER", attrValueStr);
+ } else {
+ attrValue = new SvcLogicAtom("STRING", attrValueStr);
+ }
+ }
+ thisNode.setAttribute(attrName, attrValue);
+ } catch (Exception e) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot set attribute " + attrName, e);
+ }
+ }
+ }
+
+ if (curNode != null) {
+ try {
+ if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) || "while".equalsIgnoreCase(curNode.getNodeType())) {
+ curNode.addOutcome("" + (curNode.getNumOutcomes() + 1), thisNode);
+ } else {
+ if (outcomeValue == null) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType());
+ }
+ curNode.addOutcome(outcomeValue, thisNode);
+ }
+ } catch (SvcLogicException e) {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage());
+ }
+ nodeStack.push(curNode);
+ }
+ curNode = thisNode;
+
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+
+ // Handle close of service-logic tag
+ if ("service-logic".equalsIgnoreCase(qName)) {
+ // Nothing more to do
+ return;
+ }
+
+ // Handle close of method tag
+ if ("method".equalsIgnoreCase(qName)) {
+ graphs.add(curGraph);
+ curGraph = null;
+ return;
+ }
+
+ // Handle close of outcome tag
+ if ("outcome".equalsIgnoreCase(qName)) {
+ // Finished this outcome - pop the outcome stack
+ if (outcomeStack.isEmpty()) {
+ outcomeValue = null;
+ } else {
+ outcomeValue = outcomeStack.pop();
+ }
+ return;
+ }
+
+ // Handle close of parameter tag - do nothing
+ if ("parameter".equalsIgnoreCase(qName)) {
+ return;
+ }
+
+ // Handle close of a node tag
+ if (nodeStack.isEmpty()) {
+ curNode = null;
+ } else {
+ curNode = nodeStack.pop();
+ }
+ }
+
+ @Override
+ public void error(SAXParseException arg0) throws SAXException {
+ throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage());
+ }
+
+ }
+
+ public SvcLogicParser(SvcLogicStore store) {
+ this.store = store;
+ }
+
+ public SvcLogicParser(String propFile) {
+
+ try {
+ this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile);
+ } catch (Exception e) {
+ LOGGER.error(SVC_LOGIC_STORE_ERROR, e);
+
+ }
+
+ }
+
+ public SvcLogicParser(InputStream propStr) {
+
+ try {
+ this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr);
+ } catch (Exception e) {
+ LOGGER.error(SVC_LOGIC_STORE_ERROR, e);
+
+ }
+
+ }
+
+ public LinkedList<SvcLogicGraph> parse(String fileName) throws SvcLogicException {
+ LinkedList<SvcLogicGraph> graphs = null;
+
+ URL xsdUrl = null;
+ Schema schema = null;
+ String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true");
+
+ if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) {
+ xsdUrl = getClass().getResource(SVCLOGIC_XSD);
+
+ }
+
+ if (xsdUrl != null) {
+ try {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ schema = schemaFactory.newSchema(xsdUrl);
+ } catch (Exception e) {
+ LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e);
+ }
+ } else {
+ LOGGER.warn("Could not find resource " + SVCLOGIC_XSD);
+ }
+
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ if (schema != null) {
+ factory.setNamespaceAware(true);
+ factory.setSchema(schema);
+ }
+ SAXParser saxParser = factory.newSAXParser();
+
+ if (saxParser.isValidating()) {
+ LOGGER.info("Validating against schema " + xsdUrl.getPath());
+ }
+ graphs = new LinkedList<>();
+
+ saxParser.parse(fileName, new SvcLogicHandler(graphs, store));
+
+ } catch (Exception e) {
+ String msg = e.getMessage();
+ if (msg != null) {
+ LOGGER.error(msg);
+ throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg);
+ } else {
+ LOGGER.info("Caught exception parsing " + fileName, e);
+ throw new SvcLogicException("Compiler error: " + fileName, e);
+ }
+ }
+
+ return graphs;
+ }
+
+ public static void main(String argv[]) {
+
+ if (argv.length == 0) {
+ SvcLogicParser.usage();
+ }
+
+ if ("load".equalsIgnoreCase(argv[0])) {
+ if (argv.length == 3) {
+ String xmlfile = argv[1];
+ String propfile = argv[2];
+
+ SvcLogicStore store = SvcLogicParser.getStore(propfile);
+ try {
+ SvcLogicParser.load(xmlfile, store);
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ } else {
+ SvcLogicParser.usage();
+ }
+ } else if ("print".equalsIgnoreCase(argv[0])) {
+ String version = null;
+ String propfile = null;
+
+ switch (argv.length) {
+ case 6:
+ version = argv[4];
+ propfile = argv[5];
+ case 5:
+ if (propfile == null) {
+ propfile = argv[4];
+ }
+ SvcLogicStore store = SvcLogicParser.getStore(propfile);
+ SvcLogicParser.print(argv[1], argv[2], argv[3], version, store);
+ break;
+ default:
+ SvcLogicParser.usage();
+ }
+ } else if ("get-source".equalsIgnoreCase(argv[0])) {
+
+ switch (argv.length) {
+ case 6:
+ SvcLogicStore store = SvcLogicParser.getStore(argv[5]);
+ SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store);
+ break;
+ default:
+ SvcLogicParser.usage();
+ }
+ } else if ("activate".equalsIgnoreCase(argv[0])) {
+ if (argv.length == 6) {
+ SvcLogicStore store = SvcLogicParser.getStore(argv[5]);
+ SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store);
+ } else {
+ SvcLogicParser.usage();
+ }
+ } else if ("validate".equalsIgnoreCase(argv[0])) {
+ if (argv.length == 3) {
+ String xmlfile = argv[1];
+ String propfile = argv[2];
+
+ System.setProperty(SLI_VALIDATING_PARSER, "true");
+ SvcLogicStore store = SvcLogicParser.getStore(propfile);
+ try {
+ SvcLogicParser.validate(xmlfile, store);
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ } else {
+ SvcLogicParser.usage();
+ }
+ }
+
+ System.exit(0);
+ }
+
+ private static SvcLogicStore getStore(String propfile) {
+
+ SvcLogicStore store = null;
+
+ try {
+ store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
+ } catch (Exception e) {
+ LOGGER.error(SVC_LOGIC_STORE_ERROR, e);
+ System.exit(1);
+ }
+
+ return store;
+
+ }
+
+ public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException {
+ File xmlFile = new File(xmlfile);
+ if (!xmlFile.canRead()) {
+ throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")");
+ }
+
+ SvcLogicParser parser = new SvcLogicParser(store);
+ LinkedList<SvcLogicGraph> graphs = null;
+ try {
+ graphs = parser.parse(xmlfile);
+ } catch (Exception e) {
+ throw new SvcLogicException(e.getMessage(), e);
+ }
+
+ if (graphs == null) {
+ throw new SvcLogicException("Could not parse " + xmlfile);
+ }
+
+ for (SvcLogicGraph graph : graphs) {
+
+ String module = graph.getModule();
+ String rpc = graph.getRpc();
+ String version = graph.getVersion();
+ String mode = graph.getMode();
+ try {
+ LOGGER.info("Saving SvcLogicGraph to database (module:" + module + ",rpc:" + rpc + ",version:" + version + ",mode:" + mode + ")");
+ store.store(graph);
+ } catch (Exception e) {
+ throw new SvcLogicException(e.getMessage(), e);
+ }
+
+ }
+
+ }
+
+ public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException {
+ File xmlFile = new File(xmlfile);
+ if (!xmlFile.canRead()) {
+ throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")");
+ }
+
+ SvcLogicParser parser = new SvcLogicParser(store);
+ LinkedList<SvcLogicGraph> graphs = null;
+ try {
+ LOGGER.info("Validating " + xmlfile);
+ graphs = parser.parse(xmlfile);
+ } catch (Exception e) {
+ throw new SvcLogicException(e.getMessage(), e);
+ }
+
+ if (graphs == null) {
+ throw new SvcLogicException("Could not parse " + xmlfile);
+ } else {
+ LOGGER.info("Compilation successful for " + xmlfile);
+ }
+
+ }
+
+ private static void print(String module, String rpc, String mode, String version, SvcLogicStore store) {
+ String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")";
+
+ try {
+ LOGGER.info(LOAD_MESSAGE + details);
+
+ SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
+ if (graph == null) {
+ LOGGER.error(LOAD_ERROR_MESSAGE + details);
+ System.exit(1);
+ }
+ graph.printAsGv(System.out);
+ } catch (Exception e) {
+ LOGGER.error(PRINT_ERROR_MESSAGE + details, e);
+ System.exit(1);
+ }
+
+ }
+
+ private static void getSource(String module, String rpc, String mode, String version, SvcLogicStore store) {
+ String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")";
+
+ try {
+ LOGGER.info(LOAD_MESSAGE + details);
+
+ SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
+ if (graph == null) {
+ LOGGER.error(LOAD_ERROR_MESSAGE + details);
+ System.exit(1);
+ }
+ graph.printAsXml(System.out);
+ } catch (Exception e) {
+ LOGGER.error(PRINT_ERROR_MESSAGE + details, e);
+ System.exit(1);
+ }
+
+ }
+
+ private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) {
+ String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")";
+
+ try {
+ LOGGER.info(LOAD_MESSAGE + details);
+
+ SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
+ if (graph == null) {
+ LOGGER.error(LOAD_ERROR_MESSAGE + details);
+ System.exit(1);
+ }
+ store.activate(graph);
+ } catch (Exception e) {
+ LOGGER.error(ACTIVATION_ERROR_MESSAGE + details, e);
+ System.exit(1);
+ }
+
+ }
+
+ private static void usage() {
+ System.err.println("Usage: SvcLogicParser load <xml-file> <prop-file>");
+ System.err.println(" OR SvcLogicParser print <module> <rpc> <mode> [<version>] <prop-file>");
+ System.err.println(" OR SvcLogicParser get-source <module> <rpc> <mode> <version> <prop-file>");
+ System.err.println(" OR SvcLogicParser activate <module> <rpc> <version> <mode>");
+ System.exit(1);
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java
new file mode 100644
index 000000000..ac9c515e9
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.IOException;
+
+public class SvcLogicParserException extends IOException {
+
+ public SvcLogicParserException() {
+ super();
+ }
+
+ public SvcLogicParserException(String msg) {
+ super(msg);
+ }
+
+ public SvcLogicParserException(Throwable t) {
+ super(t);
+ }
+
+ public SvcLogicParserException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java
new file mode 100644
index 000000000..8a23adf1a
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.Map;
+
+public interface SvcLogicRecorder {
+
+ void record(Map<String, String> parmMap) throws SvcLogicException;
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java
new file mode 100644
index 000000000..5fc00f87b
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+public interface SvcLogicResource {
+
+ public enum QueryStatus {
+ SUCCESS,
+ NOT_FOUND,
+ FAILURE
+ }
+
+ public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException;
+
+ public QueryStatus update(String resource, String key, Map<String, String> parms, String prefix, SvcLogicContext ctx) throws SvcLogicException;
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java
new file mode 100644
index 000000000..6959c86a8
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.util.Properties;
+
+public interface SvcLogicStore {
+
+ public void init(Properties props) throws SvcLogicException;
+ public void registerNodeType(String nodeType) throws SvcLogicException;
+ public void unregisterNodeType(String nodeType) throws SvcLogicException;
+ public boolean isValidNodeType(String nodeType) throws SvcLogicException;
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException;
+ public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException;
+ public void store(SvcLogicGraph graph) throws SvcLogicException;
+ public void delete(String module, String rpc, String version, String mode) throws SvcLogicException;
+ public void activate(SvcLogicGraph graph) throws SvcLogicException;
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java
new file mode 100644
index 000000000..8b6618bef
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SvcLogicStoreFactory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicStoreFactory.class);
+
+ public static SvcLogicStore getSvcLogicStore(String propfile)
+ throws SvcLogicException {
+ File propFile = new File(propfile);
+ if (!propFile.canRead()) {
+ throw new ConfigurationException("Cannot read property file "
+ + propfile);
+
+ }
+
+ try {
+ return (getSvcLogicStore(new FileInputStream(propFile)));
+ } catch (Exception e) {
+ throw new ConfigurationException(
+ "Could load service store from properties file " + propfile,
+ e);
+ }
+
+ }
+
+ public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException
+ {
+ Properties props = new Properties();
+
+ try {
+ props.load(inStr);
+ } catch (Exception e) {
+ throw new ConfigurationException("Could not get load properties from input stream", e);
+ }
+
+ return(getSvcLogicStore(props));
+ }
+
+ public static SvcLogicStore getSvcLogicStore(Properties props)
+ throws SvcLogicException {
+ String storeType = props.getProperty("org.openecomp.sdnc.sli.dbtype");
+ if ((storeType == null) || (storeType.length() == 0)) {
+ throw new ConfigurationException(
+ "property org.openecomp.sdnc.sli.dbtype unset");
+
+ }
+
+ SvcLogicStore retval = null;
+ LOG.debug(String.format("Using org.openecomp.sdnc.sli.dbtype=%s", storeType));
+
+ if ("jdbc".equalsIgnoreCase(storeType)) {
+ retval = new SvcLogicJdbcStore();
+
+ } else if ("dblib".equalsIgnoreCase(storeType)) {
+ retval = new SvcLogicDblibStore();
+ } else {
+ throw new ConfigurationException("unsupported dbtype (" + storeType
+ + ")");
+
+ }
+
+
+ retval.init(props);
+ return (retval);
+ }
+
+}
diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java
new file mode 100644
index 000000000..9ddc3c0b8
--- /dev/null
+++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+public class SvcLogicVariableTerm extends SvcLogicExpression {
+
+ private String name = null;
+
+ public String getName() {
+ return name;
+ }
+
+
+ public SvcLogicVariableTerm(String identifier)
+ {
+ this.name = identifier;
+ }
+
+ public SvcLogicExpression getSubscript()
+ {
+ if (numOperands() > 0)
+ {
+ return(getOperands().get(0));
+ }
+ else
+ {
+ return(null);
+ }
+ }
+
+
+ public String toString()
+ {
+ String retval = "";
+
+ if (numOperands() > 0)
+ {
+ retval = name + "[" + getSubscript().toString() + "]";
+ }
+ else
+ {
+ retval = name;
+ }
+ return(retval);
+ }
+
+ @Override
+ public String asParsedExpr() {
+ if (numOperands() == 0) {
+ return("(variable-term "+name+")");
+ }
+ else
+ {
+ return("(variable-term "+name+" "+getSubscript().asParsedExpr()+")");
+ }
+ }
+
+}
diff --git a/sli/common/src/main/resources/crAseNetwork.sql b/sli/common/src/main/resources/crAseNetwork.sql
new file mode 100644
index 000000000..412311761
--- /dev/null
+++ b/sli/common/src/main/resources/crAseNetwork.sql
@@ -0,0 +1,82 @@
+---
+-- ============LICENSE_START=======================================================
+-- openECOMP : SDN-C
+-- ================================================================================
+-- Copyright (C) 2017 AT&T Intellectual Property. All rights
+-- reserved.
+-- ================================================================================
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- ============LICENSE_END=========================================================
+---
+
+CREATE TABLE sdnctl.ASE (
+ ase_network_id INT NOT NULL,
+ topology VARCHAR(25),
+ CONSTRAINT P_ASE PRIMARY KEY(ase_network_id));
+
+CREATE TABLE sdnctl.ASE_PORT (
+ esm_name VARCHAR(25),
+ resource_emt_clli VARCHAR(25) NOT NULL,
+ resource_emt_ip_addr VARCHAR(25) NOT NULL,
+ port_action VARCHAR(25),
+ profile VARCHAR(25) ,
+ port VARCHAR(15) NOT NULL,
+ state VARCHAR(25),
+ resource_mode VARCHAR(25),
+ speed INT,
+ resource_lldp VARCHAR(1),
+ resource_mtu VARCHAR(5),
+ resource_autoneg VARCHAR(10),
+ resource_twamp VARCHAR(10),
+ resource_description VARCHAR(80),
+ uni_circuit_id VARCHAR(45),
+ CONSTRAINT P_ASE_PORT PRIMARY KEY(resource_emt_clli, port));
+
+CREATE TABLE sdnctl.ASE_EVC (
+ esm_name VARCHAR(25),
+ emt_ip_addr VARCHAR(25) NOT NULL,
+ evc_action VARCHAR(25),
+ service_id VARCHAR(25),
+ serv_type VARCHAR(25),
+ evc_choice VARCHAR(25),
+ uni_port VARCHAR(25) NOT NULL,
+ lag_port VARCHAR(25),
+ mac_onoff VARCHAR(25),
+ ppcos VARCHAR(25),
+ cir VARCHAR(25),
+ cbs VARCHAR(25),
+ ebs VARCHAR(25),
+ sgos VARCHAR(25),
+ pe VARCHAR(25),
+ unit VARCHAR(25),
+ qinq VARCHAR(25),
+ interface VARCHAR(25),
+ evc_description VARCHAR(80),
+ bandwidth VARCHAR(10),
+ svlan VARCHAR(5),
+ cvlan VARCHAR(5),
+ routing_instance VARCHAR(25),
+ rd VARCHAR(25),
+ rt VARCHAR(25),
+ evc_limit VARCHAR(25),
+ label_block_size VARCHAR(25),
+ site VARCHAR(25),
+ int_mac_limit VARCHAR(5),
+ sgos_grade VARCHAR(25),
+ bum_rate VARCHAR(25),
+ uni_circuit_id VARCHAR(45),
+ leg INT,
+ CONSTRAINT P_ASE_EVC PRIMARY KEY(emt_ip_addr, uni_port,leg));
+
+
+
diff --git a/sli/common/src/main/resources/svclogic.xsd b/sli/common/src/main/resources/svclogic.xsd
new file mode 100755
index 000000000..f74bd5dcd
--- /dev/null
+++ b/sli/common/src/main/resources/svclogic.xsd
@@ -0,0 +1,334 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.openecomp.org/sdnc/svclogic" xmlns="http://www.openecomp.org/sdnc/svclogic">
+
+ <xsd:simpleType name="modeType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="sync" />
+ <xsd:enumeration value="async" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:group name="node">
+ <xsd:choice>
+ <xsd:element ref="block" />
+ <xsd:element ref="is-available" />
+ <xsd:element ref="exists" />
+ <xsd:element ref="reserve" />
+ <xsd:element ref="release" />
+ <xsd:element ref="allocate" />
+ <xsd:element ref="get-resource" />
+ <xsd:element ref="configure" />
+ <xsd:element ref="return" />
+ <xsd:element ref="switch" />
+ <xsd:element ref="record" />
+ <xsd:element ref="save" />
+ <xsd:element ref="for" />
+ <xsd:element ref="set" />
+ <xsd:element ref="execute" />
+ <xsd:element ref="delete" />
+ <xsd:element ref="update" />
+ <xsd:element ref="call" />
+ <xsd:element ref="notify" />
+ <xsd:element ref="break" />
+ <xsd:element ref="while" />
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:element name="service-logic">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="method" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="module" use="required" type="xsd:string" />
+ <xsd:attribute name="version" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="method">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="rpc" use="required" type="xsd:string" />
+ <xsd:attribute name="mode" use="optional" type="modeType" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="block">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="atomic" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="is-available">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="exists">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="outcome">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string" />
+ <xsd:attribute name="value" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="reserve">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="select" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="release">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="record">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="allocate">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ <xsd:attribute name="pfx" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="get-resource">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="order-by" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configure">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="adaptor" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ <xsd:attribute name="activate" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="parameter">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="value" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="return">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="status" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="switch">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="test" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="save">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="force" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="delete">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ <!-- local-only is retired and does not do anything -->
+ <xsd:attribute name="local-only" use="optional" type="xsd:string" />
+ <!-- pfx is retired and does not do anything -->
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="for">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="atomic" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="index" use="required" type="xsd:string" />
+ <xsd:attribute name="start" use="required" type="xsd:string" />
+ <xsd:attribute name="end" use="required" type="xsd:string" />
+ <xsd:attribute name="silentFailure" use="optional" type="xsd:boolean" default="false" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="only-if-unset" use="optional"
+ type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="execute">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="method" use="required" type="xsd:string" />
+ <xsd:attribute name="emitsOutcome" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="update">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="force" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="call">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="module" use="optional" type="xsd:string" />
+ <xsd:attribute name="rpc" use="required" type="xsd:string" />
+ <xsd:attribute name="version" use="optional" type="xsd:string" />
+ <xsd:attribute name="mode" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="notify">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="optional" type="xsd:string" />
+ <xsd:attribute name="resource" use="optional" type="xsd:string" />
+ <xsd:attribute name="action" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="break">
+ <xsd:complexType />
+ </xsd:element>
+
+ <xsd:element name="while">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="test" use="required" type="xsd:string" />
+ <xsd:attribute name="do" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sli/common/src/main/yang/ase-network.yang b/sli/common/src/main/yang/ase-network.yang
new file mode 100755
index 000000000..ae654ae04
--- /dev/null
+++ b/sli/common/src/main/yang/ase-network.yang
@@ -0,0 +1,179 @@
+module ase {
+ namespace "att:ase";
+ prefix ase;
+ revision "2014-06-03" {
+ description "Example ASE Network Module";
+ }
+
+ container ase {
+ config true;
+ leaf ase-network-id{
+ type uint32;
+ }
+ leaf topology {
+ type string ; // check enum
+ }
+ }
+
+ container ase-port {
+ config true;
+ // is this really a list of cpe ports one for each uni-ckt
+ leaf esm-name {
+ type string;
+ }
+
+ leaf resource-emt-clli {
+ type string;
+ }
+
+ leaf resource-emt-ip-addr{
+ type string;
+ }
+ leaf port-action {
+ type string;
+ }
+ leaf profile {
+ type string;
+ }
+ leaf port {
+ type string;
+ }
+ leaf state {
+ type string;
+ }
+ leaf resource-mode {
+ type string;
+ }
+ leaf speed {
+ type string;
+ }
+ leaf resource-lldp {
+ type string;
+ }
+ leaf resource-mtu {
+ type string;
+ }
+ leaf resource-autoneg{
+ type string;
+ }
+ leaf resource-twamp {
+ type string;
+ }
+ leaf resource-description {
+ type string;
+ }
+ leaf uni-circuit-id {
+ type string;
+ }
+ } // ase-port container
+
+ container ase-evc {
+// Port contains a list of EVC
+// EVCs are either point to point or multipoint (topology)
+// EVCs are connected ? what ID is used to connected them ? (network-id) ?
+ config true;
+ leaf esm-name {
+ type string;
+ }
+ leaf emt-ip-addr {
+ type string;
+ }
+ leaf evc-action {
+ type string;
+ }
+ leaf service-id {
+ type string;
+ }
+
+ leaf serv-type {
+ type string;
+ }
+ leaf evc-choice {
+ type string;
+ }
+ leaf uni-port {
+ type string;
+ }
+ leaf lag-port {
+ type string;
+ }
+ leaf mac-onoff {
+ type string;
+ }
+
+ leaf ppcos {
+ type string;
+ }
+ leaf cir {
+ type string;
+ }
+ leaf cbs {
+ type string;
+ }
+ leaf ebs {
+ type string;
+ }
+ leaf sgos {
+ type string;
+ }
+// ipag Device Data
+ leaf pe {
+ type string;
+ }
+ leaf unit {
+ type string;
+ }
+ leaf qinq {
+ type string;
+ }
+ leaf interface {
+ type string;
+ }
+ leaf evc-description {
+ type string;
+ }
+ leaf bandwidth {
+ type string;
+ }
+ leaf svlan {
+ type string;
+ description "Service VLAN is either outer tag or only tag depending on QinQ";
+ }
+ leaf cvlan {
+ type string;
+ description "Customer VLAN is null if not QinQ";
+ }
+ leaf routing-instance {
+ type string;
+ }
+ leaf rd {
+ type string;
+ }
+ leaf rt {
+ type string;
+ }
+ leaf limit {
+ type string;
+ }
+ leaf label-block-size {
+ type string;
+ }
+ leaf site {
+ type string;
+ }
+ leaf int-mac-limit {
+ type string;
+ }
+ leaf sgos-grade {
+ type string;
+ }
+ leaf bum-rate {
+ type string;
+ }
+ leaf uni-circuit-id {
+ type string;
+ }
+ } // ase-evc container
+
+} // module ase-network
+
diff --git a/sli/common/src/main/yang/ase-type.yang b/sli/common/src/main/yang/ase-type.yang
new file mode 100755
index 000000000..2de186e69
--- /dev/null
+++ b/sli/common/src/main/yang/ase-type.yang
@@ -0,0 +1,561 @@
+module ase-type {
+
+ namespace "att:ase:type";
+ prefix ase-type;
+
+ organization "AT&T ASE";
+
+ revision 2014-06-09 {
+ description
+ "Initial version";
+ }
+
+ /////////////////////////////////////////////////////
+ // ASE Service Model Typedefs & Groupings
+ /////////////////////////////////////////////////////
+
+ typedef query-type {
+ type enumeration {
+ enum getDevicePortDetails{
+ value 0;
+ }
+ enum GetServiceDetailsRequest{
+ value 1;
+ }
+ }
+ }
+
+ typedef uni-action-type {
+ type enumeration {
+ enum PortPreReserveRequest{
+ value 0;
+ }
+ enum PortReleaseRequest{
+ value 1;
+ }
+ enum PortDeProvRequest{
+ value 2;
+ }
+ enum ChangePortProvRequest{
+ value 3;
+ }
+ enum PortActivateRequest{
+ value 4;
+ }
+ enum ChangePortActivateRequest{
+ value 5;
+ }
+ enum DisconnectPortRequest{
+ value 6;
+ }
+ enum getDevicePortDetails{
+ value 7;
+ }
+ }
+ }
+
+ typedef evc-action-type {
+ type enumeration {
+ enum ConnectionProvRequest{
+ value 0;
+ }
+ enum ChangeConnectionProvRequest{
+ value 1;
+ }
+ enum ConnectionDeProvrequest{
+ value 2;
+ }
+ enum ConnectionActivateRequest{
+ value 3;
+ }
+ enum ChangeConnectionActivateRequest{
+ value 4;
+ }
+ enum DisconnectConnectionRequest{
+ value 5;
+ }
+ enum GetServiceDetailsRequest{
+ value 6;
+ }
+ }
+ }
+
+ typedef evc-gos-type {
+ type enumeration {
+ enum "REAL-TIME"{
+ value 0;
+ }
+ enum "INTERACTIVE"{
+ value 1;
+ }
+ enum "BUSINESS-CRITICAL-HIGH"{
+ value 2;
+ }
+ enum "BUSINESS-CRITICAL-MEDIUM"{
+ value 3;
+ }
+ enum "NON-CRITICAL-HIGH"{
+ value 4;
+ }
+ enum "NON-CRITICAL-LOW"{
+ value 5;
+ }
+ }
+ }
+
+ typedef cir-rate-type {
+ type enumeration {
+ enum "Mbps"{
+ value 0;
+ }
+ enum "Gbps"{
+ value 1;
+ }
+ }
+ }
+
+ typedef ase-yes-no-type {
+ type enumeration {
+ enum "Y"{
+ value 0;
+ }
+ enum "N"{
+ value 1;
+ }
+ }
+ }
+
+ typedef provisioning-indicator {
+ type enumeration {
+ enum "Y"{
+ value 0;
+ }
+ enum "N"{
+ value 1;
+ }
+ }
+ }
+
+ typedef media-type {
+ type enumeration {
+ enum "SFP-1GE-SX"{
+ value 0;
+ }
+ enum "SFP-1GE-LX"{
+ value 1;
+ }
+ enum "SFP-1GE"{
+ value 2;
+ }
+ enum "Ethernet-10_100_1000M"{
+ value 3;
+ }
+ }
+ }
+
+ typedef media-speed-type {
+ type enumeration {
+ enum "100"{
+ value 0;
+ }
+ enum "1000"{
+ value 1;
+ }
+ enum "10000"{
+ value 2;
+ }
+ }
+ }
+
+ typedef cos-category-type {
+ type enumeration {
+ enum "GOS"{
+ value 0;
+ }
+ enum "PPCOS"{
+ value 1;
+ }
+ }
+ }
+
+ typedef uni-gos-type {
+ type enumeration {
+ enum "INTERACTIVE"{
+ value 0;
+ }
+ enum "BUSINESS-CRITICAL-HIGH"{
+ value 1;
+ }
+ enum "BUSINESS-CRITICAL-MEDIUM"{
+ value 2;
+ }
+ enum "NON-CRITICAL-HIGH"{
+ value 3;
+ }
+ }
+ }
+
+ typedef uni-cir-value-type {
+ type enumeration {
+ enum "2"{
+ value 0;
+ }
+ enum "4"{
+ value 1;
+ }
+ enum "5"{
+ value 2;
+ }
+ enum "8"{
+ value 3;
+ }
+ enum "10"{
+ value 4;
+ }
+ enum "20"{
+ value 5;
+ }
+ enum "30"{
+ value 6;
+ }
+ enum "40"{
+ value 7;
+ }
+ enum "50"{
+ value 8;
+ }
+ enum "60"{
+ value 9;
+ }
+ enum "70"{
+ value 10;
+ }
+ enum "80"{
+ value 11;
+ }
+ enum "90"{
+ value 12;
+ }
+ enum "100"{
+ value 13;
+ }
+ enum "125"{
+ value 14;
+ }
+ enum "150"{
+ value 15;
+ }
+ enum "175"{
+ value 16;
+ }
+ enum "200"{
+ value 17;
+ }
+ enum "225"{
+ value 18;
+ }
+ enum "250"{
+ value 19;
+ }
+ }
+ }
+
+ typedef uni-mac-limit-type {
+ description "MAC address limit for UNI port";
+ type enumeration {
+ enum "Y"{
+ value 0;
+ }
+ enum "N"{
+ value 1;
+ }
+ }
+ }
+
+ typedef port-tagging-type {
+ type enumeration {
+ enum "port-based"{
+ value 0;
+ }
+ enum "vlan-based"{
+ value 1;
+ }
+ }
+ }
+
+ typedef port-status {
+ type enumeration {
+ enum "Available"{
+ value 0;
+ }
+ enum "Reserved"{
+ value 1;
+ }
+ enum "Active" {
+ value 2;
+ }
+ }
+ }
+
+ grouping uni-common-request-hdr {
+ leaf request-id {
+ type string;
+ mandatory true;
+ }
+ leaf source {
+ description "The source system requesting action or info";
+ type string;
+ mandatory true;
+ }
+ leaf request-action {
+ description "action indicator for this service instance";
+ type uni-action-type;
+ }
+ leaf undo-indicator {
+ type provisioning-indicator;
+ }
+ leaf notification-url {
+ description "When this field exists, NCS will return an "
+ + "acknowledgement that the request is legal "
+ + "Once the activate is finished (or fails) NCS"
+ + "will utilize the URL to indicate the status";
+ type string;
+ }
+ }
+
+ grouping uni-common-return-hdr {
+ leaf request-action {
+ description "action indicator for this service instance";
+ type uni-action-type;
+ }
+ leaf request-id {
+ description "Identifier for the request from NGO";
+ type string;
+
+ }
+ }
+
+ grouping uni-common-error-format {
+ leaf error-code {
+ description "Error code";
+ type int32;
+ }
+ leaf error-message {
+ description "Error text describing the API error occurance";
+ type string;
+ }
+ }
+
+ grouping query-common-hdr {
+ leaf request-id {
+ description "Identifier for the request from NGO";
+ type string;
+ }
+ leaf request-type {
+ description "action indicator for this service instance";
+ type query-type;
+ }
+ }
+
+ grouping query-error-format {
+ leaf error-code {
+ description "Error code";
+ type int32;
+ }
+ leaf error-message {
+ description "Error text describing the API error occurance";
+ type string;
+ }
+ }
+
+ grouping evc-common-request-hdr {
+ leaf request-id {
+ description "Identifier for the request from NGO";
+ type string;
+ }
+ leaf source {
+ description "The source system requesting action or info";
+ type string;
+ mandatory true;
+ }
+ leaf uni-order-number {
+ type string;
+ }
+ leaf request-action {
+ description "action indicator for this service instance";
+ type evc-action-type;
+ mandatory true;
+ }
+ leaf undo-indicator {
+ type provisioning-indicator;
+ }
+ leaf notification-url {
+ description "When this field exists, NCS will return an "
+ + "acknowledgement that the request is legal "
+ + "Once the activate is finished (or fails) NCS"
+ + "will utilize the URL to indicate the status";
+ type string;
+ }
+ leaf evc-name {
+ type string;
+ mandatory true;
+ }
+ }
+
+ grouping evc-common-error-format {
+ leaf error-code {
+ description "Error code";
+ type int32;
+ }
+ leaf error-message {
+ description "Error text describing the API error occurance";
+ type string;
+ }
+ }
+
+ /////////////////////////////////////////
+ // UNI-PORTS table contains all circuits
+ /////////////////////////////////////////
+ container uni-ports {
+ description
+ "UNI port container";
+ list uni-port {
+ key "uni-circuit-id";
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ leaf subscriber-name {
+ type string;
+ mandatory true;
+ }
+ leaf uni-order-number {
+ type string;
+ mandatory true;
+ }
+ leaf edge-device-clli {
+ description "Edge device (e.g. EMT) on which port "
+ + " reservation is needed";
+ type string;
+ mandatory true;
+ }
+ leaf uni-location-city {
+ type string;
+ mandatory true;
+ }
+ leaf uni-location-state {
+ type string;
+ mandatory true;
+ }
+ leaf media-type {
+ type media-type;
+ mandatory true;
+ }
+ leaf media-speed {
+ type media-speed-type;
+ mandatory true;
+ }
+ leaf uni-cir-value {
+ description "Integer value for the CIR";
+ type uni-cir-value-type;
+ mandatory true;
+ }
+ leaf uni-cir-units {
+ description "Units for the CIR";
+ type cir-rate-type;
+ mandatory true;
+ }
+ leaf cos-category {
+ description "CoS Type";
+ type cos-category-type;
+ mandatory true;
+ }
+ leaf gos-profile {
+ description "GoS tpye";
+ type uni-gos-type;
+ mandatory true;
+ }
+ leaf aditional-mac-allowed {
+ type uni-mac-limit-type;
+ }
+ leaf port-tagging {
+ type port-tagging-type;
+ mandatory true;
+ }
+ leaf port-status {
+ type port-status;
+ }
+ leaf name-value-pair {
+ type string;
+ }
+ }
+ }
+
+ ///////////////////////////////////////////
+ // EVCS table contains all evc associations
+ ///////////////////////////////////////////
+ container evcs {
+ list evc {
+ key "evc-name";
+ leaf evc-name {
+ type string;
+ mandatory true;
+ }
+ leaf topology {
+ type enumeration {
+ enum "MultiPoint"{
+ value 0;
+ }
+ enum "PointToPoint"{
+ value 1;
+ }
+ }
+ }
+ list evc-leg {
+ key evc-access-name;
+ leaf evc-access-name {
+ type string;
+ }
+ leaf subscriber-name {
+ type string;
+ }
+ leaf cvlan {
+ type uint16 {
+ range "2..4090";
+ }
+ }
+ leaf connection-cir-value {
+ type uni-cir-value-type;
+ }
+ leaf connection-cir-units-string {
+ type cir-rate-type;
+ }
+ leaf connection-gos-profile {
+ type evc-gos-type;
+ }
+ leaf connection-additional-mac-allowed {
+ type uni-mac-limit-type;
+ }
+ leaf connection-emc-indicator {
+ type enumeration {
+ enum "Y"{
+ value 0;
+ }
+ enum "N"{
+ value 1;
+ }
+ }
+ }
+ leaf connection-emc-speed-value {
+ type uni-cir-value-type;
+ }
+ leaf connection-emc-speed-units-string {
+ type cir-rate-type;
+ }
+ }
+ leaf name-value-pair {
+ type string;
+ }
+ }
+ }
+}
diff --git a/sli/common/src/main/yang/ase.yang b/sli/common/src/main/yang/ase.yang
new file mode 100755
index 000000000..0b36a5610
--- /dev/null
+++ b/sli/common/src/main/yang/ase.yang
@@ -0,0 +1,558 @@
+module ase {
+
+ namespace "att:ase";
+ prefix ase;
+
+ import ase-type {prefix ase-type; revision-date "2014-06-09";}
+
+ organization "AT&T ASE";
+
+ description
+ "This submodule contains a collection of YANG definitions for
+ defining the ASE service model(s) for UNI and EVC";
+
+ revision 2014-03-27 {
+ description
+ "Additional detail for UNI and EVC API";
+ }
+ revision 2014-03-18 {
+ description
+ "Initial version";
+ }
+
+
+ /////////////////////////////////////////////////////
+ // ASE Query Actions
+ /////////////////////////////////////////////////////
+
+ ////
+ // Port Reserve Request
+ ////
+ rpc ase-port-reserve {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ leaf edge-device-clli {
+ description "Edge device (e.g. EMT) on which port "
+ + " reservation is needed";
+ type string;
+ mandatory true;
+ }
+ leaf uni-cir-value {
+ description "Integer value for the CIR";
+ type ase-type:uni-cir-value-type;
+ mandatory true;
+ }
+ leaf uni-cir-units {
+ description "Units for the CIR";
+ type ase-type:cir-rate-type;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ }
+ leaf uni-port-id {
+ description "Allocated UNI port id";
+ type string;
+ }
+
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Release Port Request
+ ////
+ rpc ase-release-port-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-return-hdr;
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Port Provisioning Request
+ ////
+ rpc ase-port-prov-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ leaf subscriber-name {
+ type string;
+ mandatory true;
+ }
+ leaf uni-order-number {
+ type string;
+ mandatory true;
+ }
+ leaf edge-device-clli {
+ description "Edge device (e.g. EMT) on which port "
+ + " reservation is needed";
+ type string;
+ mandatory true;
+ }
+ leaf uni-location-city {
+ type string;
+ mandatory true;
+ }
+ leaf uni-location-state {
+ type string;
+ mandatory true;
+ }
+ leaf media-type {
+ type ase-type:media-type;
+ mandatory true;
+ }
+ leaf media-speed {
+ type ase-type:media-speed-type;
+ mandatory true;
+ }
+ leaf uni-cir-value {
+ description "Integer value for the CIR";
+ type ase-type:uni-cir-value-type;
+ mandatory true;
+ }
+ leaf uni-cir-units {
+ description "Units for the CIR";
+ type ase-type:cir-rate-type;
+ mandatory true;
+ }
+ leaf cos-category {
+ description "CoS Type";
+ type ase-type:cos-category-type;
+ mandatory true;
+ }
+ leaf gos-profile {
+ description "GoS tpye";
+ type ase-type:uni-gos-type;
+ mandatory true;
+ }
+ leaf aditional-mac-allowed {
+ type ase-type:uni-mac-limit-type;
+ }
+ leaf port-tagging {
+ type ase-type:port-tagging-type;
+ mandatory true;
+ }
+ leaf name-value-pair {
+ type string;
+ }
+ }
+ output {
+ uses ase-type:uni-common-return-hdr;
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Deprovisioning Port Request
+ ////
+ rpc ase-deprov-port-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Change Port Provisioning Request
+ ////
+ rpc ase-change-port-prov-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ leaf subscriber-name {
+ type string;
+ }
+ leaf media-speed {
+ type ase-type:media-speed-type;
+ }
+ leaf uni-cir-value {
+ description "Integer value for the CIR";
+ type ase-type:uni-cir-value-type;
+ }
+ leaf uni-cir-units {
+ description "Units for the CIR";
+ type ase-type:cir-rate-type;
+ }
+ leaf cos-catagory {
+ type ase-type:cos-category-type;
+ }
+ leaf gos-profile {
+ type ase-type:uni-gos-type;
+ }
+ leaf additional-mac-allowed {
+ type ase-type:uni-mac-limit-type;
+ }
+ leaf port-tagging {
+ type ase-type:port-tagging-type;
+ mandatory true;
+ }
+ leaf name-value-pair {
+ type string;
+ }
+ }
+ output {
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Port Activate Request
+ ////
+ rpc ase-port-activate-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Port Change Activation Request
+ ////
+ rpc ase-change-port-activation-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ ////
+ // Port Disconnect Request
+ ////
+ rpc ase-port-disconnect-request {
+ input {
+ uses ase-type:uni-common-request-hdr;
+
+ leaf uni-circuit-id {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:uni-common-error-format;
+ }
+ }
+
+ /////////////////////////////////////////////////////
+ // EVC API
+ /////////////////////////////////////////////////////
+
+ ////
+ // EVC Provision Request
+ ////
+ rpc ase-evc-activation {
+ input {
+ uses ase-type:evc-common-request-hdr;
+ leaf topology {
+ type enumeration {
+ enum "MultiPoint"{
+ value 0;
+ }
+ enum "PointToPoint"{
+ value 1;
+ }
+ }
+ }
+ list evc-leg {
+ key evc-access-name;
+ leaf evc-access-name {
+ type string;
+ }
+ leaf subscriber-name {
+ type string;
+ }
+ leaf cvlan {
+ type uint16 {
+ range "2..4090";
+ }
+ }
+ leaf connection-cir-value {
+ type ase-type:uni-cir-value-type;
+ }
+ leaf connection-cir-units-string {
+ type ase-type:cir-rate-type;
+ }
+ leaf connection-gos-profile {
+ type ase-type:evc-gos-type;
+ }
+ leaf connection-additional-mac-allowed {
+ type ase-type:uni-mac-limit-type;
+ }
+ leaf connection-emc-indicator {
+ type enumeration {
+ enum "Y"{
+ value 0;
+ }
+ enum "N"{
+ value 1;
+ }
+ }
+ }
+ leaf connection-emc-speed-value {
+ type ase-type:uni-cir-value-type;
+ }
+ leaf connection-emc-speed-units-string {
+ type ase-type:cir-rate-type;
+ }
+ }
+ leaf name-value-pair {
+ type string;
+ }
+ }
+ output {
+ uses ase-type:evc-common-error-format;
+ }
+ }
+
+ ////
+ // EVC Change Activation Request
+ ////
+ rpc ase-evc-change-activation {
+ input {
+ uses ase-type:evc-common-request-hdr;
+ leaf topology {
+ type enumeration {
+ enum "MultiPoint"{
+ value 0;
+ }
+ enum "PointToPoint"{
+ value 1;
+ }
+ }
+ }
+ list evc-leg {
+ key evc-access-name;
+ leaf evc-access-name {
+ type string;
+ }
+ leaf connection-cir-value {
+ type ase-type:uni-cir-value-type;
+ }
+ leaf connection-cir-units-string {
+ type ase-type:cir-rate-type;
+ }
+ leaf connection-gos-profile {
+ type ase-type:evc-gos-type;
+ }
+ leaf connection-additional-mac-allowed {
+ type ase-type:uni-mac-limit-type;
+ }
+
+ }
+ leaf name-value-pair {
+ type string;
+ }
+
+ }
+ output {
+ uses ase-type:evc-common-error-format;
+ }
+ }
+
+ ////
+ // EVC Disconnet Connection Request
+ ////
+ rpc ase-evc-disconnect-request {
+ input {
+ uses ase-type:evc-common-request-hdr;
+ leaf topology {
+ type enumeration {
+ enum "MultiPoint"{
+ value 0;
+ }
+ enum "PointToPoint"{
+ value 1;
+ }
+ }
+ }
+ list evc-leg {
+ key evc-access-name;
+ leaf evc-access-name {
+ type string;
+ }
+ }
+ leaf name-value-pair {
+ type string;
+ }
+
+ }
+ output {
+ uses ase-type:evc-common-error-format;
+ }
+ }
+
+ /////////////////////////////////////////////////////
+ // ASE Query Actions
+ /////////////////////////////////////////////////////
+
+ rpc find-available-ports {
+ description "Return a count of available ports";
+ input {
+ uses ase-type:query-common-hdr;
+ leaf edge-device-clli {
+ type string;
+ mandatory true;
+ }
+
+ leaf port-role {
+ type enumeration {
+ enum "NETWORK"{
+ value 0;
+ }
+ enum "ACCESS"{
+ value 1;
+ }
+ enum "SDN-ACCESS"{
+ value 2;
+ }
+ }
+ mandatory true;
+ }
+ leaf port-assigned {
+ type string;
+ }
+ }
+ output {
+ uses ase-type:query-common-hdr;
+ container statuss {
+ leaf edge-device-clli {
+ type string;
+ }
+ container max-cir {
+ leaf cir-value {
+ type uint16;
+ }
+ leaf cir-type {
+ type ase-type:cir-rate-type;
+ }
+ }
+ leaf if-count {
+ type uint16;
+ }
+ }
+ uses ase-type:query-error-format;
+ }
+ }
+
+ rpc find-evcs-in-uni {
+ description "Return EVC instances for a specified UNI";
+ input {
+ uses ase-type:query-common-hdr;
+
+ leaf uni-circuit-id {
+ type string; //leafref
+ }
+ leaf edge-device-clli {
+ description "Edge device (e.g. EMT) on which port "
+ + " reservation is needed";
+ type string;
+ }
+ }
+ output {
+ uses ase-type:query-common-hdr;
+
+ leaf uni-leg-name {
+ description "NGO-proivded named";
+ type string;
+ }
+ uses ase-type:query-error-format;
+ }
+ }
+
+ rpc find-service-details {
+ description "Return EVC instances for a specified UNI";
+ input {
+ uses ase-type:query-common-hdr;
+ leaf uni-circuit-id {
+ type string; //leafref
+ }
+ leaf source {
+ type string;
+ mandatory true;
+ }
+ leaf service-name {
+ type string;
+ mandatory true;
+ }
+ leaf service-type {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ uses ase-type:query-common-hdr;
+
+ leaf service-name {
+ type string;
+ mandatory true;
+ }
+ leaf service-type {
+ type string;
+ mandatory true;
+ }
+ leaf service-state {
+ type enumeration {
+ enum "Active"{
+ value 0;
+ }
+ enum "NotActive"{
+ value 1;
+ }
+ }
+ }
+ leaf has-pending-change {
+ type ase-type:ase-yes-no-type;
+ }
+ leaf allowed-connection-count {
+ type int16;
+ }
+ uses ase-type:query-error-format;
+ }
+ }
+} //module
diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java
new file mode 100644
index 000000000..6e6656e89
--- /dev/null
+++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
+
+public class SvcLogicContextTest extends TestCase {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicContext.class);
+
+ public void testMerge() {
+
+ try {
+ InputStream testStr = getClass().getResourceAsStream("/mergetest.xml");
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ Document theDocument = db.parse(testStr);
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.mergeDocument("test-merge", theDocument);
+ Properties props = ctx.toProperties();
+ LOG.info("SvcLogicContext contains the following : ");
+ for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) {
+ String propName = (String) e.nextElement();
+ LOG.info(propName+" = "+props.getProperty(propName));
+
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception trying to merge", e);
+ fail("Caught exception trying to merge");
+ }
+
+ }
+
+}
diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java
new file mode 100644
index 000000000..d6503b60c
--- /dev/null
+++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.sli;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.openecomp.sdnc.sli.SvcLogicExprListener;
+import org.openecomp.sdnc.sli.SvcLogicExpression;
+import org.openecomp.sdnc.sli.SvcLogicExpressionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import junit.framework.TestCase;
+
+public class SvcLogicExpressionParserTest extends TestCase {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicExprListener.class);
+
+ public void testParse() {
+ try
+ {
+ InputStream testStr = getClass().getResourceAsStream("/expression.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+
+ String testExpr = null;
+ while ((testExpr = testsReader.readLine()) != null) {
+
+ SvcLogicExpression parsedExpr = SvcLogicExpressionFactory.parse(testExpr);
+ if (parsedExpr == null)
+ {
+ fail("parse("+testExpr+") returned null");
+ }
+ else
+ {
+ LOG.info("test expression = ["+testExpr+"] ; parsed expression = ["+parsedExpr.asParsedExpr()+"]");
+
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Caught exception processing test cases");
+ }
+ }
+
+}
diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java
new file mode 100644
index 000000000..e8ff2feeb
--- /dev/null
+++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ *
+ */
+package org.openecomp.sdnc.sli;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.LinkedList;
+
+import org.openecomp.sdnc.sli.SvcLogicParser;
+import org.openecomp.sdnc.sli.SvcLogicParserException;
+import org.openecomp.sdnc.sli.SvcLogicStore;
+import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @author dt5972
+ *
+ */
+public class SvcLogicParserTest extends TestCase {
+
+ /**
+ * Test method for {@link org.openecomp.sdnc.sli.SvcLogicParser#parse(java.lang.String)}.
+ */
+
+
+ public void testParse() {
+
+
+ try
+ {
+
+ URL propUrl = getClass().getResource("/svclogic.properties");
+
+ InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr);
+
+ assertNotNull(store);
+
+ store.registerNodeType("switch");
+ store.registerNodeType("block");
+ store.registerNodeType("get-resource");
+ store.registerNodeType("reserve");
+ store.registerNodeType("is-available");
+ store.registerNodeType("exists");
+ store.registerNodeType("configure");
+ store.registerNodeType("return");
+ store.registerNodeType("record");
+ store.registerNodeType("allocate");
+ store.registerNodeType("release");
+ store.registerNodeType("for");
+ store.registerNodeType("set");
+
+
+ InputStream testStr = getClass().getResourceAsStream("/parser-good.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+ String testCaseFile = null;
+ while ((testCaseFile = testsReader.readLine()) != null) {
+
+ testCaseFile = testCaseFile.trim();
+
+ if (testCaseFile.length() > 0)
+ {
+ if (!testCaseFile.startsWith("/"))
+ {
+ testCaseFile = "/"+testCaseFile;
+ }
+ URL testCaseUrl = getClass().getResource(testCaseFile);
+ if (testCaseUrl == null)
+ {
+ fail("Could not resolve test case file "+testCaseFile);
+ }
+
+ try {
+ SvcLogicParser.validate(testCaseUrl.getPath(), store);
+ } catch (Exception e) {
+ fail("Validation failure ["+e.getMessage()+"]");
+
+ }
+
+
+
+
+
+ }
+ }
+
+ testStr = getClass().getResourceAsStream("/parser-bad.tests");
+ testsReader = new BufferedReader(new InputStreamReader(testStr));
+ testCaseFile = null;
+ while ((testCaseFile = testsReader.readLine()) != null) {
+
+ testCaseFile = testCaseFile.trim();
+
+ if (testCaseFile.length() > 0)
+ {
+ if (!testCaseFile.startsWith("/"))
+ {
+ testCaseFile = "/"+testCaseFile;
+ }
+ URL testCaseUrl = getClass().getResource(testCaseFile);
+ if (testCaseUrl == null)
+ {
+ fail("Could not resolve test case file "+testCaseFile);
+ }
+
+ boolean valid = true;
+ try {
+ SvcLogicParser.load(testCaseUrl.getPath(), store);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ valid = false;
+ }
+
+ if (valid) {
+ fail("Expected compiler error on "+testCaseFile+", but got success");
+ }
+
+
+ }
+ }
+ }
+ catch (SvcLogicParserException e)
+ {
+ fail("Parser error : "+e.getMessage());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Caught exception processing test cases");
+ }
+
+
+ }
+
+
+
+}
diff --git a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml
new file mode 100644
index 000000000..097078a8a
--- /dev/null
+++ b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<service-logic xmlns="http://www.openecomp.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openecomp.org/sdnc/svclogic ./svclogic.xsd"
+ module="ase" version="1.0.0">
+
+
+ <method rpc="ase-evc-activation" mode="sync">
+ <configure adaptor="org.openecomp.sdnc.sli.adaptor.emt.EmtAdaptor"
+ key="$evc-name" activate="true">
+ <parameter name="circuit.name" value="$evc-name" />
+ <parameter name="topology" value="$topology" />
+ <parameter name="leg1.uniCircuitId" value="$evc-leg[0].evc-access-name" />
+ <parameter name="leg2.uniCircuitId" value="$evc-leg[1].evc-access-name" />
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+ <outcome value="already-active">
+ <return status="failure">
+ <parameter name="error-code" value="1590" />
+ <parameter name="error-message" value="`Circuit already active`" />
+ </return>
+ </outcome>
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1542" />
+ <parameter name="error-message" value="Activation failure" />
+ </return>
+ </outcome>
+ </configure>
+ </method>
+
+ <method rpc="ase-evc-disconnect-request" mode="sync">
+ <configure adaptor="org.openecomp.sdnc.sli.adaptor.emt.EmtAdaptor"
+ key="$evc-name" activate="false">
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1542" />
+ <parameter name="error-message" value="De-activation failure" />
+ </return>
+ </outcome>
+ </configure>
+ </method>
+
+
+</service-logic>
diff --git a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml
new file mode 100644
index 000000000..080844205
--- /dev/null
+++ b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml
@@ -0,0 +1,263 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<service-logic xmlns="http://www.openecomp.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openecomp.org/sdnc/svclogic ./svclogic.xsd"
+ module="ase" version="1.0.0">
+
+ <!-- Reserve a port. Returns uni-circuit-id of reserved ase-port -->
+ <method rpc="ase-port-reserve" mode="sync">
+ <switch test="$uni-cir-units">
+ <outcome value="Mbps">
+ <reserve plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port"
+ key="resource-emt-clli == $edge-device-clli and speed >= $uni-cir-value"
+ pfx="asePort">
+
+
+ <outcome value="success">
+ <block>
+ <record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
+ <parameter name="file" value="/tmp/sample_r1.log" />
+ <parameter name="field1" value="__TIMESTAMP__"/>
+ <parameter name="field2" value="RESERVED"/>
+ <parameter name="field3" value="$asePort.uni_circuit_id"/>
+ </record>
+ <return status="success">
+ <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" />
+ </return>
+ </block>
+
+ </outcome>
+
+ <outcome value="not-found">
+ <return status="failure">
+ <parameter name="error-code" value="1010" />
+ <parameter name="error-message" value="No ports found that match criteria" />
+ </return>
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1010" />
+ <parameter name="error-message"
+ value="Error encountered trying to reserve port" />
+ </return>
+ </outcome>
+
+ </reserve>
+ </outcome>
+ <outcome value="Gbps">
+ <reserve plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port"
+ key="resource-emt-clli == $edge-device-clli and speed >= 1000 * $uni-cir-value"
+ pfx="asePort">
+
+
+ <outcome value="success">
+ <block>
+ <record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
+ <parameter name="file" value="/tmp/sample_r1.log" />
+ <parameter name="field1" value="__TIMESTAMP__"/>
+ <parameter name="field2" value="RESERVED"/>
+ <parameter name="field3" value="$asePort.uni_circuit_id"/>
+ </record>
+ <return status="success">
+ <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" />
+ </return>
+ </block>
+ </outcome>
+
+ <outcome value="not-found">
+ <return status="failure">
+ <parameter name="error-code" value="1010" />
+ <parameter name="error-message" value="No ports found that match criteria" />
+ </return>
+ </outcome>
+ <outcome value="">
+ <return status="failure">
+ <parameter name="error-code" value="1012" />
+ <parameter name="error-message"
+ value="Error encountered trying to reserve port" />
+ </return>
+ </outcome>
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1010" />
+ <parameter name="error-message"
+ value="Error encountered trying to reserve port" />
+ </return>
+ </outcome>
+ </reserve>
+ </outcome>
+ </switch>
+ </method>
+
+ <!-- One step provisioning/activation command. Allocates a local resource,
+ then configures it on device -->
+ <method rpc="ase-port-activate-request" mode="sync">
+
+ <allocate plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port" key="uni-circuit-id == $uni-circuit-id" pfx="asePort">
+
+ <outcome value="success">
+ <configure adaptor="org.openecomp.sdnc.sli.adaptor.emt.EmtAdaptor"
+ key="$uni-circuit-id" activate="true">
+ <parameter name="circuit.id" value="$uni-circuit-id" />
+ <parameter name="subscriber.name" value="$subscriber-name" />
+ <parameter name="emt.clli" value="$edge-device-clli" />
+ <parameter name="port.tagging" value="$port-tagging" />
+ <parameter name="port.mediaSpeed" value="$media-speed" />
+ <parameter name="location.state" value="$uni-location-state" />
+ <parameter name="location.city" value="$uni-location-city" />
+ <parameter name="cosCategory" value="$cos-category" />
+ <parameter name="gosProfile" value="$gos-profile" />
+ <parameter name="lldp" value="$asePort.resource-lldp" />
+ <parameter name="mtu" value="$asePort.resource-mtu" />
+ <outcome value="success">
+ <block>
+ <record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
+ <parameter name="file" value="/tmp/sample_r1.log" />
+ <parameter name="field1" value="__TIMESTAMP__"/>
+ <parameter name="field2" value="ACTIVE"/>
+ <parameter name="field3" value="$uni-circuit-id"/>
+ </record>
+ <return status="success">
+ <parameter name="edge-device-clli" value="$asePort.resource-emt-clli" />
+ </return>
+ </block>
+
+ </outcome>
+ <outcome value="already-active">
+ <return status="failure">
+ <parameter name="error-code" value="1590" />
+ <parameter name="error-message" value="Port already active" />
+ </return>
+ </outcome>
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1542" />
+ <parameter name="error-message" value="Activation failure" />
+ </return>
+ </outcome>
+ </configure>
+ </outcome>
+
+ <outcome value="not-found">
+
+ <return status="failure">
+ <parameter name="error-code" value="1220" />
+ <parameter name="error-message" value="Circuit not found" />
+ </return>
+
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1230" />
+ <parameter name="error-message" value="Error occurred trying to find circuit" />
+ </return>
+ </outcome>
+ </allocate>
+ </method>
+
+
+
+ <!-- Change provisioning w/o activation -->
+ <method rpc="ase-change-port-prov-request" mode="sync">
+ <allocate plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port" key="uni-circuit-id == $uni-circuit-id" pfx="asePort">
+
+ <outcome value="success">
+ <return status="success">
+ <parameter name="edge-device-clli" value="$asePort.resource-emt-clli" />
+ </return>
+ </outcome>
+
+ <outcome value="not-found">
+ <return status="failure">
+ <parameter name="error-code" value="1220" />
+ <parameter name="error-message" value="Circuit not found" />
+ </return>
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1230" />
+ <parameter name="error-message" value="Error occurred trying to find circuit" />
+ </return>
+ </outcome>
+ </allocate>
+ </method>
+
+
+
+
+ <!-- Release port -->
+
+ <method rpc="ase-release-port-request" mode="sync">
+ <exists plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-evc" key="uni-circuit-id == $uni-circuit-id">
+
+ <outcome value="true">
+ <return status="failure">
+ <parameter name="error-code" value="1130" />
+ <parameter name="error-message"
+ value="Cannot release port - used in existing EVC" />
+ </return>
+ </outcome>
+ <outcome value="false">
+ <release plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port" key="uni-circuit-id == $uni-circuit-id">
+ <outcome value="success">
+ <block>
+ <record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
+ <parameter name="file" value="/tmp/sample_r1.log" />
+ <parameter name="field1" value="__TIMESTAMP__"/>
+ <parameter name="field2" value="RELEASED"/>
+ <parameter name="field3" value="$uni-circuit-id"/>
+ </record>
+ <return status="success"/>
+ </block>
+ </outcome>
+
+ <outcome value="not-found">
+ <return status="failure">
+ <parameter name="error-code" value="1110" />
+ <parameter name="error-message" value="No port found for this uni-circuit-id" />
+ </return>
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1130" />
+ <parameter name="error-message"
+ value="Error encountered trying to release port" />
+ </return>
+ </outcome>
+ </release>
+ </outcome>
+ </exists>
+ </method>
+
+</service-logic>
+
diff --git a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml
new file mode 100644
index 000000000..5a835b7be
--- /dev/null
+++ b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<service-logic xmlns="http://www.openecomp.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openecomp.org/sdnc/svclogic ./svclogic.xsd"
+ module="ase" version="1.0.1">
+
+ <!-- Updated release port logic : deactivate the released port on the EMT -->
+ <method rpc="ase-release-port-request" mode="sync">
+ <exists plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-evc" key="uni-circuit-id == $uni-circuit-id">
+
+ <outcome value="true">
+ <return status="failure">
+ <parameter name="error-code" value="1130" />
+ <parameter name="error-message"
+ value="Cannot release port - used in existing EVC" />
+ </return>
+ </outcome>
+ <outcome value="false">
+ <release plugin="org.openecomp.sdnc.sli.resource.sample.SampleResource"
+ resource="ase-port" key="uni-circuit-id == $uni-circuit-id">
+ <outcome value="success">
+ <configure adaptor="org.openecomp.sdnc.sli.adaptor.emt.EmtAdaptor"
+ key="$uni-circuit-id" activate="false">
+
+ <outcome value="success">
+ <block>
+ <record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
+ <parameter name="file" value="/tmp/sample_r1.log" />
+ <parameter name="field1" value="__TIMESTAMP__" />
+ <parameter name="field2" value="RELEASED" />
+ <parameter name="field3" value="$uni-circuit-id" />
+ </record>
+ <return status="success">
+ <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" />
+ </return>
+ </block>
+ </outcome>
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1130" />
+ <parameter name="error-message"
+ value="Error encountered trying to de-activate port" />
+ </return>
+ </outcome>
+ </configure>
+ </outcome>
+
+ <outcome value="not-found">
+ <return status="failure">
+ <parameter name="error-code" value="1110" />
+ <parameter name="error-message" value="No port found for this uni-circuit-id" />
+ </return>
+ </outcome>
+
+ <outcome value="Other">
+ <return status="failure">
+ <parameter name="error-code" value="1130" />
+ <parameter name="error-message"
+ value="Error encountered trying to release port" />
+ </return>
+ </outcome>
+ </release>
+ </outcome>
+ </exists>
+ </method>
+
+</service-logic>
+
diff --git a/sli/common/src/test/resources/bad_neutron_logic_v11.xml b/sli/common/src/test/resources/bad_neutron_logic_v11.xml
new file mode 100644
index 000000000..4e1e8d9b4
--- /dev/null
+++ b/sli/common/src/test/resources/bad_neutron_logic_v11.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<service-logic xmlns="http://www.openecomp.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openecomp.org/sdnc/svclogic ./svclogic.xsd"
+ module="neutron" version="1.0.0">
+
+ <method rpc="canCreateNetwork" mode="sync">
+ <switch test="true">
+ <return status="success">
+ <parameter name="error-code" value="200" />
+ </return>
+ </switch>
+ </method>
+
+ <method rpc="networkCreated" mode="sync">
+ <switch test="`(length($network.segment[0].provider-physical-network) >= 5) and (substr($network.segment[0].provider-physical-network,0,5) == 'dvspg')`">
+ <outcome value="true">
+ <block>
+ <set>
+ <parameter name="vlanlist" value="`$network.segment[0].provider-segmentation-id`"/>
+ </set>
+ <for index="i" start="1" end="`$network.num-segments`">
+ <set>
+ <parameter name="vlanlist" value="`$vlanlist+','+$network.segment[$i].provider-segmentation-id`"/>
+ </set>
+ </for>
+
+ <switch test="true">
+ <return status="success"/>
+ </switch>
+ </block>
+ </outcome>
+ <outcome value="Other">
+ <return status="success">
+ <parameter name="error-code" value="200"/>
+ </return>
+ </outcome>
+ </switch>
+ </method>
+
+</service-logic>
diff --git a/sli/common/src/test/resources/expression.tests b/sli/common/src/test/resources/expression.tests
new file mode 100755
index 000000000..c352e9b08
--- /dev/null
+++ b/sli/common/src/test/resources/expression.tests
@@ -0,0 +1,19 @@
+$uni-circuit-id
+$asePort
+length($uni-circuit-id) > 0
+$asePort.uni-circuit-id
+$uni-cir-units * 1000 * 100 / 100
+$uni-cir-units / 1000
+$uni-cir-units - 100
+$uni-cir-units + 100
+(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0)
+'pg-'+$network.name
+$network.segment[0].provider-physical-network
+length($network_segment[0].provider-physical-network) >= 5
+substr($network_segment[0].provider-physical-network,0,5) == 'dvspg'
+length($network_segment[0].provider-physical-network) >= 5 and substr($network_segment[0].provider-physical-network,0,5) == 'dvspg'
+(length($network_segment[0].provider-physical-network) >= 5) and (substr($network_segment[0].provider-physical-network,0,5) == 'dvspg')
+4-2-2
+1+1
+1
+1+2*3-4
diff --git a/sli/common/src/test/resources/mergetest.xml b/sli/common/src/test/resources/mergetest.xml
new file mode 100644
index 000000000..12e083c79
--- /dev/null
+++ b/sli/common/src/test/resources/mergetest.xml
@@ -0,0 +1,54 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<multicast-parameters xmlns="org.openecomp.sdnc:test">
+ <vpn-v4-multicast-enabled>Y</vpn-v4-multicast-enabled>
+ <v4-multicast>
+ <v4-pim-ssm-default-range>Y</v4-pim-ssm-default-range>
+ <v4-data-mdt>11.11.11.11</v4-data-mdt>
+ <v4-data-mdt-wildcard-mask>2.2.2.2</v4-data-mdt-wildcard-mask>
+ <max-routes-limit>100</max-routes-limit>
+ <v4-default-mdt>1.1.1.1</v4-default-mdt>
+ <v4-pim-sm-static-override>N</v4-pim-sm-static-override>
+ <v4-pim-ssm-groups>
+ <v4-pim-ssm-group-address>4.4.4.4</v4-pim-ssm-group-address>
+ </v4-pim-ssm-groups>
+ <v4-pim-ssm-groups>
+ <v4-pim-ssm-group-address>3.3.3.3</v4-pim-ssm-group-address>
+ </v4-pim-ssm-groups>
+ <v4-static-rp-triplet>
+ <rp-address>8.8.8.8</rp-address>
+ <c-groups>
+ <c-group-address-prefix>10.10.10.10</c-group-address-prefix>
+ </c-groups>
+ <c-groups>
+ <c-group-address-prefix>9.9.9.9</c-group-address-prefix>
+ </c-groups>
+ </v4-static-rp-triplet>
+ <v4-static-rp-triplet>
+ <rp-address>7.7.7.7</rp-address>
+ <c-groups>
+ <c-group-address-prefix>6.6.6.6</c-group-address-prefix>
+ </c-groups>
+ <c-groups>
+ <c-group-address-prefix>5.5.5.5</c-group-address-prefix>
+ </c-groups>
+ </v4-static-rp-triplet>
+ </v4-multicast>
+</multicast-parameters>
diff --git a/sli/common/src/test/resources/neutron_logic_v10.xml b/sli/common/src/test/resources/neutron_logic_v10.xml
new file mode 100644
index 000000000..9cd331279
--- /dev/null
+++ b/sli/common/src/test/resources/neutron_logic_v10.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<service-logic xmlns="http://www.openecomp.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.openecomp.org/sdnc/svclogic ./svclogic.xsd"
+ module="neutron" version="1.0.0">
+
+ <method rpc="canCreateNetwork" mode="sync">
+ <return status="success">
+ <parameter name="error-code" value="200" />
+ </return>
+ </method>
+
+ <method rpc="networkCreated" mode="sync">
+ <switch test="`(length($network.segment[0].provider-physical-network) >= 5) and (substr($network.segment[0].provider-physical-network,0,5) == 'dvspg')`">
+ <outcome value="true">
+ <block>
+ <set>
+ <parameter name="vlanlist" value="`$network.segment[0].provider-segmentation-id`"/>
+ </set>
+ <for index="i" start="1" end="`$network.num-segments`">
+ <set>
+ <parameter name="vlanlist" value="`$vlanlist+','+$network.segment[$i].provider-segmentation-id`"/>
+ </set>
+ </for>
+
+ </block>
+ </outcome>
+ <outcome value="Other">
+ <return status="success">
+ <parameter name="error-code" value="200"/>
+ </return>
+ </outcome>
+ </switch>
+ </method>
+
+</service-logic>
diff --git a/sli/common/src/test/resources/nonsense.xml b/sli/common/src/test/resources/nonsense.xml
new file mode 100644
index 000000000..61220825e
--- /dev/null
+++ b/sli/common/src/test/resources/nonsense.xml
@@ -0,0 +1,24 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<non>
+<sense>Hello world</sense>
+</non>
diff --git a/sli/common/src/test/resources/parser-bad.tests b/sli/common/src/test/resources/parser-bad.tests
new file mode 100755
index 000000000..82913afc2
--- /dev/null
+++ b/sli/common/src/test/resources/parser-bad.tests
@@ -0,0 +1,3 @@
+bad_neutron_logic_v11.xml
+EvcActivateSvcLogic_v100.xml
+nonsense.xml \ No newline at end of file
diff --git a/sli/common/src/test/resources/parser-good.tests b/sli/common/src/test/resources/parser-good.tests
new file mode 100755
index 000000000..06543126f
--- /dev/null
+++ b/sli/common/src/test/resources/parser-good.tests
@@ -0,0 +1,2 @@
+ReleasePortSvcLogic_v101.xml
+neutron_logic_v10.xml
diff --git a/sli/common/src/test/resources/simplelogger.properties b/sli/common/src/test/resources/simplelogger.properties
new file mode 100644
index 000000000..6f70984c9
--- /dev/null
+++ b/sli/common/src/test/resources/simplelogger.properties
@@ -0,0 +1,24 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+org.slf4j.simpleLogger.defaultLogLevel=info
+org.slf4j.simplelogger.log.org.openecomp.sdnc.sli.SvcLogicContext=debug
+org.slf4j.simplelogger.log.SvcLogicContext=debug
diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties
new file mode 100644
index 000000000..fa33146e5
--- /dev/null
+++ b/sli/common/src/test/resources/svclogic.properties
@@ -0,0 +1,26 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+org.openecomp.sdnc.sli.dbtype = jdbc
+org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl
+org.openecomp.sdnc.sli.jdbc.database = sdnctl
+org.openecomp.sdnc.sli.jdbc.user = sdnctl
+org.openecomp.sdnc.sli.jdbc.password = gamma
diff --git a/sli/common/src/test/resources/svclogic.sh b/sli/common/src/test/resources/svclogic.sh
new file mode 100644
index 000000000..09f0637d5
--- /dev/null
+++ b/sli/common/src/test/resources/svclogic.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+MYSQL_JDBC_DRIVER=${MYSQL_JDBC_DRIVER:-/home/ubuntu/mysql-connector-java-5.1.38.1.jar}
+SLI_COMMON_TARGETDIR=${SLI_COMMON_TARGETDIR:-/home/ubuntu/opendaylight/plugins}
+#SLI_COMMON_TARGETDIR=${SLI_COMMON_TARGETDIR:-/home/ubuntu/git/sdnctl/sli/common/target}
+SLI_VERSION=${SLI_VERSION:-1.1.0-SNAPSHOT}
+SLI_COMMON_JAR=${SLI_COMMON_JAR:=${SLI_COMMON_TARGETDIR}/sli-common-${SLI_VERSION}.jar}
+
+echo SLI_COMMON_JAR is $SLI_COMMON_JAR
+
+java -cp ${CLASSPATH}:${MYSQL_JDBC_DRIVER}:${SLI_COMMON_JAR} org.openecomp.sdnc.sli.SvcLogicParser $*
diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd
new file mode 100755
index 000000000..074308915
--- /dev/null
+++ b/sli/common/src/test/resources/svclogic.xsd
@@ -0,0 +1,323 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.openecomp.org/sdnc/svclogic" xmlns="http://www.openecomp.org/sdnc/svclogic">
+
+ <xsd:simpleType name="modeType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="sync" />
+ <xsd:enumeration value="async" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:group name="node">
+ <xsd:choice>
+ <xsd:element ref="block" />
+ <xsd:element ref="is-available" />
+ <xsd:element ref="exists" />
+ <xsd:element ref="reserve" />
+ <xsd:element ref="release" />
+ <xsd:element ref="allocate" />
+ <xsd:element ref="get-resource" />
+ <xsd:element ref="configure" />
+ <xsd:element ref="return" />
+ <xsd:element ref="switch" />
+ <xsd:element ref="record" />
+ <xsd:element ref="save" />
+ <xsd:element ref="for" />
+ <xsd:element ref="set" />
+ <xsd:element ref="execute" />
+ <xsd:element ref="delete" />
+ <xsd:element ref="update" />
+ <xsd:element ref="call" />
+ <xsd:element ref="notify" />
+ <xsd:element ref="break" />
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:element name="service-logic">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="method" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="module" use="required" type="xsd:string" />
+ <xsd:attribute name="version" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="method">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="rpc" use="required" type="xsd:string" />
+ <xsd:attribute name="mode" use="optional" type="modeType" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="block">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="atomic" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="is-available">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="exists">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="outcome">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string" />
+ <xsd:attribute name="value" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="reserve">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="select" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="release">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="record">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="allocate">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ <xsd:attribute name="pfx" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="get-resource">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="order-by" use="optional" type="xsd:string" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configure">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="adaptor" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="required" type="xsd:string" />
+ <xsd:attribute name="activate" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="parameter">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="value" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="return">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="status" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="switch">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="test" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="save">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="force" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="delete">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ <!-- local-only is retired and does not do anything -->
+ <xsd:attribute name="local-only" use="optional" type="xsd:string" />
+ <!-- pfx is retired and does not do anything -->
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="for">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="atomic" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="index" use="required" type="xsd:string" />
+ <xsd:attribute name="start" use="required" type="xsd:string" />
+ <xsd:attribute name="end" use="required" type="xsd:string" />
+ <xsd:attribute name="silentFailure" use="optional" type="xsd:boolean" default="false" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="only-if-unset" use="optional"
+ type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="execute">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="method" use="required" type="xsd:string" />
+ <xsd:attribute name="emitsOutcome" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="update">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="required" type="xsd:string" />
+ <xsd:attribute name="resource" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <xsd:attribute name="force" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="local-only" use="optional" type="xsd:boolean" />
+ <xsd:attribute name="pfx" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="call">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- This node does not actually read from parameters -->
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="module" use="optional" type="xsd:string" />
+ <xsd:attribute name="rpc" use="required" type="xsd:string" />
+ <xsd:attribute name="version" use="optional" type="xsd:string" />
+ <xsd:attribute name="mode" use="required" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="notify">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="outcome" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="plugin" use="optional" type="xsd:string" />
+ <xsd:attribute name="resource" use="optional" type="xsd:string" />
+ <xsd:attribute name="action" use="required" type="xsd:string" />
+ <xsd:attribute name="key" use="optional" type="xsd:string" />
+ <!-- force is retired and does not do anything -->
+ <xsd:attribute name="force" use="optional" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="break">
+ <xsd:complexType />
+ </xsd:element>
+
+</xsd:schema>