summaryrefslogtreecommitdiffstats
path: root/sshapi-call-node/provider
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-19 11:17:06 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-19 15:14:19 +0900
commitd6a56cd8f71cc196083c6ab16e86d24c7c89f9ef (patch)
tree6f1a7f481d0f4cecbc658c43260c1a56c35c79e8 /sshapi-call-node/provider
parent6603a6b208f454e87215047a3116ca6d40cc56c2 (diff)
SSHApiCallNode API definition
Issue-ID: CCSDK-384 Change-Id: I558bb774081074fbd1c541512d767a9ca5d1f866 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'sshapi-call-node/provider')
-rwxr-xr-xsshapi-call-node/provider/pom.xml73
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java84
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java19
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java39
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java42
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java43
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java96
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java32
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java62
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java56
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java389
-rw-r--r--sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java174
-rw-r--r--sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml51
-rw-r--r--sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml34
-rwxr-xr-xsshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml16
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java75
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java264
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java123
-rw-r--r--sshapi-call-node/provider/src/test/resources/invalidlength.xml49
-rw-r--r--sshapi-call-node/provider/src/test/resources/test-template.json57
-rw-r--r--sshapi-call-node/provider/src/test/resources/test.json51
-rw-r--r--sshapi-call-node/provider/src/test/resources/test.xml184
-rw-r--r--sshapi-call-node/provider/src/test/resources/test3.xml82
23 files changed, 2095 insertions, 0 deletions
diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml
new file mode 100755
index 00000000..165003ff
--- /dev/null
+++ b/sshapi-call-node/provider/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.plugins</groupId>
+ <artifactId>sshapi-call-node-provider</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId}</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-signature</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-client</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java
new file mode 100644
index 00000000..4efddec8
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.onap.ccsdk.sli.plugins.sshapicall;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import java.io.OutputStream;
+import java.util.Map;
+
+public interface SshApiCallNode extends SvcLogicJavaPlugin {
+
+ /**
+ * Allows Directed Graphs the ability to interact with SSH APIs.
+ * @param paramMap HashMap<String,String> of parameters passed by the DG to this function
+ * <table border="1">
+ * <thead><th>parameter</th><th>Mandatory/Optional</th><th>description</th><th>example values</th></thead>
+ * <tbody>
+ * <tr><td>templateFileName</td><td>Optional</td><td>full path to template file that can be used to build a request</td><td>/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json</td></tr>
+ * <tr><td>sshapiUrl</td><td>Mandatory</td><td>url to make the SSH connection request to.</td></tr>
+ * <tr><td>sshapiUser</td><td>Optional</td><td>user name to use for ssh basic authentication</td><td>sdnc_ws</td></tr>
+ * <tr><td>sshapiPassword</td><td>Optional</td><td>unencrypted password to use for ssh basic authentication</td><td>plain_password</td></tr>
+ * <tr><td>sshKey</td><td>Optional</td><td>Consumer SSH key to use for ssh authentication</td><td>plain_key</td></tr>
+ * <tr><td>cmd</td><td>Mandatory</td><td>ssh command to be executed on the server.</td><td>get post put delete patch</td></tr>
+ * <tr><td>responsePrefix</td><td>Optional</td><td>location the response will be written to in context memory</td><td>tmp.sshapi.result</td></tr>
+ * <tr><td>listName[i]</td><td>Optional</td><td>Used for processing XML responses with repeating elements.</td>vpn-information.vrf-details<td></td></tr>
+ * <tr><td>convertResponse </td><td>Optional</td><td>whether the response should be converted</td><td>true or false</td></tr>
+ * <tr><td>dumpHeaders</td><td>Optional</td><td>when true writes ssh response content to context memory</td><td>true or false</td></tr>
+ * <tr><td>returnRequestPayload</td><td>Optional</td><td>used to return payload built in the request</td><td>true or false</td></tr>
+ * </tbody>
+ * </table>
+ * Exec remote command over SSH. Return command execution status.
+ * Command output is written to out or err stream.
+ *
+ * @param ctx Reference to context memory
+ */
+ void execCommand(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException;
+
+ /**
+ * Allows Directed Graphs the ability to interact with SSH APIs.
+ * @param paramMap HashMap<String,String> of parameters passed by the DG to this function
+ * <table border="1">
+ * <thead><th>parameter</th><th>Mandatory/Optional</th><th>description</th><th>example values</th></thead>
+ * <tbody>
+ * <tr><td>templateFileName</td><td>Optional</td><td>full path to template file that can be used to build a request</td><td>/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json</td></tr>
+ * <tr><td>sshapiUrl</td><td>Mandatory</td><td>url to make the SSH connection request to.</td></tr>
+ * <tr><td>sshapiUser</td><td>Optional</td><td>user name to use for ssh basic authentication</td><td>sdnc_ws</td></tr>
+ * <tr><td>sshapiPassword</td><td>Optional</td><td>unencrypted password to use for ssh basic authentication</td><td>plain_password</td></tr>
+ * <tr><td>sshKey</td><td>Optional</td><td>Consumer SSH key to use for ssh authentication</td><td>plain_key</td></tr>
+ * <tr><td>cmd</td><td>Mandatory</td><td>ssh command to be executed on the server.</td><td>get post put delete patch</td></tr>
+ * <tr><td>responsePrefix</td><td>Optional</td><td>location the response will be written to in context memory</td><td>tmp.sshapi.result</td></tr>
+ * <tr><td>listName[i]</td><td>Optional</td><td>Used for processing XML responses with repeating elements.</td>vpn-information.vrf-details<td></td></tr>
+ * <tr><td>convertResponse </td><td>Optional</td><td>whether the response should be converted</td><td>true or false</td></tr>
+ * <tr><td>dumpHeaders</td><td>Optional</td><td>when true writes ssh response content to context memory</td><td>true or false</td></tr>
+ * <tr><td>returnRequestPayload</td><td>Optional</td><td>used to return payload built in the request</td><td>true or false</td></tr>
+ * </tbody>
+ * </table>
+ * Exec remote command over SSH with pseudo-tty. Return command execution status.
+ * Command output is written to out stream only as pseudo-tty writes to one stream only.
+ *
+ * @param ctx Reference to context memory
+ */
+ void execCommandWithPty(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException ;
+
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java
new file mode 100644
index 00000000..30816227
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java
@@ -0,0 +1,19 @@
+package org.onap.ccsdk.sli.plugins.sshapicall.impl;
+
+public enum AuthType {
+ NONE, BASIC, DIGEST, OAUTH, Unspecified;
+
+ public static AuthType fromString(String s) {
+ if ("basic".equalsIgnoreCase(s))
+ return BASIC;
+ if ("digest".equalsIgnoreCase(s))
+ return DIGEST;
+ if ("oauth".equalsIgnoreCase(s))
+ return OAUTH;
+ if ("none".equalsIgnoreCase(s))
+ return NONE;
+ if ("unspecified".equalsIgnoreCase(s))
+ return Unspecified;
+ throw new IllegalArgumentException("Invalid value for format: " + s);
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java
new file mode 100644
index 00000000..75604de6
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.impl;
+
+public enum Format {
+ JSON, XML, NONE;
+
+ public static Format fromString(String s) {
+ if ("json".equalsIgnoreCase(s))
+ return JSON;
+ if ("xml".equalsIgnoreCase(s))
+ return XML;
+ if ("none".equalsIgnoreCase(s))
+ return NONE;
+ throw new IllegalArgumentException("Invalid value for format: " + s);
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java
new file mode 100644
index 00000000..a392cc73
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.impl;
+
+import java.util.Set;
+
+public class Parameters {
+ public String templateFileName;
+ public String sshapiUrl;
+ public String sshapiUser;
+ public String sshapiPassword;
+ public Format sshKey;
+ public String cmd;
+ public String responsePrefix;
+ public Set<String> listNameList;
+ public boolean convertResponse;
+ public Boolean dumpHeaders;
+ public String requestBody;
+ public AuthType authtype;
+ public Boolean returnRequestPayload;
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java
new file mode 100644
index 00000000..9283b8b5
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.impl;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode;
+
+import java.io.OutputStream;
+import java.util.Map;
+
+public class SshapiCallNodeImpl implements SshApiCallNode {
+ @Override
+ public void execCommand(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
+ //TODO: Implementation
+ }
+
+ @Override
+ public void execCommandWithPty(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
+ //TODO: Implementation
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java
new file mode 100644
index 00000000..e840053f
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class JsonParser {
+
+ private static final Logger log = LoggerFactory.getLogger(JsonParser.class);
+
+ private JsonParser() {
+ // Preventing instantiation of the same.
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, String> convertToProperties(String s)
+ throws SvcLogicException {
+
+ checkNotNull(s, "Input should not be null.");
+
+ try {
+ JSONObject json = new JSONObject(s);
+ Map<String, Object> wm = new HashMap<>();
+ Iterator<String> ii = json.keys();
+ while (ii.hasNext()) {
+ String key1 = ii.next();
+ wm.put(key1, json.get(key1));
+ }
+
+ Map<String, String> mm = new HashMap<>();
+
+ while (!wm.isEmpty())
+ for (String key : new ArrayList<>(wm.keySet())) {
+ Object o = wm.get(key);
+ wm.remove(key);
+
+ if (o instanceof Boolean || o instanceof Number || o instanceof String) {
+ mm.put(key, o.toString());
+
+ log.info("Added property: {} : {}", key, o.toString());
+ } else if (o instanceof JSONObject) {
+ JSONObject jo = (JSONObject) o;
+ Iterator<String> i = jo.keys();
+ while (i.hasNext()) {
+ String key1 = i.next();
+ wm.put(key + "." + key1, jo.get(key1));
+ }
+ } else if (o instanceof JSONArray) {
+ JSONArray ja = (JSONArray) o;
+ mm.put(key + "_length", String.valueOf(ja.length()));
+
+ log.info("Added property: {}_length: {}", key, String.valueOf(ja.length()));
+
+ for (int i = 0; i < ja.length(); i++)
+ wm.put(key + '[' + i + ']', ja.get(i));
+ }
+ }
+ return mm;
+ } catch (JSONException e) {
+ throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e);
+ }
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java
new file mode 100644
index 00000000..9a1d3a31
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+public class RetryException extends Exception {
+
+ public RetryException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java
new file mode 100644
index 00000000..fef0f81a
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+public class RetryPolicy {
+ private String[] hostnames;
+ private Integer maximumRetries;
+
+ public Integer getMaximumRetries() {
+ return maximumRetries;
+ }
+
+ public String getNextHostName(String uri) throws RetryException {
+ Integer position = null;
+
+ for (int i = 0; i < hostnames.length; i++) {
+ if (uri.contains(hostnames[i])) {
+ position = i;
+ break;
+ }
+ }
+
+ if(position == null){
+ throw new RetryException("No match found for the provided uri[" + uri + "] " +
+ "so the next host name could not be retreived");
+ }
+ position++;
+
+ if (position > hostnames.length - 1) {
+ position = 0;
+ }
+ return hostnames[position];
+ }
+
+ public RetryPolicy(String[] hostnames, Integer maximumRetries){
+ this.hostnames = hostnames;
+ this.maximumRetries = maximumRetries;
+ }
+
+
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java
new file mode 100644
index 00000000..65575b8c
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+import java.util.HashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RetryPolicyStore {
+ private static final Logger log = LoggerFactory.getLogger(RetryPolicyStore.class);
+
+ HashMap<String, RetryPolicy> retryPolicies;
+ public String proxyServers;
+
+ public String getProxyServers() {
+ return proxyServers;
+ }
+
+ public void setProxyServers(String admServers) {
+ this.proxyServers = admServers;
+ String[] adminServersArray = admServers.split(",");
+ RetryPolicy adminPortalRetry = new RetryPolicy(adminServersArray, adminServersArray.length);
+ retryPolicies.put("dme2proxy", adminPortalRetry);
+ }
+
+ public RetryPolicyStore() {
+ retryPolicies = new HashMap<>();
+ }
+
+ public RetryPolicy getRetryPolicy(String policyName) {
+ return (this.retryPolicies.get(policyName));
+ }
+
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java
new file mode 100644
index 00000000..e7fc60ed
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java
@@ -0,0 +1,389 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class XmlJsonUtil {
+
+ private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class);
+
+ private XmlJsonUtil() {
+ // Preventing instantiation of the same.
+ }
+
+ public static String getXml(Map<String, String> varmap, String var) {
+ boolean escape = true;
+ if (var.startsWith("'")) {
+ var = var.substring(1);
+ escape = false;
+ }
+
+ Object o = createStructure(varmap, var);
+ return generateXml(o, 0, escape);
+ }
+
+ public static String getJson(Map<String, String> varmap, String var) {
+ boolean escape = true;
+ if (var.startsWith("'")) {
+ var = var.substring(1);
+ escape = false;
+ }
+
+ boolean quotes = true;
+ if (var.startsWith("\"")) {
+ var = var.substring(1);
+ quotes = false;
+ }
+
+ Object o = createStructure(varmap, var);
+ return generateJson(o, escape, quotes);
+ }
+
+ private static Object createStructure(Map<String, String> flatmap, String var) {
+ if (flatmap.containsKey(var)) {
+ if (var.endsWith("_length") || var.endsWith("].key"))
+ return null;
+ return flatmap.get(var);
+ }
+
+ Map<String, Object> mm = new HashMap<>();
+ for (String k : flatmap.keySet())
+ if (k.startsWith(var + ".")) {
+ int i1 = k.indexOf('.', var.length() + 1);
+ int i2 = k.indexOf('[', var.length() + 1);
+ int i3 = k.length();
+ if (i1 > 0 && i1 < i3)
+ i3 = i1;
+ if (i2 > 0 && i2 < i3)
+ i3 = i2;
+ String k1 = k.substring(var.length() + 1, i3);
+ String var1 = k.substring(0, i3);
+ if (!mm.containsKey(k1)) {
+ Object str = createStructure(flatmap, var1);
+ if (str != null && (!(str instanceof String) || ((String) str).trim().length() > 0))
+ mm.put(k1, str);
+ }
+ }
+ if (!mm.isEmpty())
+ return mm;
+
+ boolean arrayFound = false;
+ for (String k : flatmap.keySet())
+ if (k.startsWith(var + "[")) {
+ arrayFound = true;
+ break;
+ }
+
+ if (arrayFound) {
+ List<Object> ll = new ArrayList<>();
+
+ int length = Integer.MAX_VALUE;
+ String lengthStr = flatmap.get(var + "_length");
+ if (lengthStr != null) {
+ try {
+ length = Integer.parseInt(lengthStr);
+ } catch (Exception e) {
+ log.warn("Invalid number for {}_length:{}", var, lengthStr, e);
+ }
+ }
+
+ for (int i = 0; i < length; i++) {
+ Object v = createStructure(flatmap, var + '[' + i + ']');
+ if (v == null)
+ break;
+ ll.add(v);
+ }
+
+ if (!ll.isEmpty())
+ return ll;
+ }
+
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static String generateXml(Object o, int indent, boolean escape) {
+ if (o == null)
+ return null;
+
+ if (o instanceof String)
+ return escape ? escapeXml((String) o) : (String) o;;
+
+ if (o instanceof Map) {
+ StringBuilder ss = new StringBuilder();
+ Map<String, Object> mm = (Map<String, Object>) o;
+ for (Map.Entry<String, Object> entry: mm.entrySet()) {
+ Object v = entry.getValue();
+ String key = entry.getKey();
+ if (v instanceof String) {
+ String s = escape ? escapeXml((String) v) : (String) v;
+ ss.append(pad(indent)).append('<').append(key).append('>');
+ ss.append(s);
+ ss.append("</").append(key).append('>').append('\n');
+ } else if (v instanceof Map) {
+ ss.append(pad(indent)).append('<').append(key).append('>').append('\n');
+ ss.append(generateXml(v, indent + 1, escape));
+ ss.append(pad(indent)).append("</").append(key).append('>').append('\n');
+ } else if (v instanceof List) {
+ List<Object> ll = (List<Object>) v;
+ for (Object o1 : ll) {
+ ss.append(pad(indent)).append('<').append(key).append('>').append('\n');
+ ss.append(generateXml(o1, indent + 1, escape));
+ ss.append(pad(indent)).append("</").append(key).append('>').append('\n');
+ }
+ }
+ }
+ return ss.toString();
+ }
+
+ return null;
+ }
+
+ private static String generateJson(Object o, boolean escape, boolean quotes) {
+ if (o == null)
+ return null;
+
+ StringBuilder ss = new StringBuilder();
+ generateJson(ss, o, 0, false, escape, quotes);
+ return ss.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape, boolean quotes) {
+ if (o instanceof String) {
+ String s = escape ? escapeJson((String) o) : (String) o;
+ if (padFirst)
+ ss.append(pad(indent));
+ if (quotes) {
+ ss.append('"').append(s).append('"');
+ } else {
+ ss.append(s);
+ }
+ return;
+ }
+
+ if (o instanceof Map) {
+ Map<String, Object> mm = (Map<String, Object>) o;
+
+ if (padFirst)
+ ss.append(pad(indent));
+ ss.append("{\n");
+
+ boolean first = true;
+ for (Map.Entry<String, Object> entry : mm.entrySet()) {
+ if (!first)
+ ss.append(",\n");
+ first = false;
+ Object v = entry.getValue();
+ String key = entry.getKey();
+ ss.append(pad(indent + 1)).append('"').append(key).append("\": ");
+ generateJson(ss, v, indent + 1, false, escape, true);
+ }
+
+ ss.append("\n");
+ ss.append(pad(indent)).append('}');
+
+ return;
+ }
+
+ if (o instanceof List) {
+ List<Object> ll = (List<Object>) o;
+
+ if (padFirst)
+ ss.append(pad(indent));
+ ss.append("[\n");
+
+ boolean first = true;
+ for (Object o1 : ll) {
+ if (!first)
+ ss.append(",\n");
+ first = false;
+
+ generateJson(ss, o1, indent + 1, true, escape, quotes);
+ }
+
+ ss.append("\n");
+ ss.append(pad(indent)).append(']');
+ }
+ }
+
+ public static String removeLastCommaJson(String s) {
+ StringBuilder sb = new StringBuilder();
+ int k = 0;
+ int start = 0;
+ while (k < s.length()) {
+ int i11 = s.indexOf('}', k);
+ int i12 = s.indexOf(']', k);
+ int i1 = -1;
+ if (i11 < 0)
+ i1 = i12;
+ else if (i12 < 0)
+ i1 = i11;
+ else
+ i1 = i11 < i12 ? i11 : i12;
+ if (i1 < 0)
+ break;
+
+ int i2 = s.lastIndexOf(',', i1);
+ if (i2 < 0) {
+ k = i1 + 1;
+ continue;
+ }
+
+ String between = s.substring(i2 + 1, i1);
+ if (between.trim().length() > 0) {
+ k = i1 + 1;
+ continue;
+ }
+
+ sb.append(s.substring(start, i2));
+ start = i2 + 1;
+ k = i1 + 1;
+ }
+
+ sb.append(s.substring(start, s.length()));
+
+ return sb.toString();
+ }
+
+ public static String removeEmptyStructJson(String s) {
+ int k = 0;
+ while (k < s.length()) {
+ boolean curly = true;
+ int i11 = s.indexOf('{', k);
+ int i12 = s.indexOf('[', k);
+ int i1 = -1;
+ if (i11 < 0) {
+ i1 = i12;
+ curly = false;
+ } else if (i12 < 0)
+ i1 = i11;
+ else
+ if (i11 < i12)
+ i1 = i11;
+ else {
+ i1 = i12;
+ curly = false;
+ }
+
+ if (i1 >= 0) {
+ int i2 = curly ? s.indexOf('}', i1) : s.indexOf(']', i1);
+ if (i2 > 0) {
+ String value = s.substring(i1 + 1, i2);
+ if (value.trim().length() == 0) {
+ int i4 = s.lastIndexOf('\n', i1);
+ if (i4 < 0)
+ i4 = 0;
+ int i5 = s.indexOf('\n', i2);
+ if (i5 < 0)
+ i5 = s.length();
+
+ s = s.substring(0, i4) + s.substring(i5);
+ k = 0;
+ } else
+ k = i1 + 1;
+ } else
+ break;
+ } else
+ break;
+ }
+
+ return s;
+ }
+
+ public static String removeEmptyStructXml(String s) {
+ int k = 0;
+ while (k < s.length()) {
+ int i1 = s.indexOf('<', k);
+ if (i1 < 0 || i1 == s.length() - 1)
+ break;
+
+ char c1 = s.charAt(i1 + 1);
+ if (c1 == '?' || c1 == '!') {
+ k = i1 + 2;
+ continue;
+ }
+
+ int i2 = s.indexOf('>', i1);
+ if (i2 < 0) {
+ k = i1 + 1;
+ continue;
+ }
+
+ String closingTag = "</" + s.substring(i1 + 1, i2 + 1);
+ int i3 = s.indexOf(closingTag, i2 + 1);
+ if (i3 < 0) {
+ k = i2 + 1;
+ continue;
+ }
+
+ String value = s.substring(i2 + 1, i3);
+ if (value.trim().length() > 0) {
+ k = i2 + 1;
+ continue;
+ }
+
+ int i4 = s.lastIndexOf('\n', i1);
+ if (i4 < 0)
+ i4 = 0;
+ int i5 = s.indexOf('\n', i3);
+ if (i5 < 0)
+ i5 = s.length();
+
+ s = s.substring(0, i4) + s.substring(i5);
+ k = 0;
+ }
+
+ return s;
+ }
+
+ private static String escapeXml(String v) {
+ String s = v.replaceAll("&", "&amp;");
+ s = s.replaceAll("<", "&lt;");
+ s = s.replaceAll("'", "&apos;");
+ s = s.replaceAll("\"", "&quot;");
+ s = s.replaceAll(">", "&gt;");
+ return s;
+ }
+
+ private static String escapeJson(String v) {
+ String s = v.replaceAll("\\\\", "\\\\\\\\");
+ s = s.replaceAll("\"", "\\\\\"");
+ return s;
+ }
+
+ private static String pad(int n) {
+ StringBuilder s = new StringBuilder();
+ for (int i = 0; i < n; i++)
+ s.append(Character.toString('\t'));
+ return s.toString();
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java
new file mode 100644
index 00000000..c23aca6c
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java
@@ -0,0 +1,174 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.sshapicall.model;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public final class XmlParser {
+
+ private static final Logger log = LoggerFactory.getLogger(XmlParser.class);
+
+ private XmlParser() {
+ // Preventing instantiation of the same.
+ }
+
+ public static Map<String, String> convertToProperties(String s, Set<String> listNameList)
+ throws SvcLogicException {
+
+ checkNotNull(s, "Input should not be null.");
+
+ Handler handler = new Handler(listNameList);
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ SAXParser saxParser = factory.newSAXParser();
+ InputStream in = new ByteArrayInputStream(s.getBytes());
+ saxParser.parse(in, handler);
+ } catch (ParserConfigurationException | IOException | SAXException | NumberFormatException e) {
+ throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e);
+ }
+ return handler.getProperties();
+ }
+
+ private static class Handler extends DefaultHandler {
+
+ private Set<String> listNameList;
+
+ private Map<String, String> properties = new HashMap<>();
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public Handler(Set<String> listNameList) {
+ super();
+ this.listNameList = listNameList;
+ if (this.listNameList == null)
+ this.listNameList = new HashSet<>();
+ }
+
+ StringBuilder currentName = new StringBuilder();
+ StringBuilder currentValue = new StringBuilder();
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ super.startElement(uri, localName, qName, attributes);
+
+ String name = localName;
+ if (name == null || name.trim().length() == 0)
+ name = qName;
+ int i2 = name.indexOf(':');
+ if (i2 >= 0)
+ name = name.substring(i2 + 1);
+
+ if (currentName.length() > 0)
+ currentName.append(Character.toString('.'));
+ currentName.append(name);
+
+ String listName = removeIndexes(currentName.toString());
+
+ if (listNameList.contains(listName)) {
+ String n = currentName.toString() + "_length";
+ int len = getInt(properties, n);
+ properties.put(n, String.valueOf(len + 1));
+ currentName.append("[").append(len).append("]");
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ super.endElement(uri, localName, qName);
+
+ String name = localName;
+ if (name == null || name.trim().length() == 0)
+ name = qName;
+ int i2 = name.indexOf(':');
+ if (i2 >= 0)
+ name = name.substring(i2 + 1);
+
+ String s = currentValue.toString().trim();
+ if (s.length() > 0) {
+ properties.put(currentName.toString(), s);
+
+ log.info("Added property: {} : {}", currentName, s);
+ currentValue = new StringBuilder();
+ }
+
+ int i1 = currentName.lastIndexOf("." + name);
+ if (i1 <= 0)
+ currentName = new StringBuilder();
+ else
+ currentName = new StringBuilder(currentName.substring(0, i1));
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ super.characters(ch, start, length);
+
+ String value = new String(ch, start, length);
+ currentValue.append(value);
+ }
+
+ private static int getInt(Map<String, String> mm, String name) {
+ String s = mm.get(name);
+ if (s == null)
+ return 0;
+ return Integer.parseInt(s);
+ }
+
+ private String removeIndexes(String currentName) {
+ StringBuilder b = new StringBuilder();
+ boolean add = true;
+ for (int i = 0; i < currentName.length(); i++) {
+ char c = currentName.charAt(i);
+ if (c == '[')
+ add = false;
+ else if (c == ']')
+ add = true;
+ else if (add)
+ b.append(Character.toString(c));
+ }
+ return b.toString();
+ }
+ }
+}
diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml
new file mode 100644
index 00000000..4cce6ffa
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <value>file:${SDNC_CONFIG_DIR}/ueb.properties</value>
+ <value>file:${SDNC_CONFIG_DIR}/dme2.properties</value>
+ </list>
+ </property>
+ <property name="ignoreResourceNotFound" value="true" />
+ <property name="ignoreUnresolvablePlaceholders" value="true" />
+ </bean>
+
+ <!-- context:property-placeholder location="file:${SDNC_CONFIG_DIR}/ueb.properties" /-->
+
+ <bean id="sshapiCallNode" class="org.onap.ccsdk.sli.plugins.sshapicall.impl.SshapiCallNodeImpl">
+ <property name="uebServers" value="${servers}" />
+ <property name="retryPolicyStore" ref="retryPolicyStore"/>
+ </bean>
+
+ <bean id="retryPolicyStore" class="org.onap.ccsdk.sli.plugins.sshapicall.model.RetryPolicyStore">
+ <property name="proxyServers" value="${proxyUrl}" />
+ </bean>
+</beans>
diff --git a/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml
new file mode 100644
index 00000000..c8e9a99e
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ -->
+
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <service ref="sshapiCallNode" interface="org.onap.ccsdk.sli.plugins.sshapicall.impl.SshapiCallNodeImpl" />
+
+</beans:beans>
diff --git a/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml
new file mode 100755
index 00000000..b24aaf1e
--- /dev/null
+++ b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="sshapiCallNodeProvider" class="org.onap.ccsdk.sli.plugins.sshapicall.impl.SshapiCallNodeImpl" />
+
+
+
+ <service ref="sshapiCallNodeProvider">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode</value>
+ </interfaces>
+ </service>
+
+</blueprint> \ No newline at end of file
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java
new file mode 100644
index 00000000..9df790ae
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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 jtest.org.onap.ccsdk.sli.plugins.sshapicall;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.sshapicall.model.JsonParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestJsonParser {
+
+ private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class);
+
+ @Test
+ public void test() throws SvcLogicException, IOException {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Map<String, String> mm = JsonParser.convertToProperties(b.toString());
+
+ logProperties(mm);
+
+ in.close();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullString() throws SvcLogicException {
+ JsonParser.convertToProperties(null);
+ }
+
+ private void logProperties(Map<String, String> mm) {
+ List<String> ll = new ArrayList<>();
+ for (Object o : mm.keySet())
+ ll.add((String) o);
+ Collections.sort(ll);
+ log.info("Properties:");
+ for (String name : ll)
+ log.info("--- {}: {}", name, mm.get(name));
+ }
+}
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java
new file mode 100644
index 00000000..599043e9
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java
@@ -0,0 +1,264 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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 jtest.org.onap.ccsdk.sli.plugins.sshapicall;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlJsonUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TestXmlJsonUtil {
+
+ private static final Logger log = LoggerFactory.getLogger(TestXmlJsonUtil.class);
+
+ @Test
+ public void test() {
+ Map<String, String> mm = new HashMap<>();
+ mm.put("service-data.vnf-config-parameters-list.vnf-config-parameters[0].vnf-type", "N-SBG");
+ mm.put("service-data.service-information.service-instance-id", "someinstance001");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].dns-server-ip-address", "10.11.12.13");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].escf-domain-name", "hclab.atttest.com");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3_length", "2");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[0].snmp-target-v3-id", "1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[0].snmp-target-ip-address", "127.0.0.1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[0].snmp-security-level", "NO_AUTH_NO_PRIV");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[1].snmp-target-v3-id", "2");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[1].snmp-target-ip-address", "192.168.1.8");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].snmp-target-v3[1].snmp-security-level", "NO_AUTH_NO_PRIV");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].dns-ip-address-1", "2001:1890:1001:2224::1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].dns-ip-address-2", "2001:1890:1001:2424::1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].diameter-rf-realm-name", "uvp.els-an.att.net");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].diameter-rf-peer-ip-address", "192.168.1.66");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].bgf-controller-ip-address", "192.168.1.186");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].bgf-control-link-name", "mg3/69@192.168.1.226");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].rf-interface-nexthop-ip-address", "10.111.108.150");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].rf-mated-pair-ip-address", "10.111.108.146");
+
+ mm.put("service-data.vnf-config-parameters-list.vnf-config-parameters[0].access-net-pcscf_length", "4");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[0].network-name", "UvpbUgnAccess1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[0].sip-pa-termination-ip-address", "10.111.108.146");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[1].network-name", "MIS");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[1].proactive-transcoding-profile",
+ "trinity-transcodingProfile");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[1].next-hop-ip-address", "10.111.108.158");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[1].subnet-mask-length", "10.111.108.154");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[2].network-name", "AVPN1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[2].proactive-transcoding-profile",
+ "trinity-transcodingProfile");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[2].next-hop-ip-address", "10.111.108.166");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[2].subnet-mask-length", "10.111.108.162");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[3].network-name", "AVPN1");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[3].proactive-transcoding-profile",
+ "trinity-transcodingProfile");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[3].next-hop-ip-address", "10.129.108.166");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].access-net-pcscf[3].subnet-mask-length", "10.129.108.162");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].core-net-pcscf_length", "1");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].core-net-pcscf[0].network-name", "Core");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].core-net-pcscf[0].next-hop-ip-address", "10.111.108.142");
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].core-net-pcscf[0].sip-pa-termination-ip-address", "10.111.108.138");
+
+ mm.put("service-data.vnf-config-parameters-list." +
+ "vnf-config-parameters[0].mated-pair-fully-qualified-domain-name",
+ "mt1nj01sbg01pyl-mt1nj01sbg02pyl.ar1ga.uvp.els-an.att.net");
+
+ mm.put("service-data.appc-request-header.svc-request-id", "SOMESERVICEREQUEST123451000");
+ mm.put("service-data.vnf-config-information.vnf-host-ip-address", "192.168.13.151");
+ mm.put("service-data.vnf-config-information.vendor", "Netconf");
+
+ mm.put("service-data.vnf-config-information.escape-test",
+ "blah blah \"xxx&nnn<>\\'\"there>blah<&''\"\"123\\\\\\'''blah blah &");
+
+ String ss = XmlJsonUtil.getXml(mm, "service-data.vnf-config-parameters-list");
+ log.info(ss);
+
+ ss = XmlJsonUtil.getXml(mm, "service-data.vnf-config-information");
+ log.info(ss);
+
+ ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-parameters-list.vnf-config-parameters");
+ log.info(ss);
+
+ ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-information");
+ log.info(ss);
+
+ ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-information.vnf-host-ip-address");
+ log.info(ss);
+
+ ss = XmlJsonUtil.getJson(mm, "\"service-data.vnf-config-information.vnf-host-ip-address");
+ log.info(ss);
+ }
+
+ @Test
+ public void testRemoveEmptyStructXml() {
+ String xmlin = "" +
+ "<T1>\n" +
+ " <T2>\n" +
+ " <T3>\n" +
+ " <T4></T4>\n" +
+ " <T5> </T5>\n" +
+ " <T6>\n" +
+ " </T6>\n" +
+ " </T3>\n" +
+ " <T7>blah</T7>\n" +
+ " </T2>\n" +
+ " <T8>\n" +
+ " <T9>\n" +
+ " <T10></T10>\n" +
+ " <T11> </T11>\n" +
+ " <T12>\n" +
+ " </T12>\n" +
+ " </T9>\n" +
+ " <T13>\n" +
+ " <T14></T14>\n" +
+ " <T15> </T15>\n" +
+ " <T16>\n" +
+ " <T17></T17>\n" +
+ " </T16>\n" +
+ " </T13>\n" +
+ " <T17>\n" +
+ " </T17>\n" +
+ " </T8>\n" +
+ " <T18>blah blah</T18>\n" +
+ "</T1>\n";
+
+ String xmloutexpected = "" +
+ "<T1>\n" +
+ " <T2>\n" +
+ " <T7>blah</T7>\n" +
+ " </T2>\n" +
+ " <T18>blah blah</T18>\n" +
+ "</T1>\n";
+
+ String xmlout = XmlJsonUtil.removeEmptyStructXml(xmlin);
+ log.info(xmlout);
+
+ Assert.assertEquals(xmloutexpected, xmlout);
+ }
+
+ @Test
+ public void testRemoveEmptyStructJson() {
+ String xmlin = "{\r\n" +
+ " \"T1\":{\r\n" +
+ " \"T2\":{\r\n" +
+ " \"T3\":[\r\n" +
+ " \r\n" +
+ " ],\r\n" +
+ " \"T4\":{\r\n" +
+ " \"T12\":[\r\n" +
+ " \r\n" +
+ " ],\r\n" +
+ " \"T13\":[ ],\r\n" +
+ " \"T14\":{\r\n" +
+ " \"T15\":{\r\n" +
+ " \r\n" +
+ " },\r\n" +
+ " \"T16\":{\r\n" +
+ " \r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ " },\r\n" +
+ " \"T5\":{\r\n" +
+ " \"T6\":[\r\n" +
+ " \r\n" +
+ " ],\r\n" +
+ " \"T7\":[\r\n" +
+ " \"T8\":{\r\n" +
+ " \r\n" +
+ " },\r\n" +
+ " \"T9\":{ },\r\n" +
+ " \"T10\":\"blah\",\r\n" +
+ " \"T11\":[\r\n" +
+ " \r\n" +
+ " ]\r\n" +
+ " ]\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}\r\n" +
+ "";
+
+ String xmloutexpected = "{\r\n" +
+ " \"T1\":{\r\n" +
+ " \"T2\":{\r\n" +
+ " \"T5\":{\r\n" +
+ " \"T7\":[\r\n" +
+ " \"T10\":\"blah\",\r\n" +
+ " ]\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}\r\n" +
+ "";
+
+ String xmlout = XmlJsonUtil.removeEmptyStructJson(xmlin);
+ log.info(xmlout);
+
+ Assert.assertEquals(xmloutexpected, xmlout);
+ }
+}
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java
new file mode 100644
index 00000000..d904721f
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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 jtest.org.onap.ccsdk.sli.plugins.sshapicall;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestXmlParser {
+
+ private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class);
+
+ @Test
+ public void test() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("project.dependencies.dependency");
+ listNameList.add("project.build.plugins.plugin");
+ listNameList.add("project.build.plugins.plugin.executions.execution");
+ listNameList.add("project.build.pluginManagement.plugins.plugin");
+ listNameList.add("project.build.pluginManagement." +
+ "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
+
+ @Test
+ public void testValidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[5]"), is("SET_RESET_LP"));
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[0]"), is("SET_BVOIP_IN"));
+
+ logProperties(mm);
+ in.close();
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testInvalidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("invalidlength.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
+
+ private void logProperties(Map<String, String> mm) {
+ List<String> ll = new ArrayList<>();
+ for (Object o : mm.keySet())
+ ll.add((String) o);
+ Collections.sort(ll);
+
+ log.info("Properties:");
+ for (String name : ll)
+ log.info("--- " + name + ": " + mm.get(name));
+ }
+}
diff --git a/sshapi-call-node/provider/src/test/resources/invalidlength.xml b/sshapi-call-node/provider/src/test/resources/invalidlength.xml
new file mode 100644
index 00000000..b71f6391
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/resources/invalidlength.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ -->
+
+<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1"
+ xmlns:ns2="http://onap.org/prov/vpn/schema/v2">
+ <ApplyGroupResponseData>
+ <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId>
+ <VrfDetails>
+ <End2EndVpnKey>VPNL811182</End2EndVpnKey>
+ <VpnId>811182</VpnId>
+ <VrfName>21302:811182</VrfName>
+ <VrfImport>SET_BVOIP_IN</VrfImport>
+ <VrfImport>SET6_BVOIP_IN</VrfImport>
+ <VrfExport_length>a</VrfExport_length>
+ <VrfExport>SET6_DSU</VrfExport>
+ <VrfExport>SET_DSU</VrfExport>
+ <VrfExport>SET6_MANAGED</VrfExport>
+ <VrfExport>SET_MANAGED</VrfExport>
+ <VrfExport>SET_LOVRF_COMMUNITY</VrfExport>
+ <VrfExport>SET_RESET_LP</VrfExport>
+ <ApplyGroup>
+ <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup>
+ </ApplyGroup>
+ </VrfDetails>
+ </ApplyGroupResponseData>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</ApplyGroupResponse>
+
diff --git a/sshapi-call-node/provider/src/test/resources/test-template.json b/sshapi-call-node/provider/src/test/resources/test-template.json
new file mode 100644
index 00000000..cd5e7469
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/resources/test-template.json
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ */
+
+{
+ "sdn-circuit-request": [
+ ${repeat:tmp.sdn-circuit-req-row_length:
+ {
+ "request-id": ${tmp.sdn-circuit-req-row[${1}].request-id},
+ "source-uid": ${tmp.sdn-circuit-req-row[${1}].source-uid},
+ "action": ${tmp.sdn-circuit-req-row[${1}].action},
+ "request-timestamp": ${tmp.sdn-circuit-req-row[${1}].request-timestamp},
+ "update-timestamp": ${tmp.sdn-circuit-req-row[${1}].update-timestamp},
+ "request-status": ${tmp.sdn-circuit-req-row[${1}].request-status},
+ "processing-status": ${tmp.sdn-circuit-req-row[${1}].processing-status},
+ "reason-code": ${tmp.sdn-circuit-req-row[${1}].reason-code},
+ "reason-message": ${tmp.sdn-circuit-req-row[${1}].reason-message},
+ "customer-code": ${tmp.sdn-circuit-req-row[${1}].customer-code},
+ "bundle-id": ${tmp.sdn-circuit-req-row[${1}].bundle-id},
+ "router-name-1": ${tmp.sdn-circuit-req-row[${1}].router-name-1},
+ "tail-clfi-1": ${tmp.sdn-circuit-req-row[${1}].tail-clfi-1},
+ "srg-1": ${tmp.sdn-circuit-req-row[${1}].srg-1},
+ "router-name-2": ${tmp.sdn-circuit-req-row[${1}].router-name-2},
+ "tail-clfi-2": ${tmp.sdn-circuit-req-row[${1}].tail-clfi-2},
+ "srg-2": ${tmp.sdn-circuit-req-row[${1}].srg-2},
+ "facility-speed": ${tmp.sdn-circuit-req-row[${1}].facility-speed},
+ "facility-speed-units": ${tmp.sdn-circuit-req-row[${1}].facility-speed-units},
+ "facility-type": ${tmp.sdn-circuit-req-row[${1}].facility-type},
+ "service-clfi": ${tmp.sdn-circuit-req-row[${1}].service-clfi},
+ "clci": ${tmp.sdn-circuit-req-row[${1}].clci},
+ "wavelength-purpose": ${tmp.sdn-circuit-req-row[${1}].wavelength-purpose},
+ "activate-setting": ${tmp.sdn-circuit-req-row[${1}].activate-setting},
+ "apply-date": ${tmp.sdn-circuit-req-row[${1}].apply-date},
+ "run-id": ${tmp.sdn-circuit-req-row[${1}].run-id},
+ "hostname": ${tmp.sdn-circuit-req-row[${1}].hostname},
+ "algo-request-reason": ${tmp.sdn-circuit-req-row[${1}].algo-request-reason}
+ },
+ }
+ ]
+}
diff --git a/sshapi-call-node/provider/src/test/resources/test.json b/sshapi-call-node/provider/src/test/resources/test.json
new file mode 100644
index 00000000..e272d457
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/resources/test.json
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ */
+
+{
+ "equipment-data": [
+ {
+ "server-count": "4",
+ "max-server-speed": "1600000",
+ "number-primary-servers": "2",
+ "equipment-id": "Server1",
+ "server-model": "Unknown",
+ "server-id": "Server1",
+ "test-node" : {
+ "test-inner-node" : "Test-Value"
+ }
+ }
+ ],
+ "resource-state": {
+ "threshold-value": "1600000",
+ "last-added": "1605000",
+ "used": "1605000",
+ "limit-value": "1920000"
+ },
+ "resource-rule": {
+ "endpoint-position": "VCE-Cust",
+ "soft-limit-expression": "0.6 * max-server-speed * number-primary-servers",
+ "resource-name": "Bandwidth",
+ "service-model": "DUMMY",
+ "hard-limit-expression": "max-server-speed * number-primary-servers",
+ "equipment-level": "Server"
+ },
+ "message": "The provisioned access bandwidth is at or exceeds 50% of the total server capacity."
+}
diff --git a/sshapi-call-node/provider/src/test/resources/test.xml b/sshapi-call-node/provider/src/test/resources/test.xml
new file mode 100644
index 00000000..7645f199
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/resources/test.xml
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property.
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.sli.plugins</groupId>
+ <artifactId>sshapi-call-node</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>sshapi-call-node-provider</artifactId>
+ <packaging>bundle</packaging>
+ <name>SSHAPI Call Node - Provider</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>3.1.4.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-signature</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-client</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.brocade.developer</groupId>
+ <artifactId>providermodule-plugin</artifactId>
+ <configuration>
+ <packageId>org.onap.ccsdk.sli.plugins</packageId>
+ <appName>sshapi-call-node</appName>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.onap.ccsdk.sli.plugins.sshapicall</Bundle-SymbolicName>
+ <Export-Package>org.onap.ccsdk.sli.plugins.sshapicall</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+
+ </configuration>
+
+ </plugin>
+
+
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ com.brocade.developer
+ </groupId>
+ <artifactId>
+ providermodule-plugin
+ </artifactId>
+ <versionRange>
+ [1.2.0.100-SNAPSHOT,)
+ </versionRange>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/sshapi-call-node/provider/src/test/resources/test3.xml b/sshapi-call-node/provider/src/test/resources/test3.xml
new file mode 100644
index 00000000..52a7a7d9
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/resources/test3.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2018 Samsung Electronics. 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=========================================================
+ -->
+
+<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1"
+ xmlns:ns2="http://onap.org/prov/vpn/schema/v2">
+ <ApplyGroupResponseData>
+ <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId>
+ <VrfDetails>
+ <End2EndVpnKey>VPNL811182</End2EndVpnKey>
+ <VpnId>811182</VpnId>
+ <VrfName>21302:811182</VrfName>
+ <VrfImport>SET_BVOIP_IN</VrfImport>
+ <VrfImport>SET6_BVOIP_IN</VrfImport>
+ <VrfExport>SET6_DSU</VrfExport>
+ <VrfExport>SET_DSU</VrfExport>
+ <VrfExport>SET6_MANAGED</VrfExport>
+ <VrfExport>SET_MANAGED</VrfExport>
+ <VrfExport>SET_LOVRF_COMMUNITY</VrfExport>
+ <VrfExport>SET_RESET_LP</VrfExport>
+ <ApplyGroup>
+ <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup>
+ </ApplyGroup>
+ </VrfDetails>
+ <RoutingApplyGroups>
+ <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol>
+ <Family>v4</Family>
+ <PeerGroupName>gp_21302:811182</PeerGroupName>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG_L3VPN_EBGP</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG_MAX_PREFIX</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG_BGP_UNMANAGED</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG_BFD_BGP_3000</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ </RoutingApplyGroups>
+ <RoutingApplyGroups>
+ <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol>
+ <Family>v6</Family>
+ <PeerGroupName>gp6_21302:811182</PeerGroupName>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG6_L3VPN_EBGP</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG6_MAX_PREFIX</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG6_BGP_UNMANAGED</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG6_BFD_BGP_3000</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ </RoutingApplyGroups>
+ </ApplyGroupResponseData>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</ApplyGroupResponse>
+